JS: Add test case for flow through new Error()

This commit is contained in:
Asger F
2019-05-02 14:29:55 +01:00
parent 36cefd8fc6
commit b0090c2fe6

View File

@@ -1,33 +1,67 @@
function test(unsafe, safe) {
try {
throw2(source());
throwRaw2(source());
} catch (e) {
sink(e);
sink(e); // NOT OK
}
try {
throw2(unsafe);
throwRaw2(unsafe);
} catch (e) {
sink(e);
sink(e); // NOT OK
}
try {
throw2(safe);
throwRaw2(safe);
} catch (e) {
sink(e); // OK
}
try {
throwError2(source());
} catch (e) {
sink(e); // NOT OK
sink(e.toString()); // NOT OK
sink(e.message); // NOT OK
sink(e.fileName); // OK
}
try {
throwError2(unsafe);
} catch (e) {
sink(e); // NOT OK
sink(e.toString()); // NOT OK
sink(e.message); // NOT OK
sink(e.fileName); // OK
}
try {
throwError2(safe);
} catch (e) {
sink(e); // NOT OK
sink(e.toString()); // NOT OK
sink(e.message); // NOT OK
sink(e.fileName); // OK
}
}
function throw2(x) {
throw1(x);
throw1(x); // no single-call inlining
function throwRaw2(x) {
throwRaw1(x);
throwRaw1(x); // no single-call inlining
}
function throw1(x) {
function throwRaw1(x) {
throw x;
}
function throwError2(x) {
throwError1(x);
throwError1(x); // no single-call inlining
}
function throwError1(x) {
throw new Error(x);
}
test(source(), "hello");
test("hey", "hello"); // no single-call inlining