Package-level declarations

Types

Link copied to clipboard
data class CapturedResult<T>(val returnedValue: T, val consoleOutput: List<String>)

Combined representation of executing a function: the return value as well as any console output.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class EnabledTest

Marks a function as a test to be run

Functions

Link copied to clipboard
fun <T> captureResults(f: () -> T, vararg consoleLines: String): CapturedResult<T>

Executes a function, simulating the supplied text as coming from the console (one per line) and produces the resulting function return value and console output.

Link copied to clipboard

Determines if a file exists at the supplied path.

Link copied to clipboard

Gets the entire file contents as a list of strings (one per line).

Link copied to clipboard

Gets the entire file contents as a string.

Link copied to clipboard
fun fileWrite(path: String, contents: String)

Writes a string as the contents of a file (overwriting if the path already exists).

Link copied to clipboard
fun input(): String

Gets a string from the console.

Link copied to clipboard

Determines if the supplied string is a valid integer.

Link copied to clipboard
fun linesToString(vararg lines: String): String

Converts a sequence of strings into a single string, separated by new lines.

Link copied to clipboard
fun <S> reactConsole(initialState: S, stateToText: (S) -> String, nextState: (S, String) -> S, isTerminalState: (S) -> Boolean, terminalStateToText: (S) -> String = stateToText): S

An event-driven approach to decomposing console programs, which provides for explicit representation of state and functions to provide state-driven output, transition (via state and console input), and termination detection.

Link copied to clipboard
fun runEnabledTests(myObj: Any)

Runs all annotated tests in a supplied object.

Link copied to clipboard
fun <T> testSame(unsure: T, expectedResult: T, testName: String = "")

Outputs a report as to whether the unsure expression is the same as the expected result.