[JS TESTS] Rewrite web demo tests using new test infrastructure

This commit is contained in:
Ivan Kylchik
2021-10-20 22:15:16 +03:00
parent af0e40a0d2
commit 8a1362de03
45 changed files with 369 additions and 579 deletions
@@ -0,0 +1,21 @@
// MAIN_ARGS: []
// Return null if str does not hold a number
fun myParseInt(str: String): Int? = str.toIntOrNull().also {
if (it == null) println("One of arguments isn't Int")
}
fun main(args: Array<String>) {
if (args.size < 2) {
print("No number supplied");
}
else {
val x = myParseInt(args[0])
val y = myParseInt(args[1])
// We cannot say 'x * y' now because they may hold nulls
if (x != null && y != null) {
print(x * y) // Now we can
}
}
}