JS: introduce a new base class for generated tests

This commit is contained in:
Alexey Andreev
2016-07-29 16:20:11 +03:00
parent 282629f618
commit dc0d7114be
22 changed files with 695 additions and 354 deletions
@@ -1,8 +0,0 @@
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
fun box(): String {
if ((Boolean::not)(true) != false) return "Fail 1"
if ((Boolean::not)(false) != true) return "Fail 2"
return "OK"
}
@@ -14,12 +14,14 @@ fun A.bar(x: Int): Int {
return x
}
fun box(): Boolean {
fun box(): String {
val funRef = A::bar
val obj = A()
var result = funRef(obj, 25)
if (result != 25 || obj.xx != 200) return false
if (result != 25 || obj.xx != 200) return "fail1: result = $result, expected 25; obj.xx = $obj.xx, expected 200"
result = run(A(), 25, funRef)
return result == 25 && obj.xx == 200
if (result != 25 || obj.xx != 200) return "fail2: result = $result, expected 25; obj.xx = $obj.xx, expected 200"
return "OK"
}
@@ -1,20 +0,0 @@
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
fun run(arg: Int, funRef:(Int) -> Int): Int {
return funRef(arg)
}
fun inc(x: Int) = x + 1
fun tmp():Function1<Int, Int> {
return ::inc
}
fun box(): Boolean {
if (tmp()(5) != 6) return false
if (run(5, tmp()) != 6) return false
return true
}
@@ -6,13 +6,13 @@ fun run(arg: Int, funRef:(Int) -> Int): Int {
}
fun inc(x: Int) = x + 1
fun box(): Boolean {
fun box(): String {
val funRef = ::inc
if (funRef(5) != 6) return false
if (funRef(5) != 6) return "fail1"
if (run(5, funRef) != 6) return false
if (run(5, funRef) != 6) return "fail2"
if (run(5) {x -> x + 1} != 6) return false
if (run(5) {x -> x + 1} != 6) return "fail3"
return true
return "OK"
}
-2
View File
@@ -1,2 +0,0 @@
function B() {
}
+5
View File
@@ -1,3 +1,4 @@
// FILE: is.kt
package foo
class A
@@ -15,4 +16,8 @@ fun box(): String {
testFalse { b is A }
return "OK"
}
// FILE: is.js
function B() {
}
@@ -0,0 +1,14 @@
// MODULE: main(module1)
// FILE: main.kt
fun box(): String {
var module1 = bar()
assertEquals("bar", module1)
return "OK"
}
// MODULE: module1
// FILE: module1.kt
fun bar() = "bar"
@@ -1,2 +0,0 @@
module1->
main->module1
@@ -1,6 +0,0 @@
fun box(): String {
var module1 = bar()
assertEquals("bar", module1)
return "OK"
}
@@ -1 +0,0 @@
fun bar() = "bar"
@@ -0,0 +1,17 @@
// MODULE: main(module1)
// FILE: main.kt
fun box(): String {
assertEquals("A: invoked from module", f("A"))
assertEquals(10, A(10).x)
return "OK"
}
// MODULE: module1
// FILE: module1.kt
public fun f(s: String): String = "${s}: invoked from module"
public class A(val x: Int)
@@ -1,2 +0,0 @@
module1->
main->module1
@@ -1,7 +0,0 @@
fun box(): String {
assertEquals("A: invoked from module", f("A"))
assertEquals(10, A(10).x)
return "OK"
}
@@ -1,3 +0,0 @@
public fun f(s: String): String = "${s}: invoked from module"
public class A(val x: Int)