Move some tests from boxWithStdlib/ to box/

Move those tests which do not require neither stdlib nor reflect
This commit is contained in:
Alexander Udalov
2016-03-05 18:39:20 +03:00
committed by Alexander Udalov
parent 54a615fcd3
commit 20e36438e2
217 changed files with 1561 additions and 1397 deletions
@@ -0,0 +1,12 @@
class Outer {
val result = "OK"
inner class Inner {
fun foo() = result
}
}
fun box(): String {
val f = Outer.Inner::foo
return f(Outer().Inner())
}
@@ -0,0 +1,8 @@
fun box(): String {
class Local {
fun foo() = "OK"
}
val ref = Local::foo
return ref(Local())
}
@@ -0,0 +1,9 @@
fun box(): String {
var result = "Fail"
fun changeToOK() { result = "OK" }
val ok = ::changeToOK
ok()
return result
}
@@ -0,0 +1,7 @@
fun box(): String {
class A {
val result = "OK"
}
return (::A)().result
}
@@ -0,0 +1,10 @@
fun box(): String {
class A {
var result: String = "Fail";
init {
result = "OK"
}
}
return (::A)().result
}
@@ -0,0 +1,11 @@
interface Named {
val name: String
}
enum class E : Named {
OK
}
fun box(): String {
return E.OK.name
}
@@ -0,0 +1,6 @@
class A
fun box(): String {
fun A.foo() = "OK"
return (A::foo)(A())
}
@@ -0,0 +1,5 @@
fun box(): String {
class A
fun A.foo() = "OK"
return (A::foo)((::A)())
}
@@ -0,0 +1,4 @@
fun box(): String {
fun Int.is42With(that: Int) = this + 2 * that == 42
return if ((Int::is42With)(16, 13)) "OK" else "Fail"
}
@@ -0,0 +1,11 @@
class A
fun box(): String {
var result = "Fail"
fun A.ext() { result = "OK" }
val f = A::ext
f(A())
return result
}
@@ -0,0 +1,8 @@
fun box(): String {
class Id<T> {
fun invoke(t: T) = t
}
val ref = Id<String>::invoke
return ref(Id<String>(), "OK")
}
@@ -0,0 +1,11 @@
fun box(): String {
val result = "OK"
class Local {
fun foo() = result
}
val member = Local::foo
val instance = Local()
return member(instance)
}
@@ -0,0 +1,10 @@
fun box(): String {
fun foo(): String {
fun bar() = "OK"
val ref = ::bar
return ref()
}
val ref = ::foo
return ref()
}
@@ -0,0 +1,7 @@
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)
@@ -0,0 +1,4 @@
fun box(): String {
fun foo() = "OK"
return (::foo)()
}
@@ -0,0 +1,7 @@
fun box(): String {
val result = "OK"
fun foo() = result
return (::foo)()
}
@@ -0,0 +1,4 @@
fun box(): String {
fun foo(s: String) = s
return (::foo)("OK")
}
@@ -0,0 +1,15 @@
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"
}