You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a42343f
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: test/unitCases/syntax-printer.unittest.js
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -289,6 +289,11 @@ const IMPROVED_CASES = [
289
289
`(() => { let a = console.log.name; console.log(a, a); })(); (() => { ${TRY} console.log(2); })();`,
290
290
{compress: {passes: 2},mangle: true}
291
291
],
292
+
[
293
+
"a conditional whose other branch is its test, or ends as its other branch",
294
+
"function f(a, b, c) { var r = []; return [a ? b : a, a ? (r.push(1), c) : c, a ? (r.push(2), r.push(3), c) : c, r.join()]; } console.log(f(0, 1, 2), f(3, 4, 5));",
// of its function's own, or the call passes, keeps or constructs something.
677
682
/** @type {[string, string][]} */
678
683
constKEPT_CASES=[
684
+
["a conditional whose branches end in one chain made optional at different links","function f(flag, obj, t) { return flag ? (t(), obj?.b.c) : obj.b?.c; } console.log(f(1, { b: { c: 1 } }, () => 0), f(0, {}, () => 0));"],
685
+
["a conditional whose other branch reads a global getter again",'var n = 0; Object.defineProperty(globalThis, "g", { get: function () { return n++; }, configurable: true }); function f(b) { return g ? b : g; } console.log(f(1), f(2));'],
686
+
["a conditional whose other branch reads a getter twice or a different binding","var n = 0, o = { get x() { return ++n; } }; function f(b) { var a = 1; { let a = 0; var r = a ? b : o.x ? b : o.x; } return [r, a, n]; } console.log(f(2));"],
679
687
["a bigint and a number concatenated, which throws","try { console.log(1n + 2); } catch (e) { console.log(e.name); }"],
680
688
["an array literal joining to a string longer than it",'console.log([!0, !0, !0] + "");'],
681
689
["`+` and `~` of what a literal does not give","function f(a) { return [+[a], ~a !== 0 ? 1 : 2]; } console.log(f(1), f(1n));"],
0 commit comments