Codegen tests for inner/nested classes

#KT-1174 In Progress
This commit is contained in:
Alexander Udalov
2013-01-14 19:37:12 +04:00
parent cc5ba53c80
commit 85bd41dfa5
15 changed files with 263 additions and 0 deletions
@@ -0,0 +1,13 @@
class A {
class B1
class B2(val x: Int)
class B3(val x: Long, val y: Int)
class B4(val str: String)
}
fun box(): String {
A.B1()
val b2 = A.B2(A.B3(42, 42).y)
return A.B4("OK").str
}
@@ -0,0 +1,6 @@
fun ok(b: Boolean) = if (b) "OK" else "Fail"
fun box(): String {
val data = java.util.Arrays.asList("foo", "bar")!!
return ok(data.contains("foo"))
}
@@ -0,0 +1,31 @@
class Outer {
class Nested
inner class Inner
fun Inner.foo() {
Outer()
Nested()
Inner()
}
fun Nested.bar() {
Outer()
Nested()
Inner()
}
fun Outer.baz() {
Outer()
Nested()
Inner()
}
fun box(): String {
Inner().foo()
Nested().bar()
baz()
return "OK"
}
}
fun box() = Outer().box()
@@ -0,0 +1,18 @@
import A.B
import A.B.C
class A {
class B {
class C
}
}
fun box(): String {
val a = A()
val b = B()
val ab = A.B()
val c = C()
val bc = B.C()
val abc = A.B.C()
return "OK"
}
@@ -0,0 +1,11 @@
class Outer {
inner class Inner<T>(val t: T) {
fun box() = t
}
}
fun box(): String {
if (Outer().Inner("OK").box() != "OK") return "Fail"
val x: Outer.Inner<String> = Outer().Inner("OK")
return x.box()
}
@@ -0,0 +1,11 @@
class Outer {
inner class Inner {
fun O() = this@Outer.O
val K = this@Outer.K()
}
val O = "O"
fun K() = "K"
}
fun box() = Outer().Inner().O() + Outer().Inner().K
@@ -0,0 +1,7 @@
class Outer {
inner class Inner {
fun box() = "OK"
}
}
fun box() = Outer().Inner().box()
@@ -0,0 +1,12 @@
class Outer {
class Nested {
class object {
val O = "O"
val K = "K"
}
}
fun O() = Nested.O
}
fun box() = Outer().O() + Outer.Nested.K
@@ -0,0 +1,8 @@
class Outer {
enum class Nested {
O
K
}
}
fun box() = "${Outer.Nested.O}${Outer.Nested.K}"
@@ -0,0 +1,12 @@
class Outer {
class Nested<T>(val t: T) {
fun box() = t
}
}
fun box(): String {
if (Outer.Nested<String>("OK").box() != "OK") return "Fail"
val x: Outer.Nested<String> = Outer.Nested("OK")
return x.box()
}
@@ -0,0 +1,10 @@
package Package
class Outer {
class Nested {
val O = "O"
val K = "K"
}
}
fun box() = Package.Outer.Nested().O + Outer.Nested().K
@@ -0,0 +1,9 @@
object A {
object B {
object C {
val ok = "OK"
}
}
}
fun box() = A.B.C.ok
@@ -0,0 +1,7 @@
class Outer {
class Nested {
fun box() = "OK"
}
}
fun box() = Outer.Nested().box()