-
-
Save harsh183/10e879a31a4008aa4f741d34ecd36b9e to your computer and use it in GitHub Desktop.
A very hacky quick test thingy I wrote because I did not want to deal with libraries and imports but show people basic exercises. I'm pretty sure it'll fall apart on basic security.
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
fun main() { | |
println("Running stuff") | |
case("5 + 10") { | |
var x = 15; | |
x = x + 10 | |
add(5, 10) == x | |
} | |
case("10 + 15") { | |
add(10, 15) == 25 | |
} | |
case("Negative") { | |
add(10, -15) == -5 | |
} | |
case("Zero") { | |
add(10, 0) == 10 | |
} | |
} | |
fun case(name: String, code: () -> Boolean): Boolean { | |
val result = code() | |
val resultDisplay = if (result) "PASSED" else "FAILED" | |
println("TEST $name -> $resultDisplay") | |
return result | |
} | |
fun add(a: Int, b: Int): Int { | |
return a + b | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment