JS: move more test to box tests

This commit is contained in:
Alexey Andreev
2016-08-29 14:51:32 +03:00
parent a18f5eca2d
commit 9bf124af3f
129 changed files with 766 additions and 685 deletions
+60
View File
@@ -0,0 +1,60 @@
package foo
val EXPECTED = """Hello, World
***
####
"""
val EXPECTED_NEWLINE_FOR_EACH = """Hello
, World
***
##
##
"""
@native
var buffer: String = noImpl
fun test(expected: String, initCode: String, getResult: () -> String) {
buffer = ""
eval("kotlin.out = new $initCode")
print("Hello")
print(", World")
print("\n")
println()
println("***")
print("##")
print("##")
println()
val actual = getResult()
assertEquals(expected, actual, initCode)
}
fun box(): String {
test(EXPECTED, "kotlin.NodeJsOutput(outputStream)") {
buffer
}
test(EXPECTED_NEWLINE_FOR_EACH, "kotlin.OutputToConsoleLog()") {
buffer
}
test(EXPECTED, "kotlin.BufferedOutput()") {
eval("kotlin.out.buffer") as String
}
test(EXPECTED, "kotlin.BufferedOutputToConsoleLog()") {
buffer
}
return "OK"
}