Remove duplicate tests from JS compiler test set. Merge chages to common compiler tests

This commit is contained in:
Svyatoslav Kuzmich
2019-02-18 15:40:23 +03:00
parent a736756ceb
commit beb5f73a2b
80 changed files with 56 additions and 2086 deletions
@@ -1,13 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1291
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
abstract class A {
abstract fun foo(): String
}
class B : A() {
override fun foo() = "OK"
}
fun box(): String = (A::foo)(B())
@@ -1,26 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1286
package foo
class A {
val s = "sA"
fun memBar(other: String): String = s +":memBar:" + other
}
fun A.extBar(other: String):String = s + ":extBar:" + other
fun box():String {
fun A.locExtBar(other: String):String = s + ":locExtBar:" + other
val a = A()
var r = (A::memBar)(a, "!!")
if (r != "sA:memBar:!!") return r
r = (A::extBar)(a, "!!")
if (r != "sA:extBar:!!") return r
r = (A::locExtBar)(a, "!!")
if (r != "sA:locExtBar:!!") return r
return "OK"
}
@@ -1,15 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1285
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
fun bar(k: Int) = k
fun result() = (A::bar)(this, 111)
}
fun box(): String {
val result = A().result()
if (result != 111) return "Fail $result"
return "OK"
}
@@ -1,16 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1286
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
fun o() = 111
fun k(k: Int) = k
}
fun A.bar() = (A::o)(this) + (A::k)(this, 222)
fun box(): String {
val result = A().bar()
if (result != 333) return "Fail $result"
return "OK"
}
@@ -1,13 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1284
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
fun foo() = "OK"
}
fun box(): String {
val x = A::foo
var r = x(A())
return r
}
@@ -1,14 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1284
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
fun foo(result: String):String = result
}
fun box(): String {
val x = A::foo
var r = x(A(), "OK")
return r
}
@@ -1,18 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1284
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
var result = "Fail"
fun foo() {
result = "OK"
}
}
fun box(): String {
val a = A()
val x = A::foo
x(a)
return a.result
}
@@ -1,18 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1284
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
var result = "Fail"
fun foo(newResult: String) {
result = newResult
}
}
fun box(): String {
val a = A()
val x = A::foo
x(a, "OK")
return a.result
}
@@ -1,13 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1281
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
fun box(): String {
var result = "Fail"
fun changeToOK() { result = "OK" }
val ok = ::changeToOK
ok()
return result
}
@@ -1,9 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1282
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
var result = "OK"
}
fun box() = (::A)().result
@@ -1,7 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1282
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A(val result: String)
fun box() = (::A)("OK").result
@@ -1,10 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1283
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
class A
fun box(): String {
fun A.foo() = "OK"
return (A::foo)(A())
}
@@ -1,11 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1285
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
fun result() = (A::bar)(this, "OK")
}
fun A.bar(x: String) = x
fun box() = A().result()
@@ -1,11 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1284
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A
fun A.foo() = (A::bar)(this, "OK")
fun A.bar(x: String) = x
fun box() = A().foo()
@@ -1,22 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1284
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
fun run(arg1: A, funRef:A.() -> String): String {
return arg1.funRef()
}
class A
fun A.foo() = "OK"
fun box(): String {
val x = A::foo
var r = x(A())
if (r != "OK") return r
r = run(A(), A::foo)
if (r != "OK") return r
return "OK"
}
@@ -1,20 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1284
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
fun run(arg1: A, arg2: String, funRef:A.(String) -> String): String {
return arg1.funRef(arg2)
}
class A
fun A.foo(result: String) = result
fun box(): String {
val x = A::foo
var r = x(A(), "OK")
if (r != "OK") return r
r = run(A(), "OK", A::foo)
return "OK"
}
@@ -1,19 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1283
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
class A {
var result = "Fail"
}
fun A.foo() {
result = "OK"
}
fun box(): String {
val a = A()
val x = A::foo
x(a)
return a.result
}
@@ -1,32 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1283
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
fun run(arg1: A, arg2: String, funRef:A.(String) -> Unit): Unit {
return arg1.funRef(arg2)
}
class A {
var result = "Fail"
}
fun A.foo(newResult: String) {
result = newResult
}
fun box(): String {
val a = A()
val x = A::foo
x(a, "OK")
if (a.result != "OK") return a.result
// TODO: uncomment when KT-13312 gets fixed
/*
val a1 = A()
run(a1, "OK", A::foo)
if (a1.result != "OK) return a1.result
*/
return "OK"
}
@@ -1,8 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1281
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
fun box(): String {
fun Int.is42With(that: Int) = this + 2 * that == 42
return if ((Int::is42With)(16, 13)) "OK" else "Fail"
}
@@ -1,15 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1283
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
class A
fun box(): String {
var result = "Fail"
fun A.ext() { result = "OK" }
val f = A::ext
f(A())
return result
}
@@ -1,14 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1282
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
fun box(): String {
fun foo(): String {
fun bar() = "OK"
val ref = ::bar
return ref()
}
val ref = ::foo
return ref()
}
@@ -1,11 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1283
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
fun foo(until: Int): String {
fun bar(x: Int): String =
if (x == until) "OK" else bar(x + 1)
return (::bar)(0)
}
fun box() = foo(10)
@@ -1,8 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1281
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
fun box(): String {
fun foo() = "OK"
return (::foo)()
}
@@ -1,11 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1281
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
fun box(): String {
val result = "OK"
fun foo() = result
return (::foo)()
}
@@ -1,8 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1281
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
fun box(): String {
fun foo(s: String) = s
return (::foo)("OK")
}
@@ -1,23 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1286
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
fun <T> run(arg1: T, arg2: T, funRef:(T,T) -> T): T {
return funRef(arg1, arg2)
}
fun tmp(o: Int, k: Int) = o + k
class A {
fun bar() = (::tmp)(111, 222)
}
fun box(): String {
val result = A().bar()
if (result != 333) return "Fail $result"
var r = run(111, 222, ::tmp)
if (result != 333) return "Fail $result"
return "OK"
}
@@ -1,23 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1285
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
fun <T> run(arg1: T, arg2: T, funRef:(T,T) -> T): T {
return funRef(arg1, arg2)
}
fun tmp(o: Int, k: Int) = o + k
class A
fun A.bar() = (::tmp)(111, 222)
fun box(): String {
val result = A().bar()
if (result != 333) return "Fail $result"
var r = run(111, 222, ::tmp)
if (result != 333) return "Fail $result"
return "OK"
}
@@ -1,21 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1282
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo
fun run(funRef:() -> String): String {
return funRef()
}
fun bar() = "OK"
fun box(): String {
val x = ::bar
var r = x()
if (r != "OK") return r
r = run(::bar)
if (r != "OK") return r
return "OK"
}
@@ -1,19 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1282
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo
var state = 23
fun box(): String {
fun incrementState(inc: Int) {
state += inc
}
val inc = ::incrementState
inc(12)
inc(-5)
inc(27)
inc(-15)
return if (state == 42) "OK" else "Fail $state"
}
@@ -1,13 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1293
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
abstract class Base {
val result = "OK"
}
class Derived : Base()
fun box(): String {
return (Base::result).get(Derived())
}
@@ -1,28 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1240
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
import kotlin.reflect.KProperty
object NumberDecrypter {
operator fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) {
"four" -> 4
"two" -> 2
else -> throw Exception()
}
}
val four: Int by NumberDecrypter
class A {
val two: Int by NumberDecrypter
}
fun box(): String {
val x = ::four.get()
if (x != 4) return "Fail x: $x"
val a = A()
val y = A::two.get(a)
if (y != 2) return "Fail y: $y"
return "OK"
}
@@ -1,28 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1298
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
import kotlin.reflect.KProperty
object Delegate {
var value = "lol"
operator fun getValue(instance: Any?, data: KProperty<*>): String {
return value
}
operator fun setValue(instance: Any?, data: KProperty<*>, newValue: String) {
value = newValue
}
}
var result: String by Delegate
fun box(): String {
val f = ::result
if (f.get() != "lol") return "Fail 1: {$f.get()}"
Delegate.value = "rofl"
if (f.get() != "rofl") return "Fail 2: {$f.get()}"
f.set("OK")
return f.get()
}
@@ -1,17 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1290
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
import kotlin.reflect.KProperty1
class A {
companion object {
val ref: KProperty1<A, String> = A::foo
}
val foo: String = "OK"
}
fun box(): String {
return A.ref.get(A())
}
@@ -1,13 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1295
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
open class Base {
open val foo = "Base"
}
class Derived : Base() {
override val foo = "OK"
}
fun box() = (Base::foo).get(Derived())
@@ -1,16 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1285
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
val String.id: String
get() = this
fun box(): String {
val pr = String::id
if (pr.get("123") != "123") return "Fail value: ${pr.get("123")}"
if (pr.name != "id") return "Fail name: ${pr.name}"
return pr.get("OK")
}
@@ -1,13 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1286
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
class A(val x: Int)
fun box(): String {
val p = A::x
if (p.get(A(42)) != 42) return "Fail 1"
if (p.get(A(-1)) != -1) return "Fail 2"
if (p.name != "x") return "Fail 3"
return "OK"
}
@@ -1,22 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1287
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
var storage = 0
var Int.foo: Int
get() {
return this + storage
}
set(value) {
storage = this + value
}
fun box(): String {
val pr = Int::foo
if (pr.get(42) != 42) return "Fail 1: ${pr.get(42)}"
pr.set(200, 39)
if (pr.get(-239) != 0) return "Fail 2: ${pr.get(-239)}"
if (storage != 239) return "Fail 3: $storage"
return "OK"
}
@@ -1,20 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1292
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
data class Box(var value: String)
fun box(): String {
val o = Box("lorem")
val prop = Box::value
if (prop.get(o) != "lorem") return "Fail 1: ${prop.get(o)}"
prop.set(o, "ipsum")
if (prop.get(o) != "ipsum") return "Fail 2: ${prop.get(o)}"
if (o.value != "ipsum") return "Fail 3: ${o.value}"
o.value = "dolor"
if (prop.get(o) != "dolor") return "Fail 4: ${prop.get(o)}"
if ("$o" != "Box(value=dolor)") return "Fail 5: $o"
return "OK"
}
@@ -1,16 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1293
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
data class Box(val value: String)
var pr = Box("first")
fun box(): String {
val property = ::pr
if (property.get() != Box("first")) return "Fail value: ${property.get()}"
if (property.name != "pr") return "Fail name: ${property.name}"
property.set(Box("second"))
if (property.get().value != "second") return "Fail value 2: ${property.get()}"
return "OK"
}
@@ -1,14 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1293
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
data class Box(val value: String)
val foo = Box("lol")
fun box(): String {
val property = ::foo
if (property.get() != Box("lol")) return "Fail value: ${property.get()}"
if (property.name != "foo") return "Fail name: ${property.name}"
return "OK"
}