JS: move more test to box tests
This commit is contained in:
+60
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user