Created
April 1, 2016 12:09
-
-
Save occar421/46b1c22abcceff8e6176ceef89e3a326 to your computer and use it in GitHub Desktop.
actual should be { expected } and actual should not be { expected }
This file contains 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
class SN<T>(val value: T) | |
class B<T>(val value: T) | |
infix fun <T> T.should(right: B<T>): Unit { | |
println("$this is ${right.value}") | |
} | |
fun <T> be(value: () -> T): B<T> { | |
return B(value()) | |
} | |
infix fun <T> T.should(right: not): SN<T> = SN(this) | |
object not | |
infix fun <T> SN<T>.be(value: () -> T): Unit { | |
println("${this.value} isn't ${value()}") | |
} | |
fun main(args: Array<String>) { | |
(1) should be { 1 } | |
(1) should not be { 2 } | |
(1) should be { 1 } | |
(1 + 1) should be { 2 } | |
1 should be { 1 } | |
(2) should not be { 1 } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment