JS: move more test to box tests
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
import bar.*
|
||||
|
||||
open class A() {
|
||||
open fun f() = 3;
|
||||
}
|
||||
|
||||
open class C() : B() {
|
||||
override fun f() = 5
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A().f() != 3) return "fail1"
|
||||
if (B().f() != 4) return "fail2"
|
||||
if (C().f() != 5) return "fail3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package bar
|
||||
|
||||
import foo.A
|
||||
|
||||
open class B() : A() {
|
||||
override fun f() = 4
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
fun box() = (b.foo.A().tadada(b.foo.A()))
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.foo
|
||||
|
||||
class A() {
|
||||
fun tadada(a: A) = "OK"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
import b.foo.*
|
||||
|
||||
fun box() = (A().tadada(A()))
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.foo
|
||||
|
||||
class A() {
|
||||
fun tadada(a: A) = "OK"
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package bar
|
||||
|
||||
fun f() = 3;
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
import bar.*
|
||||
|
||||
fun box() = if (f() == 3) "OK" else "fail"
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
fun box() = b.bar.f()
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.bar
|
||||
|
||||
fun f() = "OK"
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
val a = 2
|
||||
|
||||
fun box() = if ((a + bar.a) == 5) "OK" else "fail"
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package bar
|
||||
|
||||
val a = 3
|
||||
@@ -0,0 +1,55 @@
|
||||
// FILE: a.kt
|
||||
package bar
|
||||
|
||||
fun topLevelFun(s: String) = "topLevelFun: ${s}";
|
||||
|
||||
var topLevelVar = 100
|
||||
|
||||
val topLevelVal = 200
|
||||
|
||||
class A(val v: String) {
|
||||
fun memA(s: String) = "memA: ${v} ${s}"
|
||||
var propVar: Int = 1000
|
||||
val propVal: Int = 2000
|
||||
var text: String = "text"
|
||||
}
|
||||
|
||||
fun A.ext1(s: String): String = "A.ext1: ${this.v} ${s}"
|
||||
|
||||
var A.extProp: String
|
||||
get() = "${this.text}"
|
||||
set(value) {
|
||||
this.text = value
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
import bar.*
|
||||
|
||||
fun A.ext2(s: String): String = "A.ext2: ${this.v} ${s}"
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals("topLevelFun: A", (::topLevelFun)("A"))
|
||||
assertEquals("A.ext1: test B", (A::ext1)(A("test"), "B"))
|
||||
assertEquals("A.ext2: test B", (A::ext2)(A("test"), "B"))
|
||||
assertEquals("memA: test C", (A::memA)(A("test"), "C"))
|
||||
|
||||
assertEquals(100, ::topLevelVar.get())
|
||||
::topLevelVar.set(500)
|
||||
assertEquals(500, ::topLevelVar.get())
|
||||
assertEquals(200, ::topLevelVal.get())
|
||||
val a = A("test")
|
||||
assertEquals(1000, (A::propVar).get(a))
|
||||
A::propVar.set(a, 5000)
|
||||
assertEquals(5000, (A::propVar).get(a))
|
||||
assertEquals(2000, (A::propVal).get(a))
|
||||
|
||||
assertEquals("text", (A::extProp).get(a))
|
||||
(A::extProp).set(a, "new text")
|
||||
assertEquals("new text", (A::extProp).get(a))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
fun box() = if (b.foo.f() == 1) "OK" else "fail"
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.foo
|
||||
|
||||
fun f() = 1
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
import b.foo.f
|
||||
|
||||
fun box() = if (f() == 1) "OK" else "fail"
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.foo
|
||||
|
||||
fun f() = 1
|
||||
Reference in New Issue
Block a user