Add Contract tests for JS

This commit is contained in:
Roman Artemev
2018-11-01 17:43:36 +03:00
committed by romanart
parent caad0d5a74
commit b010d9eef8
17 changed files with 340 additions and 1 deletions
@@ -0,0 +1,16 @@
class Foo(
val width: Int,
val height: Int,
// This function tells the constructor which cells are alive
// if init(i, j) is true, the cell (i, j) is alive
init: (Int, Int) -> String
) {
val live: Array<Array<String>> = Array(height) { i -> Array(width) { j -> init(i, j) } }
}
fun box(): String {
val foo = Foo(2, 2) { i, j -> if (i == j) (if (i == 0) "O" else "K") else "Fail@[$i, $j]" }
return foo.live[0][0] + foo.live[1][1]
}