Last active
February 23, 2022 10:36
-
-
Save nikku/e12e681a7002c8750af5d56b2805266c to your computer and use it in GitHub Desktop.
Quick hack of a readable DSL for writing assertions in Kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.test.assertEquals | |
fun <T> equal(expected: T) : (T) -> Unit { | |
return { t -> | |
assertEquals(t, expected); | |
} | |
} | |
infix fun <T> T.should(matcher: (T) -> Unit) { | |
matcher(this); | |
} | |
// in test | |
"FOO" should equal("5"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment