1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
catch_destructuring_with_sequence: {
beautify = {
ecma: 2015
}
input: {
try {
throw {};
} catch ({xCover = (0, function() {})} ) {
}
}
expect_exact: "try{throw{}}catch({xCover=(0,function(){})}){}"
}
broken_safari_catch_scope: {
mangle = {
safari10: true,
}
input: {
"AAAAAAAA";
"BBBBBBB";
new class {
f(x) {
try {
throw {
m: "PASS"
};
} catch ({m: s}) {
console.log(s);
}
}
}().f();
}
expect: {
"AAAAAAAA";
"BBBBBBB";
new class {
f(A) {
try {
throw {
m: "PASS"
};
} catch ({m: B}) {
console.log(B);
}
}
}().f();
}
expect_stdout: "PASS"
}
broken_safari_catch_scope_caveat: {
// The `input` of this test reportedly fails on Safari 10+ despite
// being valid ECMAScript.
// The `expect`ed output of this test will also fail on Safari 10+
// despite of the `safari10` `mangle` option being enabled.
// This test just exists to prove that both forms will run correctly
// on ES spec compliant engines such as V8.
mangle = {
safari10: true,
}
input: {
"AAAAAAAA";
"BBBBBBB";
new class {
f(x) {
try {
throw {
m: "PASS"
};
} catch ({m: x}) {
console.log(x);
}
}
}().f();
}
expect: {
"AAAAAAAA";
"BBBBBBB";
new class {
f(A) {
try {
throw {
m: "PASS"
};
} catch ({m: A}) {
console.log(A);
}
}
}().f();
}
expect_stdout: "PASS"
}
parameterless_catch: {
input: {
try {
unknown();
} catch {
console.log("PASS");
}
}
expect_exact: 'try{unknown()}catch{console.log("PASS")}'
expect_stdout: "PASS"
}
parent_scope_of_catch_block_is_not_the_try_block: {
mangle = {}
input: {
function test(foo, bar) {
try {
const bar = {};
throw 'PASS'
} catch (error) {
return bar(error);
}
}
console.log(test(null, x => x));
}
expect_stdout: "PASS"
}
issue_452: {
options = {
toplevel: true,
unused: true
}
input: {
try {
const arr = ['PASS'];
for (const x of arr) { console.log(x) }
} catch(e) { }
}
expect_stdout: 'PASS'
}
|