Add tests for secondary constructors

This commit is contained in:
Roman Artemev
2018-04-02 14:46:31 +03:00
parent 42d9c5b932
commit 3ce324fa9d
8 changed files with 284 additions and 133 deletions
@@ -15,5 +15,22 @@ val JS_IR_BACKEND_TEST_WHITELIST = listOf(
"js/js.translator/testData/box/expression/identifierClash/useVariableOfNameOfFunction.kt",
"js/js.translator/testData/box/expression/stringClass/stringConstant.kt",
"js/js.translator/testData/box/expression/when/empty.kt",
"js/js.translator/testData/box/simple/notBoolean.kt"
"js/js.translator/testData/box/simple/notBoolean.kt",
"js/js.translator/testData/box/simple/primCtorDelegation1.kt",
"js/js.translator/testData/box/simple/secCtorDelegation1.kt",
"js/js.translator/testData/box/simple/secCtorDelegation2.kt",
"js/js.translator/testData/box/simple/secCtorDelegation3.kt",
"js/js.translator/testData/box/simple/secCtorDelegation4.kt",
"js/js.translator/testData/box/operatorOverloading/notOverload.kt",
"js/js.translator/testData/box/operatorOverloading/binaryDivOverload.kt",
"js/js.translator/testData/box/package/initializersOfNestedPackagesExecute.kt",
"js/js.translator/testData/box/package/classCreatedInDeeplyNestedPackage.kt",
"js/js.translator/testData/box/extensionProperty/inClass.kt",
"js/js.translator/testData/box/multiPackage/createClassFromOtherPackage.kt",
"js/js.translator/testData/box/multiPackage/createClassFromOtherPackageUsingImport.kt",
"js/js.translator/testData/box/simple/methodDeclarationAndCall.kt",
"js/js.translator/testData/box/simple/propertyAccess.kt",
"js/js.translator/testData/box/simple/classInstantiation.kt",
"js/js.translator/testData/box/expression/invoke/internalFunctionFromSuperclass.kt",
"js/js.translator/testData/box/inheritance/withInitializeMethod.kt"
).map { File(it) }
@@ -8095,6 +8095,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
doTest(fileName);
}
@TestMetadata("primCtorDelegation1.kt")
public void testPrimCtorDelegation1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/primCtorDelegation1.kt");
doTest(fileName);
}
@TestMetadata("propertiesAsParametersInitialized.kt")
public void testPropertiesAsParametersInitialized() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/propertiesAsParametersInitialized.kt");
@@ -8107,6 +8113,30 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
doTest(fileName);
}
@TestMetadata("secCtorDelegation1.kt")
public void testSecCtorDelegation1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/secCtorDelegation1.kt");
doTest(fileName);
}
@TestMetadata("secCtorDelegation2.kt")
public void testSecCtorDelegation2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/secCtorDelegation2.kt");
doTest(fileName);
}
@TestMetadata("secCtorDelegation3.kt")
public void testSecCtorDelegation3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/secCtorDelegation3.kt");
doTest(fileName);
}
@TestMetadata("secCtorDelegation4.kt")
public void testSecCtorDelegation4() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/secCtorDelegation4.kt");
doTest(fileName);
}
@TestMetadata("simpleInitializer.kt")
public void testSimpleInitializer() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/simpleInitializer.kt");
@@ -7586,18 +7586,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("internalFunctionFromSuperclass.kt")
public void testInternalFunctionFromSuperclass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/expression/invoke/internalFunctionFromSuperclass.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("invokeInExtensionFunctionLiteral.kt")
@@ -9847,18 +9836,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("inClass.kt")
public void testInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/extensionProperty/inClass.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("privateExtensionProperty.kt")
@@ -10511,18 +10489,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("withInitializeMethod.kt")
public void testWithInitializeMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inheritance/withInitializeMethod.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("js/js.translator/testData/box/inheritance/interfaces")
@@ -16533,35 +16500,13 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("createClassFromOtherPackage.kt")
public void testCreateClassFromOtherPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/multiPackage/createClassFromOtherPackage.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("createClassFromOtherPackageUsingImport.kt")
public void testCreateClassFromOtherPackageUsingImport() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/multiPackage/createClassFromOtherPackageUsingImport.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("functionsVisibleFromOtherPackage.kt")
@@ -18744,18 +18689,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("binaryDivOverload.kt")
public void testBinaryDivOverload() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/operatorOverloading/binaryDivOverload.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("compareTo.kt")
@@ -18812,18 +18746,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("notOverload.kt")
public void testNotOverload() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/operatorOverloading/notOverload.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt")
@@ -19127,18 +19050,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("classCreatedInDeeplyNestedPackage.kt")
public void testClassCreatedInDeeplyNestedPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/package/classCreatedInDeeplyNestedPackage.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("deeplyNestedPackage.kt")
@@ -19156,18 +19068,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("initializersOfNestedPackagesExecute.kt")
public void testInitializersOfNestedPackagesExecute() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/package/initializersOfNestedPackagesExecute.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("nestedPackage.kt")
@@ -21096,18 +20997,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("classInstantiation.kt")
public void testClassInstantiation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/classInstantiation.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("comparison.kt")
@@ -21300,18 +21190,7 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("methodDeclarationAndCall.kt")
public void testMethodDeclarationAndCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/methodDeclarationAndCall.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
doTest(fileName);
}
@TestMetadata("minusAssignOnProperty.kt")
@@ -21405,6 +21284,23 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
}
@TestMetadata("primCtorDelegation1.kt")
public void testPrimCtorDelegation1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/primCtorDelegation1.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
}
@TestMetadata("propertiesAsParametersInitialized.kt")
public void testPropertiesAsParametersInitialized() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/propertiesAsParametersInitialized.kt");
@@ -21425,6 +21321,63 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
@TestMetadata("propertyAccess.kt")
public void testPropertyAccess() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/propertyAccess.kt");
doTest(fileName);
}
@TestMetadata("secCtorDelegation1.kt")
public void testSecCtorDelegation1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/secCtorDelegation1.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
}
@TestMetadata("secCtorDelegation2.kt")
public void testSecCtorDelegation2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/secCtorDelegation2.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
}
@TestMetadata("secCtorDelegation3.kt")
public void testSecCtorDelegation3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/secCtorDelegation3.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
}
try {
doTest(fileName);
}
catch (Throwable ignore) {
ignore.printStackTrace();
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.");
}
@TestMetadata("secCtorDelegation4.kt")
public void testSecCtorDelegation4() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/simple/secCtorDelegation4.kt");
if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {
doTest(fileName);
return;
@@ -0,0 +1,19 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
open class Base(val bb: String) {
open fun foo() = bb
}
class Test(val tt: String) : Base("fail") {
override fun foo() = tt
}
fun box(): String {
val t = Test("OK")
return t.foo()
}
@@ -0,0 +1,35 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
open class Base {
val i: Int
val i2: Int
val i3: Int
val bs: String
constructor(ii1: Int, ii2: Int) {
i = ii1
i2 = ii2
i3 = 30
}
constructor(ii: Int): this(ii, 25) {
}
open fun foo() = bs
init {
bs = "fail"
}
}
class Test(val tt: String) : Base(18) {
override fun foo() = tt
}
fun box(): String {
val t = Test("OK")
return t.foo()
}
@@ -0,0 +1,36 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
open class Base(val bs: String) {
val i: Int
val i2: Int
val i3: Int
fun foo() = bs
init {
i = 10
i2 = 20
i3 = 30
}
}
class Test : Base {
val t1: Int
val t2: Int
constructor(tt1: Int, tt2: Int): super("OK") {
t1 = tt1
t2 = tt2
}
}
fun box(): String {
val t = Test(1, 2)
return t.foo()
}
@@ -0,0 +1,35 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
open class Base {
val i: Int
val i2: Int
val i3: Int
val bs: String
constructor(s:String) {bs = s}
fun foo() = bs
init {
i = 10
i2 = 20
i3 = 30
}
}
class Test: Base {
val t1: Int
val t2: Int
constructor(tt1: Int, tt2:Int) : super("OK") {
t1 = tt1
t2 = tt2
}
}
fun box(): String {
val t = Test(1, 2)
return t.foo()
}
@@ -0,0 +1,26 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
class Test(val bs: String) {
var i: Int = 0
var i2: Int = 0
var i3: Int =0
constructor(ii1: Int, ii2: Int): this("OK") {
i = ii1
i2 = ii2
i3 = 30
}
constructor(ii: Int): this(ii, 18) {
}
fun foo() = bs
}
fun box(): String {
val t = Test(1)
return t.foo()
}