Move some tests from boxWithStdlib/ to box/
Move those tests which do not require neither stdlib nor reflect
This commit is contained in:
committed by
Alexander Udalov
parent
54a615fcd3
commit
20e36438e2
-9
@@ -1,9 +0,0 @@
|
||||
abstract class A {
|
||||
abstract fun foo(): String
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = (A::foo)(B())
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
fun box(): String {
|
||||
if ((Boolean::not)(true) != false) return "Fail 1"
|
||||
if ((Boolean::not)(false) != true) return "Fail 2"
|
||||
return "OK"
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
class A {
|
||||
fun foo(k: Int) = k
|
||||
|
||||
fun result() = (A::foo)(this, 111)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = A().result()
|
||||
if (result != 111) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
class A {
|
||||
fun o() = 111
|
||||
fun k(k: Int) = k
|
||||
}
|
||||
|
||||
fun A.foo() = (A::o)(this) + (A::k)(this, 222)
|
||||
|
||||
fun box(): String {
|
||||
val result = A().foo()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
class A {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return x(A())
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
class A {
|
||||
fun foo(result: String) = result
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return x(A(), "OK")
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
class A {
|
||||
var result = "Fail"
|
||||
|
||||
fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
x(a)
|
||||
return a.result
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
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
|
||||
}
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
class A {
|
||||
var result = "OK"
|
||||
}
|
||||
|
||||
fun box() = (::A)().result
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
class A(val result: String)
|
||||
|
||||
fun box() = (::A)("OK").result
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
enum class E {
|
||||
ENTRY
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val f = E::valueOf
|
||||
val result = f("ENTRY")
|
||||
return if (result == E.ENTRY) "OK" else "Fail $result"
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
class A
|
||||
|
||||
fun box() = if ((A::equals)(A(), A())) "Fail" else "OK"
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
class A {
|
||||
fun result() = (A::foo)(this, "OK")
|
||||
}
|
||||
|
||||
fun A.foo(x: String) = x
|
||||
|
||||
fun box() = A().result()
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
class A
|
||||
|
||||
fun A.foo() = (A::bar)(this, "OK")
|
||||
|
||||
fun A.bar(x: String) = x
|
||||
|
||||
fun box() = A().foo()
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
class A
|
||||
|
||||
fun A.foo() = "OK"
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return x(A())
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
class A
|
||||
|
||||
fun A.foo(result: String) = result
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return x(A(), "OK")
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
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
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
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")
|
||||
return a.result
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
class A<T>(val t: T) {
|
||||
fun foo(): T = t
|
||||
}
|
||||
|
||||
fun box() = (A<String>::foo)(A("OK"))
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
class A {
|
||||
inner class Inner {
|
||||
val o = 111
|
||||
val k = 222
|
||||
}
|
||||
|
||||
fun result() = (A::Inner)(this).o + (A::Inner)(this).k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = A().result()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
class A {
|
||||
inner class Inner {
|
||||
val o = 111
|
||||
val k = 222
|
||||
}
|
||||
}
|
||||
|
||||
fun A.foo() = (A::Inner)(this).o + (A::Inner)(this).k
|
||||
|
||||
fun box(): String {
|
||||
val result = A().foo()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
class A {
|
||||
inner class Inner {
|
||||
val o = 111
|
||||
val k = 222
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = (A::Inner)((::A)()).o + (A::Inner)(A()).k
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class A {
|
||||
inner class Inner(val result: Int)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = (A::Inner)((::A)(), 111).result + (A::Inner)(A(), 222).result
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
// KT-5123
|
||||
|
||||
import java.util.Collections
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box(): String {
|
||||
val numbers = ArrayList<Int>()
|
||||
numbers.add(1)
|
||||
numbers.add(2)
|
||||
numbers.add(3)
|
||||
(Collections::rotate)(numbers, 1)
|
||||
return if ("$numbers" == "[3, 1, 2]") "OK" else "Fail $numbers"
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
class Outer {
|
||||
val result = "OK"
|
||||
|
||||
inner class Inner {
|
||||
fun foo() = result
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val f = Outer.Inner::foo
|
||||
return f(Outer().Inner())
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
fun box(): String {
|
||||
class Local {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
val ref = Local::foo
|
||||
return ref(Local())
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
fun box(): String {
|
||||
var result = "Fail"
|
||||
|
||||
fun changeToOK() { result = "OK" }
|
||||
|
||||
val ok = ::changeToOK
|
||||
ok()
|
||||
return result
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun box(): String {
|
||||
class A {
|
||||
val result = "OK"
|
||||
}
|
||||
|
||||
return (::A)().result
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
fun box(): String {
|
||||
class A {
|
||||
var result: String = "Fail";
|
||||
init {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
return (::A)().result
|
||||
}
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
interface Named {
|
||||
val name: String
|
||||
}
|
||||
|
||||
enum class E : Named {
|
||||
OK
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return E.OK.name
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
class A
|
||||
|
||||
fun box(): String {
|
||||
fun A.foo() = "OK"
|
||||
return (A::foo)(A())
|
||||
}
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
fun box(): String {
|
||||
class A
|
||||
fun A.foo() = "OK"
|
||||
return (A::foo)((::A)())
|
||||
}
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
fun box(): String {
|
||||
fun Int.is42With(that: Int) = this + 2 * that == 42
|
||||
return if ((Int::is42With)(16, 13)) "OK" else "Fail"
|
||||
}
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
class A
|
||||
|
||||
fun box(): String {
|
||||
var result = "Fail"
|
||||
|
||||
fun A.ext() { result = "OK" }
|
||||
|
||||
val f = A::ext
|
||||
f(A())
|
||||
return result
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
fun box(): String {
|
||||
class Id<T> {
|
||||
fun invoke(t: T) = t
|
||||
}
|
||||
|
||||
val ref = Id<String>::invoke
|
||||
return ref(Id<String>(), "OK")
|
||||
}
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
fun box(): String {
|
||||
val result = "OK"
|
||||
|
||||
class Local {
|
||||
fun foo() = result
|
||||
}
|
||||
|
||||
val member = Local::foo
|
||||
val instance = Local()
|
||||
return member(instance)
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
fun box(): String {
|
||||
fun foo(): String {
|
||||
fun bar() = "OK"
|
||||
val ref = ::bar
|
||||
return ref()
|
||||
}
|
||||
|
||||
val ref = ::foo
|
||||
return ref()
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
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)
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
fun box(): String {
|
||||
fun foo() = "OK"
|
||||
return (::foo)()
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun box(): String {
|
||||
val result = "OK"
|
||||
|
||||
fun foo() = result
|
||||
|
||||
return (::foo)()
|
||||
}
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
fun box(): String {
|
||||
fun foo(s: String) = s
|
||||
return (::foo)("OK")
|
||||
}
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
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"
|
||||
}
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
class A {
|
||||
class Nested {
|
||||
val o = 111
|
||||
val k = 222
|
||||
}
|
||||
|
||||
fun result() = (::Nested)().o + (A::Nested)().k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = A().result()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
class A {
|
||||
class Nested {
|
||||
val result = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = (A::Nested)().result
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
class A {
|
||||
class Nested(val result: String)
|
||||
}
|
||||
|
||||
fun box() = (A::Nested)("OK").result
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
private fun <T> upcast(value: T): T = value
|
||||
|
||||
fun box(): String {
|
||||
upcast<(Int)->ByteArray>(::ByteArray)(10)
|
||||
upcast<(Int)->IntArray>(::IntArray)(10)
|
||||
upcast<(Int)->ShortArray>(::ShortArray)(10)
|
||||
upcast<(Int)->LongArray>(::LongArray)(10)
|
||||
upcast<(Int)->DoubleArray>(::DoubleArray)(10)
|
||||
upcast<(Int)->FloatArray>(::FloatArray)(10)
|
||||
upcast<(Int)->BooleanArray>(::BooleanArray)(10)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun foo(): String = "foo1"
|
||||
fun foo(i: Int): String = "foo2"
|
||||
|
||||
val f1: () -> String = ::foo
|
||||
val f2: (Int) -> String = ::foo
|
||||
|
||||
fun foo1() {}
|
||||
fun foo2(i: Int) {}
|
||||
|
||||
fun bar(f: () -> Unit): String = "bar1"
|
||||
fun bar(f: (Int) -> Unit): String = "bar2"
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("foo1", f1())
|
||||
assertEquals("foo2", f2(0))
|
||||
assertEquals("bar1", bar(::foo1))
|
||||
assertEquals("bar2", bar(::foo2))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class A {
|
||||
val x = 1
|
||||
fun x(): String = "OK"
|
||||
}
|
||||
|
||||
val f1: KProperty1<A, Int> = A::x
|
||||
val f2: (A) -> String = A::x
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
|
||||
assertEquals(1, f1.get(a))
|
||||
assertEquals("OK", f2(a))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
class A {
|
||||
private fun foo() = "OK"
|
||||
|
||||
fun bar() = (A::foo)(this)
|
||||
}
|
||||
|
||||
fun box() = A().bar()
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
import java.util.ArrayList
|
||||
import java.util.Arrays
|
||||
import java.util.Collections
|
||||
import java.util.Comparator
|
||||
|
||||
fun sort(list: MutableList<String>, comparator: (String, String) -> Int) {
|
||||
Collections.sort(list, object : Comparator<String> {
|
||||
override fun compare(p0: String, p1: String) = comparator(p0, p1)
|
||||
})
|
||||
}
|
||||
|
||||
fun compare(s1: String, s2: String) = s1.compareTo(s2)
|
||||
|
||||
fun box(): String {
|
||||
val l = ArrayList(Arrays.asList("d", "b", "c", "e", "a"))
|
||||
sort(l, ::compare)
|
||||
if (l != Arrays.asList("a", "b", "c", "d", "e")) return "Fail: $l"
|
||||
return "OK"
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fun foo(o: Int, k: Int) = o + k
|
||||
|
||||
class A {
|
||||
fun bar() = (::foo)(111, 222)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = A().bar()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
fun foo(o: Int, k: Int) = o + k
|
||||
|
||||
class A
|
||||
|
||||
fun A.bar() = (::foo)(111, 222)
|
||||
|
||||
fun box(): String {
|
||||
val result = A().bar()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
fun foo() = "OK"
|
||||
|
||||
fun box(): String {
|
||||
val x = ::foo
|
||||
return x()
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
fun foo(x: String) = x
|
||||
|
||||
fun box(): String {
|
||||
val x = ::foo
|
||||
return x("OK")
|
||||
}
|
||||
compiler/testData/codegen/boxWithStdlib/callableReference/function/topLevelFromTopLevelUnitNoArgs.kt
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
var result = "Fail"
|
||||
|
||||
fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = ::foo
|
||||
x()
|
||||
return result
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
var result = "Fail"
|
||||
|
||||
fun foo(newResult: String) {
|
||||
result = newResult
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = ::foo
|
||||
x("OK")
|
||||
return result
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
interface T {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
class B : T {
|
||||
inner class C {
|
||||
fun bar() = (T::foo)(this@B)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = B().C().bar()
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
interface A {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
class B : A {
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box() = (A::foo)(B())
|
||||
Reference in New Issue
Block a user