[JS BE] Merge Legacy and IR BE exceptions-related test data

- regenerate tests
 - add consistency test
This commit is contained in:
Roman Artemev
2020-10-06 16:24:13 +03:00
parent c16b11a124
commit f824bb6987
5 changed files with 72 additions and 2 deletions
@@ -7676,6 +7676,11 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
runTest("js/js.translator/testData/box/standardClasses/stringPlus.kt");
}
@TestMetadata("throwableConsistancy.kt")
public void testThrowableConsistancy() throws Exception {
runTest("js/js.translator/testData/box/standardClasses/throwableConsistancy.kt");
}
@TestMetadata("throwableCtor.kt")
public void testThrowableCtor() throws Exception {
runTest("js/js.translator/testData/box/standardClasses/throwableCtor.kt");
@@ -7676,6 +7676,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
runTest("js/js.translator/testData/box/standardClasses/stringPlus.kt");
}
@TestMetadata("throwableConsistancy.kt")
public void testThrowableConsistancy() throws Exception {
runTest("js/js.translator/testData/box/standardClasses/throwableConsistancy.kt");
}
@TestMetadata("throwableCtor.kt")
public void testThrowableCtor() throws Exception {
runTest("js/js.translator/testData/box/standardClasses/throwableCtor.kt");
@@ -7706,6 +7706,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
runTest("js/js.translator/testData/box/standardClasses/stringPlus.kt");
}
@TestMetadata("throwableConsistancy.kt")
public void testThrowableConsistancy() throws Exception {
runTest("js/js.translator/testData/box/standardClasses/throwableConsistancy.kt");
}
@TestMetadata("throwableCtor.kt")
public void testThrowableCtor() throws Exception {
runTest("js/js.translator/testData/box/standardClasses/throwableCtor.kt");
@@ -25,10 +25,10 @@ class MyException2(i1: String, i2: String, m: String? = null, t: Throwable? = nu
fun box(): String {
check(MyException1("1", "2"), "MyException1")
check(MyException1("3", "4", "aaa"), "MyException1: aaa")
check(MyException1("5", "6", t = Throwable("bbb")), "MyException1: Throwable: bbb")
check(MyException1("5", "6", t = Throwable("bbb")), "MyException1")
check(MyException2("7", "8"), "MyException2")
check(MyException2("9", "0", "ccc"), "MyException2: ccc")
check(MyException2("A", "B", t = Throwable("ddd")), "MyException2: Throwable: ddd")
check(MyException2("A", "B", t = Throwable("ddd")), "MyException2")
if (storage != "1234567890AB") return "FAIL $storage"
@@ -0,0 +1,55 @@
// IGNORE_BACKEND: JS
fun test(case: String, expctedMessage: String?, expectedCause: Throwable?, expectedToString: String, t: Throwable): String {
val actualMessage = t.message
if (actualMessage != expctedMessage) return "$case FAIL message: $actualMessage, expcted: $expctedMessage"
val actualCause = t.cause
if (actualCause != expectedCause) return "$case FAIL cause: $actualCause, expcted: $expectedCause"
val actualToString = t.toString()
if (actualToString != expectedToString) return "$case FAIL toString: $actualToString, expcted: $expectedToString"
return "OK"
}
fun box(): String {
var result: String = "FAIL"
result = test("Throwable()", null, null, "Throwable", Throwable())
if (result != "OK") return result
result = test("Throwable(\"aaaa\")", "aaaa", null, "Throwable: aaaa", Throwable("aaaa"))
if (result != "OK") return result
var cause = Throwable()
result = test("Throwable(Throwable())", "Throwable", cause, "Throwable: Throwable", Throwable(cause))
if (result != "OK") return result
cause = Throwable("ccc")
result = test("Throwable(\"bbbb\", Throwable(\"ccc\"))", "bbbb", cause, "Throwable: bbbb", Throwable("bbbb", cause))
if (result != "OK") return result
result = test("Throwable(message = null)", null, null, "Throwable", Throwable(message = null))
if (result != "OK") return result
result = test("Throwable(cause = null)", null, null, "Throwable", Throwable(cause = null))
if (result != "OK") return result
result = test("Throwable(null, null)", null, null, "Throwable", Throwable(null, null))
if (result != "OK") return result
result = test("Throwable(\"eee\", null)", "eee", null, "Throwable: eee", Throwable("eee", null))
if (result != "OK") return result
cause = Throwable("ddd")
result = test("Throwable(null, Throwable(\"ddd\"))", null, cause, "Throwable", Throwable(null, cause))
if (result != "OK") return result
return "OK"
}