backend/tests: Add blackbox tests from Kotlin JVM

Added tests from testData/codegen/box directory. There are blackbox tests
in other directories and they are to be added.
This commit is contained in:
Ilya Matveev
2017-01-12 19:43:20 +07:00
parent d5988297b1
commit 1b553ebfaf
2643 changed files with 66666 additions and 0 deletions
@@ -0,0 +1,14 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
data class A(var x: Int) : Cloneable {
public override fun clone(): A = A(x)
}
fun box(): String {
val a = A(42)
val b = a.clone()
if (b != a) return "Fail equals"
if (b === a) return "Fail identity"
return "OK"
}
@@ -0,0 +1,14 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
data class A(var x: Int) : Cloneable {
public override fun clone(): A = super.clone() as A
}
fun box(): String {
val a = A(42)
val b = a.clone()
if (a != b) return "Fail equals"
if (a === b) return "Fail identity"
return "OK"
}
@@ -0,0 +1,19 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
data class A(var x: Int) : Cloneable {
public override fun clone(): A {
val result = super.clone() as A
result.x = 239
return result
}
}
fun box(): String {
val a = A(42)
val b = a.clone()
if (a == b) return "Fail: $a == $b"
if (a === b) return "Fail: $a === $b"
if (b.x != 239) return "Fail: b.x = ${b.x}"
return "OK"
}
@@ -0,0 +1,12 @@
// TARGET_BACKEND: JVM
fun box(): String {
val a = HashSet<String>()
a.add("live")
a.add("long")
a.add("prosper")
val b = a.clone()
if (a != b) return "Fail equals"
if (a === b) return "Fail identity"
return "OK"
}
@@ -0,0 +1,32 @@
// TARGET_BACKEND: JVM
open class A : Cloneable {
public override fun clone(): A = super.clone() as A
}
open class B(var s: String) : A() {
override fun clone(): B = super.clone() as B
}
open class C(s: String, var l: ArrayList<Any>): B(s) {
override fun clone(): C {
val result = super.clone() as C
result.l = l.clone() as ArrayList<Any>
return result
}
}
fun box(): String {
val l = ArrayList<Any>()
l.add(true)
val c = C("OK", l)
val d = c.clone()
if (c.s != d.s) return "Fail s: ${d.s}"
if (c.l != d.l) return "Fail l: ${d.l}"
if (c.l === d.l) return "Fail list identity"
if (c === d) return "Fail identity"
return "OK"
}
@@ -0,0 +1,14 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
data class A(val s: String) : Cloneable {
fun externalClone(): A = clone() as A
}
fun box(): String {
val a = A("OK")
val b = a.externalClone()
if (a != b) return "Fail equals"
if (a === b) return "Fail identity"
return b.s
}