[K/N][Tests] Move codegen test sources cycles..innerClass
^KT-61259
This commit is contained in:
committed by
Space Team
parent
35d2be25b2
commit
71a834b778
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.innerClass.doubleInner
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
open class Father(val param: String) {
|
||||
abstract inner class InClass {
|
||||
fun work(): String {
|
||||
return param
|
||||
}
|
||||
}
|
||||
|
||||
inner class Child(p: String) : Father(p) {
|
||||
inner class Child2 : Father.InClass {
|
||||
constructor(): super()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Father("fail").Child("OK").Child2().work()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.innerClass.generic
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.innerClass.getOuterVal
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Outer(val s: String) {
|
||||
inner class Inner {
|
||||
fun box() = s
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Outer("OK").Inner().box()
|
||||
|
||||
@Test fun runTest()
|
||||
{
|
||||
println(box())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.innerClass.noPrimaryConstructor
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Outer(val s: String) {
|
||||
inner class Inner {
|
||||
constructor(x: Int) {
|
||||
this.x = x
|
||||
}
|
||||
|
||||
constructor(z: String) {
|
||||
x = z.length
|
||||
}
|
||||
|
||||
val x: Int
|
||||
|
||||
fun foo() = s
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Outer("OK").Inner(42).foo())
|
||||
println(Outer("OK").Inner("zzz").foo())
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
OK
|
||||
OK
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.innerClass.qualifiedThis
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
open class ABase
|
||||
{
|
||||
open fun zzz() = "a_base"
|
||||
}
|
||||
|
||||
open class BBase
|
||||
{
|
||||
open fun zzz() = "b_base"
|
||||
}
|
||||
|
||||
class D() {
|
||||
val z = "d"
|
||||
}
|
||||
|
||||
class A: ABase() { // implicit label @A
|
||||
val z = "a"
|
||||
override fun zzz() = "a"
|
||||
inner class B: BBase() { // implicit label @B
|
||||
val z = "b"
|
||||
override fun zzz() = "b"
|
||||
fun D.foo() : String { // implicit label @foo
|
||||
if(this@A.z != "a") return "Fail1"
|
||||
if(this@B.z != "b") return "Fail2"
|
||||
|
||||
if(super@A.zzz() != "a_base") return "Fail3"
|
||||
if(super<BBase>.zzz() != "b_base") return "Fail4"
|
||||
if(super@B.zzz() != "b_base") return "Fail5"
|
||||
if(this@A.zzz() != "a") return "Fail6"
|
||||
if(this@B.zzz() != "b") return "Fail7"
|
||||
|
||||
if(this.z != "d") return "Fail8"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun bar(d: D): String {
|
||||
return d.foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = A().B().bar(D())
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.innerClass.secondaryConstructor
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Outer(val x: Int) {
|
||||
inner class Inner() {
|
||||
inner class InnerInner() {
|
||||
|
||||
init {
|
||||
println(x)
|
||||
}
|
||||
|
||||
lateinit var s: String
|
||||
|
||||
constructor(s: String) : this() {
|
||||
this.s = s
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
Outer(42).Inner().InnerInner("zzz")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
42
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.innerClass.simple
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Outer {
|
||||
inner class Inner {
|
||||
fun box() = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Outer().Inner().box()
|
||||
|
||||
@Test fun runTest()
|
||||
{
|
||||
println(box())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.innerClass.superOuter
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
open class Outer(val outer: String) {
|
||||
open inner class Inner(val inner: String): Outer(inner) {
|
||||
fun foo() = outer
|
||||
}
|
||||
|
||||
fun value() = Inner("OK").foo()
|
||||
}
|
||||
|
||||
fun box() = Outer("Fail").value()
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
Reference in New Issue
Block a user