JS backend: testFiles -> testData
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package foo
|
||||
|
||||
public trait A {
|
||||
fun foo() {
|
||||
}
|
||||
}
|
||||
public trait B : A {
|
||||
fun boo() {
|
||||
}
|
||||
}
|
||||
|
||||
native fun eval(code: String): Any = noImpl
|
||||
native val undefined: Any = noImpl
|
||||
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 = "BAR"
|
||||
}
|
||||
|
||||
trait Test {
|
||||
fun addFoo(s: String): String {
|
||||
return s + "FOO"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class B() : A(), Test {
|
||||
fun eval(): String {
|
||||
return addFoo(value);
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = B().eval() == "BARFOO"
|
||||
@@ -0,0 +1,21 @@
|
||||
package foo
|
||||
|
||||
|
||||
open class A() {
|
||||
val value = "BAR"
|
||||
}
|
||||
|
||||
trait Test {
|
||||
fun addFoo(s: String): String {
|
||||
return s + "FOO"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class B() : Test, A() {
|
||||
fun eval(): String {
|
||||
return addFoo(value);
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = B().eval() == "BARFOO"
|
||||
@@ -0,0 +1,48 @@
|
||||
package foo
|
||||
|
||||
class C() : B() {
|
||||
{
|
||||
order = order + "C"
|
||||
}
|
||||
}
|
||||
|
||||
class D() : B() {
|
||||
{
|
||||
order = order + "D"
|
||||
}
|
||||
}
|
||||
|
||||
class E() : A() {
|
||||
{
|
||||
order = order + "E"
|
||||
}
|
||||
}
|
||||
|
||||
open class B() : A(), F {
|
||||
{
|
||||
order = order + "B"
|
||||
}
|
||||
}
|
||||
|
||||
open class A() : F {
|
||||
|
||||
var order = ""
|
||||
{
|
||||
order = order + "A"
|
||||
}
|
||||
}
|
||||
|
||||
trait F : G {
|
||||
fun bar() = "F"
|
||||
}
|
||||
|
||||
// KT-3437
|
||||
trait G : H
|
||||
trait K : H
|
||||
trait L
|
||||
trait H : L
|
||||
trait Dummy
|
||||
|
||||
fun box(): Boolean {
|
||||
return (C().order == "ABC") && (D().order == "ABD") && (E().order == "AE") && (C().bar() == "F") && (A().bar() == "F")
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package foo
|
||||
|
||||
trait AL {
|
||||
fun get(index: Int): Any? = null
|
||||
}
|
||||
|
||||
class SmartArrayList() : AL {
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
val c = SmartArrayList()
|
||||
return (null == c.get(0))
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package foo
|
||||
|
||||
open class Base() {
|
||||
fun n(n: Int): Int = n + 1
|
||||
}
|
||||
|
||||
trait 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
|
||||
|
||||
trait 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() = A().value() == "TESTFOOBAR"
|
||||
@@ -0,0 +1,21 @@
|
||||
package foo
|
||||
|
||||
trait Test {
|
||||
fun addFoo(s: String): String {
|
||||
return s + "FOO"
|
||||
}
|
||||
}
|
||||
|
||||
trait ExtendedTest : Test {
|
||||
fun hooray(): String {
|
||||
return "hooray"
|
||||
}
|
||||
}
|
||||
|
||||
class A() : ExtendedTest {
|
||||
fun eval(): String {
|
||||
return addFoo(hooray());
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = (A().eval() == "hoorayFOO")
|
||||
@@ -0,0 +1,25 @@
|
||||
package foo
|
||||
|
||||
trait A {
|
||||
fun addFoo(s: String): String {
|
||||
return s + "FOO"
|
||||
}
|
||||
}
|
||||
|
||||
trait B {
|
||||
fun hooray(): String {
|
||||
return "hooray"
|
||||
}
|
||||
}
|
||||
|
||||
trait AD : A, B {
|
||||
|
||||
}
|
||||
|
||||
class Test() : AD {
|
||||
fun eval(): String {
|
||||
return addFoo(hooray());
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = (Test().eval() == "hoorayFOO")
|
||||
Reference in New Issue
Block a user