testSame

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.

Example (REPL) usages:

>>> testSame(1 == 2, true, "intentional failure")
Test (intentional failure): expected=true, got=false
>>> testSame(1 + 1, 2)
Test: passed
>>> testSame({ x: Int -> x + 1 }(5), 6, "lambda")
Test (lambda): passed

Parameters

T

type of the expression and expected results

unsure

expression to evaluate

expectedResult

expression considered correct

testName

visual indication of which test was run