Add tests
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
fun box(): String {
|
||||
// kotlin.Nothing should not be loaded here
|
||||
return (if (null is Nothing?) "O" else "FAIL1") + (if (null !is Nothing) "K" else "FAIL2")
|
||||
}
|
||||
+5
@@ -23595,6 +23595,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullNothing.kt")
|
||||
public void testNullNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullNothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableNothing.kt")
|
||||
public void testNullableNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullableNothing.kt");
|
||||
|
||||
+5
@@ -23595,6 +23595,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullNothing.kt")
|
||||
public void testNullNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullNothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableNothing.kt")
|
||||
public void testNullableNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullableNothing.kt");
|
||||
|
||||
+5
@@ -23600,6 +23600,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullNothing.kt")
|
||||
public void testNullNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullNothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableNothing.kt")
|
||||
public void testNullableNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullableNothing.kt");
|
||||
|
||||
+5
@@ -2229,6 +2229,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/expression/evaluationOrder/singleComponentDestructuring.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("throwableDelegation.kt")
|
||||
public void testThrowableDelegation() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/evaluationOrder/throwableDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("whenAsMinusArgument.kt")
|
||||
public void testWhenAsMinusArgument() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/evaluationOrder/whenAsMinusArgument.kt");
|
||||
|
||||
+5
@@ -2229,6 +2229,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/expression/evaluationOrder/singleComponentDestructuring.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("throwableDelegation.kt")
|
||||
public void testThrowableDelegation() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/evaluationOrder/throwableDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("whenAsMinusArgument.kt")
|
||||
public void testWhenAsMinusArgument() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/evaluationOrder/whenAsMinusArgument.kt");
|
||||
|
||||
+5
@@ -20770,6 +20770,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullNothing.kt")
|
||||
public void testNullNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullNothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableNothing.kt")
|
||||
public void testNullableNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullableNothing.kt");
|
||||
|
||||
+5
@@ -21815,6 +21815,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullNothing.kt")
|
||||
public void testNullNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullNothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableNothing.kt")
|
||||
public void testNullableNothing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/typeMapping/nullableNothing.kt");
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// EXPECTED_REACHABLE_NODES: 1298
|
||||
package foo
|
||||
|
||||
fun check(e: Throwable, expectedString: String) {
|
||||
try {
|
||||
throw e
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
assertEquals(expectedString, e.toString())
|
||||
}
|
||||
}
|
||||
|
||||
var storage = ""
|
||||
|
||||
fun <T> sideEffect(v: String, m: T?): T? {
|
||||
storage += v
|
||||
return m
|
||||
}
|
||||
|
||||
class MyException1(i1: String, i2: String, m: String? = null, t: Throwable? = null): Throwable(sideEffect(i2, sideEffect(i1, m)), t)
|
||||
class MyException2(i1: String, i2: String, m: String? = null, t: Throwable? = null): Throwable(sideEffect(i1, m), sideEffect(i2, t))
|
||||
|
||||
|
||||
fun box(): String {
|
||||
check(MyException1("1", "2"), "MyException1: null")
|
||||
check(MyException1("3", "4", "aaa"), "MyException1: aaa")
|
||||
check(MyException1("5", "6", t = Throwable("bbb")), "MyException1: Throwable: bbb")
|
||||
check(MyException2("7", "8"), "MyException2: null")
|
||||
check(MyException2("9", "0", "ccc"), "MyException2: ccc")
|
||||
check(MyException2("A", "B", t = Throwable("ddd")), "MyException2: Throwable: ddd")
|
||||
|
||||
if (storage != "1234567890AB") return "FAIL $storage"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user