Codegen tests for inner/nested classes
#KT-1174 In Progress
This commit is contained in:
@@ -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()
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jet.codegen.generated;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.codegen.generated.AbstractCodegenTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@TestMetadata("compiler/testData/codegen/innerNested")
|
||||
public class InnerNestedGenTestGenerated extends AbstractCodegenTest {
|
||||
public void testAllFilesPresentInInnerNested() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/innerNested"), "kt", true);
|
||||
}
|
||||
|
||||
@TestMetadata("createNestedClass.kt")
|
||||
public void testCreateNestedClass() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/createNestedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dataLocalVariable.kt")
|
||||
public void testDataLocalVariable() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/dataLocalVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFun.kt")
|
||||
public void testExtensionFun() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/extensionFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("importNestedClass.kt")
|
||||
public void testImportNestedClass() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/importNestedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerGeneric.kt")
|
||||
public void testInnerGeneric() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/innerGeneric.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerLabeledThis.kt")
|
||||
public void testInnerLabeledThis() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/innerLabeledThis.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerSimple.kt")
|
||||
public void testInnerSimple() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/innerSimple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClassObject.kt")
|
||||
public void testNestedClassObject() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/nestedClassObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedEnumConstant.kt")
|
||||
public void testNestedEnumConstant() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/nestedEnumConstant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedGeneric.kt")
|
||||
public void testNestedGeneric() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/nestedGeneric.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedInPackage.kt")
|
||||
public void testNestedInPackage() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/nestedInPackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedObjects.kt")
|
||||
public void testNestedObjects() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/nestedObjects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedSimple.kt")
|
||||
public void testNestedSimple() throws Exception {
|
||||
doTest("compiler/testData/codegen/innerNested/nestedSimple.kt");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -125,6 +125,13 @@ public class GenerateTests {
|
||||
testModel("compiler/testData/codegen/label")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"compiler/tests/",
|
||||
"InnerNestedGenTestGenerated",
|
||||
AbstractCodegenTest.class,
|
||||
testModel("compiler/testData/codegen/innerNested")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"compiler/tests/",
|
||||
"InstructionsTestGenerated",
|
||||
|
||||
Reference in New Issue
Block a user