[Tests] Migrate backend-independent tests from native to compiler/testData.
^KT-65979
This commit is contained in:
committed by
Space Team
parent
dd9332d9e1
commit
febac0dd5f
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// WITH_STDLIB
|
||||
|
||||
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()
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// WITH_STDLIB
|
||||
|
||||
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()
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Outer(val s: String) {
|
||||
inner class Inner {
|
||||
fun box() = s
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Outer("OK").Inner().box()
|
||||
@@ -0,0 +1,26 @@
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
open class Foo(val z: Int) {
|
||||
open inner class FooInner {
|
||||
fun foo() = z
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Bar : Foo(42) {
|
||||
inner class BarInner(val x: Int) : FooInner()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val o = Bar().BarInner(117)
|
||||
assertEquals(117, o.x)
|
||||
assertEquals(42, o.foo())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
open class Outer(val x: String) {
|
||||
open inner class Inner1
|
||||
inner class Middle(x: String) : Outer(x) {
|
||||
inner class Inner2 : Inner1() {
|
||||
fun foo() = this@Outer.x + this@Middle.x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = Outer("O").Middle("K").Inner2().foo()
|
||||
@@ -0,0 +1,26 @@
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
open class Outer {
|
||||
open inner class Inner1
|
||||
inner class Middle {
|
||||
inner class Inner2 : Inner1() {
|
||||
fun getOuter() = this@Outer
|
||||
fun getMiddle() = this@Middle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val o = Outer().Middle().Inner2()
|
||||
assertNotSame(o.getOuter(), Outer())
|
||||
assertNotSame(o.getMiddle(), Outer().Middle())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
open class A {
|
||||
open inner class Inner {
|
||||
val x = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
open class B : A() {
|
||||
open inner class Inner : A.Inner()
|
||||
}
|
||||
|
||||
fun box() = B().Inner().x
|
||||
@@ -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.
|
||||
*/
|
||||
// WITH_STDLIB
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("OK", Outer("OK").Inner(42).foo())
|
||||
return Outer("OK").Inner("zzz").foo()
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// WITH_STDLIB
|
||||
|
||||
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())
|
||||
@@ -0,0 +1,9 @@
|
||||
MODULE main
|
||||
CLASS SecondaryConstructorKt.class
|
||||
PACKAGE METADATA
|
||||
PROPERTY getSb()Ljava/lang/StringBuilder;
|
||||
Property: class.metadata.property.returnType
|
||||
K1
|
||||
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
|
||||
K2
|
||||
java/lang/StringBuilder
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// JVM_ABI_K1_K2_DIFF: KT-63864
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
class Outer(val x: Int) {
|
||||
inner class Inner() {
|
||||
inner class InnerInner() {
|
||||
|
||||
init {
|
||||
sb.appendLine(x)
|
||||
}
|
||||
|
||||
lateinit var s: String
|
||||
|
||||
constructor(s: String) : this() {
|
||||
this.s = s
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Outer(42).Inner().InnerInner("zzz")
|
||||
|
||||
assertEquals("42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Outer {
|
||||
inner class Inner {
|
||||
fun box() = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Outer().Inner().box()
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// WITH_STDLIB
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user