JS: move more test to box tests

This commit is contained in:
Alexey Andreev
2016-08-30 15:31:53 +03:00
parent 3801052460
commit 34bf3e6e56
196 changed files with 1162 additions and 1293 deletions
@@ -0,0 +1,34 @@
package foo
public interface A {
fun foo() {
}
}
public interface B : A {
fun boo() {
}
}
@native class Function(vararg args: String)
val hasProp = Function("obj, prop", "return obj[prop] !== undefined") as ((Any, String) -> Boolean)
fun box(): String {
val a = object: A {
}
val b = object: B {
}
if (!hasProp(a, "foo")) return "A hasn't foo"
if (hasProp(a, "boo")) return "A has boo"
if (!hasProp(b, "foo")) return "B hasn't foo"
if (!hasProp(b, "boo")) return "B hasn't boo"
val PREFIX = "kotlin.modules.JS_TESTS.foo"
if (eval("$PREFIX.A") == null) return "$PREFIX.A not found"
if (eval("$PREFIX.B") == null) return "$PREFIX.B not found"
if (eval("$PREFIX.A === $PREFIX.B") as Boolean) return "A and B refer to the same object"
return "OK"
}
@@ -0,0 +1,21 @@
package foo
open class A() {
val value = "O"
}
interface Test {
fun addFoo(s: String): String {
return s + "K"
}
}
class B() : A(), Test {
fun eval(): String {
return addFoo(value);
}
}
fun box() = B().eval()
@@ -0,0 +1,21 @@
package foo
open class A() {
val value = "O"
}
interface Test {
fun addFoo(s: String): String {
return s + "K"
}
}
class B() : Test, A() {
fun eval(): String {
return addFoo(value);
}
}
fun box() = B().eval()
+54
View File
@@ -0,0 +1,54 @@
package foo
class C() : B() {
init {
order = order + "C"
}
}
class D() : B() {
init {
order = order + "D"
}
}
class E() : A() {
init {
order = order + "E"
}
}
open class B() : A(), F {
init {
order = order + "B"
}
}
open class A() : F {
var order = ""
init {
order = order + "A"
}
}
interface F : G {
fun bar() = "F"
}
// KT-3437
interface G : H
interface K : H
interface L
interface H : L
interface Dummy
fun box(): String {
if (C().order != "ABC") return "fail1"
if (D().order != "ABD") return "fail2"
if (E().order != "AE") return "fail3"
if (C().bar() != "F") return "fail4"
if (A().bar() != "F") return "fail5"
return "OK"
}
+13
View File
@@ -0,0 +1,13 @@
package foo
interface AL {
fun get(index: Int): Any? = null
}
class SmartArrayList() : AL {
}
fun box(): String {
val c = SmartArrayList()
return if (null == c.get(0)) return "OK" else "fail"
}
+22
View File
@@ -0,0 +1,22 @@
package foo
open class Base() {
fun n(n: Int): Int = n + 1
}
interface Abstract {
}
class Derived1() : Base(), Abstract {
}
class Derived2() : Abstract, Base() {
}
fun test(s: Base): Boolean = s.n(238) == 239
fun box(): String {
if (!test(Base())) return "Fail #1"
if (!test(Derived1())) return "Fail #2"
if (!test(Derived2())) return "Fail #3"
return "OK"
}
@@ -0,0 +1,21 @@
package foo
interface Test {
fun addFoo(s: String): String {
return s + "FOO"
}
fun addBar(s: String): String {
return s + "BAR"
}
}
class A() : Test {
val string = "TEST"
fun value(): String {
return addBar(addFoo(string))
}
}
fun box() = if (A().value() == "TESTFOOBAR") "OK" else "fail"
@@ -0,0 +1,21 @@
package foo
interface Test {
fun addFoo(s: String): String {
return s + "FOO"
}
}
interface ExtendedTest : Test {
fun hooray(): String {
return "hooray"
}
}
class A() : ExtendedTest {
fun eval(): String {
return addFoo(hooray());
}
}
fun box() = if (A().eval() == "hoorayFOO") "OK" else "fail"
@@ -0,0 +1,25 @@
package foo
interface A {
fun addFoo(s: String): String {
return s + "K"
}
}
interface B {
fun hooray(): String {
return "O"
}
}
interface AD : A, B {
}
class Test() : AD {
fun eval(): String {
return addFoo(hooray());
}
}
fun box() = Test().eval()