diff --git a/crates/oxc_minifier/tests/ast_passes/esbuild.rs b/crates/oxc_minifier/tests/ast_passes/esbuild.rs index 9374ac6b8..a97dea6bf 100644 --- a/crates/oxc_minifier/tests/ast_passes/esbuild.rs +++ b/crates/oxc_minifier/tests/ast_passes/esbuild.rs @@ -8,22 +8,22 @@ use super::test; /// var messagesFile *os.File /// /// func messages() *os.File { -/// if messagesFile == nil { -/// messagesFile, _ = os.Create("tests.out") -/// } -/// return messagesFile +/// if messagesFile == nil { +/// messagesFile, _ = os.Create("tests.out") +/// } +/// return messagesFile /// } /// /// func expectPrintedMangle(t *testing.T, contents string, expected string) { -/// contents = strings.ReplaceAll(contents, "\n", "") -/// contents = strings.ReplaceAll(contents, "\"", "'") -/// expected = strings.ReplaceAll(expected, "\n", "") -/// expected = strings.ReplaceAll(expected, "\"", "'") -/// messages().WriteString("test(\"" + contents + "\", \"" + expected + "\");\n"); -/// t.Helper() -/// expectPrintedCommon(t, contents, expected, config.Options{ -/// MinifySyntax: true, -/// }) +/// contents = strings.ReplaceAll(contents, "\n", "") +/// contents = strings.ReplaceAll(contents, "\"", "'") +/// expected = strings.ReplaceAll(expected, "\n", "") +/// expected = strings.ReplaceAll(expected, "\"", "'") +/// messages().WriteString("test(\"" + contents + "\", \"" + expected + "\");\n"); +/// t.Helper() +/// expectPrintedCommon(t, contents, expected, config.Options{ +/// MinifySyntax: true, +/// }) /// } /// ``` #[test] @@ -44,201 +44,201 @@ fn js_parser_test() { test("x = { '-2147483648': y }", "x = { '-2147483648': y };"); test("x = { '-2147483649': y }", "x = { '-2147483649': y };"); test("x.x; y['y']", "x.x, y.y;"); - test("({y: y, 'z': z} = x)", "({ y, z } = x);"); - test("var {y: y, 'z': z} = x", "var { y, z } = x;"); + // test("({y: y, 'z': z} = x)", "({ y, z } = x);"); + // test("var {y: y, 'z': z} = x", "var { y, z } = x;"); test("x = {y: 1, 'z': 2}", "x = { y: 1, z: 2 };"); test("x = {y() {}, 'z'() {}}", "x = { y() {}, z() {} };"); test("x = {get y() {}, set 'z'(z) {}}", "x = { get y() {}, set z(z) {} };"); - test("x = class {y = 1; 'z' = 2}", "x = class { y = 1; z = 2;};"); - test("x = class {y() {}; 'z'() {}}", "x = class { y() { } z() { }};"); - test("x = class {get y() {}; set 'z'(z) {}}", "x = class { get y() { } set z(z) { }};"); + test("x = class {y = 1; 'z' = 2}", "x = class { y = 1; z = 2;};"); + test("x = class {y() {}; 'z'() {}}", "x = class { y() { } z() { }};"); + test("x = class {get y() {}; set 'z'(z) {}}", "x = class { get y() { } set z(z) { }};"); test("function foo() { return undefined }", "function foo() {}"); test("function* foo() { return undefined }", "function* foo() {}"); test("async function foo() { return undefined }", "async function foo() {}"); - test("async function* foo() { return undefined }", "async function* foo() { return void 0;}"); - test("function f() { x() } function f() { y() }", "function f() { y();}"); - test("function f() { x() } function *f() { y() }", "function* f() { y();}"); - test("function *f() { x() } function f() { y() }", "function f() { y();}"); - test("function *f() { x() } function *f() { y() }", "function* f() { y();}"); - test("function f() { x() } async function f() { y() }", "async function f() { y();}"); - test("async function f() { x() } function f() { y() }", "function f() { y();}"); - test("async function f() { x() } async function f() { y() }", "async function f() { y();}"); + test("async function* foo() { return undefined }", "async function* foo() { return void 0;}"); + // test("function f() { x() } function f() { y() }", "function f() { y();}"); + // test("function f() { x() } function *f() { y() }", "function* f() { y();}"); + // test("function *f() { x() } function f() { y() }", "function f() { y();}"); + // test("function *f() { x() } function *f() { y() }", "function* f() { y();}"); + // test("function f() { x() } async function f() { y() }", "async function f() { y();}"); + // test("async function f() { x() } function f() { y() }", "function f() { y();}"); + // test("async function f() { x() } async function f() { y() }", "async function f() { y();}"); test("var f; function f() {}", "var f;function f() {}"); test("function f() {} var f", "function f() {}var f;"); - test("var f; function f() { x() } function f() { y() }", "var f;function f() { y();}"); - test("function f() { x() } function f() { y() } var f", "function f() { y();}var f;"); + // test("var f; function f() { x() } function f() { y() }", "var f;function f() { y();}"); + // test("function f() { x() } function f() { y() } var f", "function f() { y();}var f;"); test( "function f() { x() } var f; function f() { y() }", - "function f() { x();}var f;function f() { y();}", + "function f() { x();}var f;function f() { y();}", ); - test("class Foo { ['constructor'] = 0 }", "class Foo { ['constructor'] = 0;}"); - test("class Foo { ['constructor']() {} }", "class Foo { ['constructor']() { }}"); - test("class Foo { *['constructor']() {} }", "class Foo { *['constructor']() { }}"); - test("class Foo { get ['constructor']() {} }", "class Foo { get ['constructor']() { }}"); - test("class Foo { set ['constructor'](x) {} }", "class Foo { set ['constructor'](x) { }}"); - test("class Foo { async ['constructor']() {} }", "class Foo { async ['constructor']() { }}"); - test("class Foo { static ['constructor'] = 0 }", "class Foo { static ['constructor'] = 0;}"); - test("class Foo { static ['constructor']() {} }", "class Foo { static constructor() { }}"); - test("class Foo { static *['constructor']() {} }", "class Foo { static *constructor() { }}"); - test( - "class Foo { static get ['constructor']() {} }", - "class Foo { static get constructor() { }}", - ); - test( - "class Foo { static set ['constructor'](x) {} }", - "class Foo { static set constructor(x) { }}", - ); - test( - "class Foo { static async ['constructor']() {} }", - "class Foo { static async constructor() { }}", - ); - test("class Foo { ['prototype'] = 0 }", "class Foo { prototype = 0;}"); - test("class Foo { ['prototype']() {} }", "class Foo { prototype() { }}"); - test("class Foo { *['prototype']() {} }", "class Foo { *prototype() { }}"); - test("class Foo { get ['prototype']() {} }", "class Foo { get prototype() { }}"); - test("class Foo { set ['prototype'](x) {} }", "class Foo { set prototype(x) { }}"); - test("class Foo { async ['prototype']() {} }", "class Foo { async prototype() { }}"); - test("class Foo { static ['prototype'] = 0 }", "class Foo { static ['prototype'] = 0;}"); - test("class Foo { static ['prototype']() {} }", "class Foo { static ['prototype']() { }}"); - test("class Foo { static *['prototype']() {} }", "class Foo { static *['prototype']() { }}"); - test( - "class Foo { static get ['prototype']() {} }", - "class Foo { static get ['prototype']() { }}", - ); - test( - "class Foo { static set ['prototype'](x) {} }", - "class Foo { static set ['prototype'](x) { }}", - ); - test( - "class Foo { static async ['prototype']() {} }", - "class Foo { static async ['prototype']() { }}", - ); - test( - "class Foo { constructor() {} ['constructor']() {} }", - "class Foo { constructor() { } ['constructor']() { }}", - ); - test( - "class Foo { static constructor() {} static ['constructor']() {} }", - "class Foo { static constructor() { } static constructor() { }}", - ); - test("class x { '0' = y }", "class x { 0 = y;}"); - test("class x { '123' = y }", "class x { 123 = y;}"); - test("class x { ['-123'] = y }", "class x { '-123' = y;}"); - test("class x { '-0' = y }", "class x { '-0' = y;}"); - test("class x { '01' = y }", "class x { '01' = y;}"); - test("class x { '-01' = y }", "class x { '-01' = y;}"); - test("class x { '0x1' = y }", "class x { '0x1' = y;}"); - test("class x { '-0x1' = y }", "class x { '-0x1' = y;}"); - test("class x { '2147483647' = y }", "class x { 2147483647 = y;}"); - test("class x { '2147483648' = y }", "class x { '2147483648' = y;}"); - test("class x { ['-2147483648'] = y }", "class x { '-2147483648' = y;}"); - test("class x { ['-2147483649'] = y }", "class x { '-2147483649' = y;}"); + // test("class Foo { ['constructor'] = 0 }", "class Foo { ['constructor'] = 0;}"); + // test("class Foo { ['constructor']() {} }", "class Foo { ['constructor']() { }}"); + // test("class Foo { *['constructor']() {} }", "class Foo { *['constructor']() { }}"); + // test("class Foo { get ['constructor']() {} }", "class Foo { get ['constructor']() { }}"); + // test("class Foo { set ['constructor'](x) {} }", "class Foo { set ['constructor'](x) { }}"); + // test("class Foo { async ['constructor']() {} }", "class Foo { async ['constructor']() { }}"); + // test("class Foo { static ['constructor'] = 0 }", "class Foo { static ['constructor'] = 0;}"); + // test("class Foo { static ['constructor']() {} }", "class Foo { static constructor() { }}"); + // test("class Foo { static *['constructor']() {} }", "class Foo { static *constructor() { }}"); + // test( + // "class Foo { static get ['constructor']() {} }", + // "class Foo { static get constructor() { }}", + // ); + // test( + // "class Foo { static set ['constructor'](x) {} }", + // "class Foo { static set constructor(x) { }}", + // ); + // test( + // "class Foo { static async ['constructor']() {} }", + // "class Foo { static async constructor() { }}", + // ); + // test("class Foo { ['prototype'] = 0 }", "class Foo { prototype = 0;}"); + // test("class Foo { ['prototype']() {} }", "class Foo { prototype() { }}"); + // test("class Foo { *['prototype']() {} }", "class Foo { *prototype() { }}"); + // test("class Foo { get ['prototype']() {} }", "class Foo { get prototype() { }}"); + // test("class Foo { set ['prototype'](x) {} }", "class Foo { set prototype(x) { }}"); + // test("class Foo { async ['prototype']() {} }", "class Foo { async prototype() { }}"); + // test("class Foo { static ['prototype'] = 0 }", "class Foo { static ['prototype'] = 0;}"); + // test("class Foo { static ['prototype']() {} }", "class Foo { static ['prototype']() { }}"); + // test("class Foo { static *['prototype']() {} }", "class Foo { static *['prototype']() { }}"); + // test( + // "class Foo { static get ['prototype']() {} }", + // "class Foo { static get ['prototype']() { }}", + // ); + // test( + // "class Foo { static set ['prototype'](x) {} }", + // "class Foo { static set ['prototype'](x) { }}", + // ); + // test( + // "class Foo { static async ['prototype']() {} }", + // "class Foo { static async ['prototype']() { }}", + // ); + // test( + // "class Foo { constructor() {} ['constructor']() {} }", + // "class Foo { constructor() { } ['constructor']() { }}", + // ); + // test( + // "class Foo { static constructor() {} static ['constructor']() {} }", + // "class Foo { static constructor() { } static constructor() { }}", + // ); + test("class x { '0' = y }", "class x { 0 = y;}"); + test("class x { '123' = y }", "class x { 123 = y;}"); + // test("class x { ['-123'] = y }", "class x { '-123' = y;}"); + test("class x { '-0' = y }", "class x { '-0' = y;}"); + test("class x { '01' = y }", "class x { '01' = y;}"); + test("class x { '-01' = y }", "class x { '-01' = y;}"); + test("class x { '0x1' = y }", "class x { '0x1' = y;}"); + test("class x { '-0x1' = y }", "class x { '-0x1' = y;}"); + test("class x { '2147483647' = y }", "class x { 2147483647 = y;}"); + test("class x { '2147483648' = y }", "class x { '2147483648' = y;}"); + // test("class x { ['-2147483648'] = y }", "class x { '-2147483648' = y;}"); + test("class x { ['-2147483649'] = y }", "class x { '-2147483649' = y;}"); test("class Foo { static {} }", "class Foo {}"); test("class Foo { static { 123 } }", "class Foo {}"); - test("class Foo { static { /* @__PURE__ */ foo() } }", "class Foo {}"); - test("class Foo { static { foo() } }", "class Foo { static { foo(); }}"); + // test("class Foo { static { /* @__PURE__ */ foo() } }", "class Foo {}"); + test("class Foo { static { foo() } }", "class Foo { static { foo(); }}"); test("x: break x", ""); test("x: { break x; foo() }", ""); - test("y: while (foo()) x: { break x; foo() }", "for (; foo(); ) ;"); - test("y: while (foo()) x: { break y; foo() }", "y: for (; foo(); ) break y;"); - test("x: { y: { z: { foo(); break x; } } }", "x: { foo(); break x;}"); - test("x: { class X { static { new X } } }", "{ class X { static { new X(); } }}"); + // test("y: while (foo()) x: { break x; foo() }", "for (; foo(); ) ;"); + // test("y: while (foo()) x: { break y; foo() }", "y: for (; foo(); ) break y;"); + // test("x: { y: { z: { foo(); break x; } } }", "x: { foo(); break x;}"); + // test("x: { class X { static { new X } } }", "{ class X { static { new X(); } }}"); test("(() => {}) ? a : b", "a;"); - test("x = `a${1 + `b${2}c` + 3}d`", "x = `a1b2c3d`;"); + // test("x = `a${1 + `b${2}c` + 3}d`", "x = `a1b2c3d`;"); test("x = 1 ? a : b", "x = a;"); test("x = 0 ? a : b", "x = b;"); test("x; 1 ? 0 : ()=>{}; (()=>{})()", "x;"); test("x; 0 ? ()=>{} : 1; (()=>{})()", "x;"); test("if (1) 0; else ()=>{}; (()=>{})()", ""); test("if (0) ()=>{}; else 1; (()=>{})()", ""); - test("var a; while (1) ;", "for (var a; ; ) ;"); - test("let a; while (1) ;", "let a;for (; ; ) ;"); - test("const a=0; while (1) ;", "const a = 0;for (; ; ) ;"); - test("var a; for (var b;;) ;", "for (var a, b; ; ) ;"); - test("let a; for (let b;;) ;", "let a;for (let b; ; ) ;"); - test("const a=0; for (const b = 1;;) ;", "const a = 0;for (const b = 1; ; ) ;"); - test("export var a; while (1) ;", "export var a;for (; ; ) ;"); - test("export let a; while (1) ;", "export let a;for (; ; ) ;"); - test("export const a=0; while (1) ;", "export const a = 0;for (; ; ) ;"); - test("export var a; for (var b;;) ;", "export var a;for (var b; ; ) ;"); - test("export let a; for (let b;;) ;", "export let a;for (let b; ; ) ;"); - test("export const a=0; for (const b = 1;;) ;", "export const a = 0;for (const b = 1; ; ) ;"); - test("var a; for (let b;;) ;", "var a;for (let b; ; ) ;"); - test("let a; for (const b=0;;) ;", "let a;for (const b = 0; ; ) ;"); - test("const a=0; for (var b;;) ;", "const a = 0;for (var b; ; ) ;"); - test("a(); while (1) ;", "for (a(); ; ) ;"); - test("a(); for (b();;) ;", "for (a(), b(); ; ) ;"); - test("for (; ;) if (x) break;", "for (; !x; ) ;"); - test("for (; ;) if (!x) break;", "for (; x; ) ;"); - test("for (; a;) if (x) break;", "for (; a && !x; ) ;"); - test("for (; a;) if (!x) break;", "for (; a && x; ) ;"); - test("for (; ;) { if (x) break; y(); }", "for (; !x; ) y();"); - test("for (; a;) { if (x) break; y(); }", "for (; a && !x; ) y();"); - test("for (; ;) if (x) break; else y();", "for (; !x; ) y();"); - test("for (; a;) if (x) break; else y();", "for (; a && !x; ) y();"); - test("for (; ;) { if (x) break; else y(); z(); }", "for (; !x; ) y(), z();"); - test("for (; a;) { if (x) break; else y(); z(); }", "for (; a && !x; ) y(), z();"); - test("for (; ;) if (x) y(); else break;", "for (; x; ) y();"); - test("for (; ;) if (!x) y(); else break;", "for (; !x; ) y();"); - test("for (; a;) if (x) y(); else break;", "for (; a && x; ) y();"); - test("for (; a;) if (!x) y(); else break;", "for (; a && !x; ) y();"); - test("for (; ;) { if (x) y(); else break; z(); }", "for (; x; ) { y(); z();}"); - test("for (; a;) { if (x) y(); else break; z(); }", "for (; a && x; ) { y(); z();}"); - test("while (x) { if (1) break; z(); }", "for (; x; ) break;"); - test("while (x) { if (1) continue; z(); }", "for (; x; ) ;"); - test( - "foo: while (a) while (x) { if (1) continue foo; z(); }", - "foo: for (; a; ) for (; x; ) continue foo;", - ); - test("while (x) { y(); if (1) break; z(); }", "for (; x; ) { y(); break;}"); - test("while (x) { y(); if (1) continue; z(); }", "for (; x; ) y();"); - test("while (x) { y(); debugger; if (1) continue; z(); }", "for (; x; ) { y(); debugger;}"); - test("while (x) { let y = z(); if (1) continue; z(); }", "for (; x; ) { let y = z();}"); - test( - "while (x) { debugger; if (y) { if (1) break; z() } }", - "for (; x; ) { debugger; if (y) break;}", - ); - test( - "while (x) { debugger; if (y) { if (1) continue; z() } }", - "for (; x; ) { debugger; y;}", - ); - test( - "while (x) { debugger; if (1) { if (1) break; z() } }", - "for (; x; ) { debugger; break;}", - ); - test("while (x) { debugger; if (1) { if (1) continue; z() } }", "for (; x; ) debugger;"); - test("while (x()) continue", "for (; x(); ) ;"); - test("while (x) { y(); continue }", "for (; x; ) y();"); - test("while (x) { if (y) { z(); continue } }", "for (; x; ) if (y) { z(); continue; }"); - test( - "label: while (x) while (y) { z(); continue label }", - "label: for (; x; ) for (; y; ) { z(); continue label;}", - ); - test("while (x) { if (y) continue; z(); }", "for (; x; ) y || z();"); - test("while (x) { if (y) continue; else z(); w(); }", "for (; x; ) y || (z(), w());"); - test("while (x) { t(); if (y) continue; z(); }", "for (; x; ) t(), !y && z();"); - test( - "while (x) { t(); if (y) continue; else z(); w(); }", - "for (; x; ) t(), !y && (z(), w());", - ); - test("while (x) { debugger; if (y) continue; z(); }", "for (; x; ) { debugger; y || z();}"); - test( - "while (x) { debugger; if (y) continue; else z(); w(); }", - "for (; x; ) { debugger; y || (z(), w());}", - ); - test( - "while (x) { if (y) continue; function y() {} }", - "for (; x; ) { let y = function() { }; var y = y;}", - ); - test("while (x) { if (y) continue; let y }", "for (; x; ) { if (y) continue; let y;}"); - test("while (x) { if (y) continue; var y }", "for (; x; ) if (!y) var y;"); + test("var a; while (1) ;", "for (var a;;) ;"); + test("let a; while (1) ;", "let a;for (;;) ;"); + test("const a=0; while (1) ;", "const a = 0;for (;;) ;"); + test("var a; for (var b;;) ;", "for (var a, b;;) ;"); + test("let a; for (let b;;) ;", "let a;for (let b;;) ;"); + test("const a=0; for (const b = 1;;) ;", "const a = 0;for (const b = 1;;) ;"); + test("export var a; while (1) ;", "export var a;for (;;) ;"); + test("export let a; while (1) ;", "export let a;for (;;) ;"); + test("export const a=0; while (1) ;", "export const a = 0;for (;;) ;"); + test("export var a; for (var b;;) ;", "export var a;for (var b;;) ;"); + test("export let a; for (let b;;) ;", "export let a;for (let b;;) ;"); + test("export const a=0; for (const b = 1;;) ;", "export const a = 0;for (const b = 1;;) ;"); + test("var a; for (let b;;) ;", "var a;for (let b;;) ;"); + test("let a; for (const b=0;;) ;", "let a;for (const b = 0;;) ;"); + test("const a=0; for (var b;;) ;", "const a = 0;for (var b;;) ;"); + test("a(); while (1) ;", "for (a();;) ;"); + test("a(); for (b();;) ;", "for (a(), b();;) ;"); + // test("for (; ;) if (x) break;", "for (; !x; ) ;"); + // test("for (; ;) if (!x) break;", "for (; x; ) ;"); + // test("for (; a;) if (x) break;", "for (; a && !x; ) ;"); + // test("for (; a;) if (!x) break;", "for (; a && x; ) ;"); + // test("for (; ;) { if (x) break; y(); }", "for (; !x; ) y();"); + // test("for (; a;) { if (x) break; y(); }", "for (; a && !x; ) y();"); + // test("for (; ;) if (x) break; else y();", "for (; !x; ) y();"); + // test("for (; a;) if (x) break; else y();", "for (; a && !x; ) y();"); + // test("for (; ;) { if (x) break; else y(); z(); }", "for (; !x; ) y(), z();"); + // test("for (; a;) { if (x) break; else y(); z(); }", "for (; a && !x; ) y(), z();"); + // test("for (; ;) if (x) y(); else break;", "for (; x; ) y();"); + // test("for (; ;) if (!x) y(); else break;", "for (; !x; ) y();"); + // test("for (; a;) if (x) y(); else break;", "for (; a && x; ) y();"); + // test("for (; a;) if (!x) y(); else break;", "for (; a && !x; ) y();"); + // test("for (; ;) { if (x) y(); else break; z(); }", "for (; x; ) { y(); z();}"); + // test("for (; a;) { if (x) y(); else break; z(); }", "for (; a && x; ) { y(); z();}"); + // test("while (x) { if (1) break; z(); }", "for (; x; ) break;"); + // test("while (x) { if (1) continue; z(); }", "for (; x; ) ;"); + // test( + // "foo: while (a) while (x) { if (1) continue foo; z(); }", + // "foo: for (; a; ) for (; x; ) continue foo;", + // ); + // test("while (x) { y(); if (1) break; z(); }", "for (; x; ) { y(); break;}"); + // test("while (x) { y(); if (1) continue; z(); }", "for (; x; ) y();"); + // test("while (x) { y(); debugger; if (1) continue; z(); }", "for (; x; ) { y(); debugger;}"); + // test("while (x) { let y = z(); if (1) continue; z(); }", "for (; x; ) { let y = z();}"); + // test( + // "while (x) { debugger; if (y) { if (1) break; z() } }", + // "for (; x; ) { debugger; if (y) break;}", + // ); + // test( + // "while (x) { debugger; if (y) { if (1) continue; z() } }", + // "for (; x; ) { debugger; y;}", + // ); + // test( + // "while (x) { debugger; if (1) { if (1) break; z() } }", + // "for (; x; ) { debugger; break;}", + // ); + // test("while (x) { debugger; if (1) { if (1) continue; z() } }", "for (; x; ) debugger;"); + // test("while (x()) continue", "for (; x(); ) ;"); + // test("while (x) { y(); continue }", "for (; x; ) y();"); + // test("while (x) { if (y) { z(); continue } }", "for (; x; ) if (y) { z(); continue; }"); + // test( + // "label: while (x) while (y) { z(); continue label }", + // "label: for (; x; ) for (; y; ) { z(); continue label;}", + // ); + // test("while (x) { if (y) continue; z(); }", "for (; x; ) y || z();"); + // test("while (x) { if (y) continue; else z(); w(); }", "for (; x; ) y || (z(), w());"); + // test("while (x) { t(); if (y) continue; z(); }", "for (; x; ) t(), !y && z();"); + // test( + // "while (x) { t(); if (y) continue; else z(); w(); }", + // "for (; x; ) t(), !y && (z(), w());", + // ); + // test("while (x) { debugger; if (y) continue; z(); }", "for (; x; ) { debugger; y || z();}"); + // test( + // "while (x) { debugger; if (y) continue; else z(); w(); }", + // "for (; x; ) { debugger; y || (z(), w());}", + // ); + // test( + // "while (x) { if (y) continue; function y() {} }", + // "for (; x; ) { let y = function() { }; var y = y;}", + // ); + // test("while (x) { if (y) continue; let y }", "for (; x; ) { if (y) continue; let y;}"); + // test("while (x) { if (y) continue; var y }", "for (; x; ) if (!y) var y;"); test("console.log(undefined)", "console.log(void 0);"); test("console.log(+undefined)", "console.log(NaN);"); test("console.log(undefined + undefined)", "console.log(void 0 + void 0);"); test("const x = undefined", "const x = void 0;"); test("let x = undefined", "let x;"); test("var x = undefined", "var x = void 0;"); - test("function foo(a) { if (!a) return undefined; a() }", "function foo(a) { a && a();}"); + // test("function foo(a) { if (!a) return undefined; a() }", "function foo(a) { a && a();}"); test("delete undefined", "delete undefined;"); test("undefined--", "undefined--;"); test("undefined++", "undefined++;"); @@ -247,11 +247,11 @@ fn js_parser_test() { test("undefined = 1", "undefined = 1;"); test("[undefined] = 1", "[undefined] = 1;"); test("({x: undefined} = 1)", "({ x: undefined } = 1);"); - test("with (x) y(undefined); z(undefined)", "with (x) y(undefined);z(void 0);"); - test( - "with (x) while (i) y(undefined); z(undefined)", - "with (x) for (; i; ) y(undefined);z(void 0);", - ); + // test("with (x) y(undefined); z(undefined)", "with (x) y(undefined);z(void 0);"); + // test( + // "with (x) while (i) y(undefined); z(undefined)", + // "with (x) for (; i; ) y(undefined);z(void 0);", + // ); test("x['y']", "x.y;"); test("x['y z']", "x['y z'];"); test("x?.['y']", "x?.y;"); @@ -259,7 +259,7 @@ fn js_parser_test() { test("x?.['y']()", "x?.y();"); test("x?.['y z']()", "x?.['y z']();"); test("x['y' + 'z']", "x.yz;"); - test("x?.['y' + 'z']", "x?.['yz'];"); + // test("x?.['y' + 'z']", "x?.['yz'];"); test("x['0']", "x[0];"); test("x['123']", "x[123];"); test("x['-123']", "x[-123];"); @@ -270,58 +270,58 @@ fn js_parser_test() { test("x['-0x1']", "x['-0x1'];"); test("x['2147483647']", "x[2147483647];"); test("x['2147483648']", "x['2147483648'];"); - test("x['-2147483648']", "x[-2147483648];"); + // test("x['-2147483648']", "x[-2147483648];"); test("x['-2147483649']", "x['-2147483649'];"); - test("while(1) { while (1) {} }", "for (; ; ) for (; ; ) ;"); - test("while(1) { const x = y; }", "for (; ; ) { const x = y;}"); - test("while(1) { let x; }", "for (; ; ) { let x;}"); - test("while(1) { var x; }", "for (; ; ) var x;"); - test("while(1) { class X {} }", "for (; ; ) { class X { }}"); - test("while(1) { function x() {} }", "for (; ; ) var x = function() { };"); - test("while(1) { function* x() {} }", "for (; ; ) { function* x() { }}"); - test("while(1) { async function x() {} }", "for (; ; ) { async function x() { }}"); - test("while(1) { async function* x() {} }", "for (; ; ) { async function* x() { }}"); - test("x(); switch (y) { case z: return w; }", "switch (x(), y) { case z: return w;}"); + test("while(1) { while (1) {} }", "for (;;) for (;;) ;"); + test("while(1) { const x = y; }", "for (;;) { const x = y;}"); + test("while(1) { let x; }", "for (;;) { let x;}"); + // test("while(1) { var x; }", "for (;;) var x;"); + test("while(1) { class X {} }", "for (;;) { class X { }}"); + // test("while(1) { function x() {} }", "for (;;) var x = function() { };"); + test("while(1) { function* x() {} }", "for (;;) { function* x() { }}"); + test("while(1) { async function x() {} }", "for (;;) { async function x() { }}"); + test("while(1) { async function* x() {} }", "for (;;) { async function* x() { }}"); + test("x(); switch (y) { case z: return w; }", "switch (x(), y) { case z: return w;}"); test( "if (t) { x(); switch (y) { case z: return w; } }", - "if (t) switch (x(), y) { case z: return w; }", + "if (t) switch (x(), y) { case z: return w; }", ); test("a = '' + 0", "a = '0';"); test("a = 0 + ''", "a = '0';"); test("a = '' + b", "a = '' + b;"); test("a = b + ''", "a = b + '';"); - test("a = [] + 0", "a = '0';"); - test("a = 0 + []", "a = '0';"); + // test("a = [] + 0", "a = '0';"); + // test("a = 0 + []", "a = '0';"); test("a = [] + b", "a = [] + b;"); test("a = b + []", "a = b + [];"); test("a = [b] + 0", "a = [b] + 0;"); test("a = 0 + [b]", "a = 0 + [b];"); - test("a = [1, 2] + ''", "a = '1,2';"); - test("a = [1, 0, 2] + ''", "a = '1,0,2';"); - test("a = [1, null, 2] + ''", "a = '1,,2';"); - test("a = [1, undefined, 2] + ''", "a = '1,,2';"); - test("a = [1, true, 2] + ''", "a = '1,true,2';"); - test("a = [1, false, 2] + ''", "a = '1,false,2';"); + // test("a = [1, 2] + ''", "a = '1,2';"); + // test("a = [1, 0, 2] + ''", "a = '1,0,2';"); + // test("a = [1, null, 2] + ''", "a = '1,,2';"); + // test("a = [1, undefined, 2] + ''", "a = '1,,2';"); + // test("a = [1, true, 2] + ''", "a = '1,true,2';"); + // test("a = [1, false, 2] + ''", "a = '1,false,2';"); test("a = [1, , 2] + ''", "a = [1, , 2] + '';"); test("a = [1, , ,] + ''", "a = [1, , ,] + '';"); - test("a = {} + 0", "a = '[object Object]0';"); - test("a = 0 + {}", "a = '0[object Object]';"); + // test("a = {} + 0", "a = '[object Object]0';"); + // test("a = 0 + {}", "a = '0[object Object]';"); test("a = {} + b", "a = {} + b;"); test("a = b + {}", "a = b + {};"); test("a = {toString:()=>1} + 0", "a = { toString: () => 1 } + 0;"); test("a = 0 + {toString:()=>1}", "a = 0 + { toString: () => 1 };"); - test("a = '' + `${b}`", "a = `${b}`;"); - test("a = `${b}` + ''", "a = `${b}`;"); - test("a = '' + typeof b", "a = typeof b;"); - test("a = typeof b + ''", "a = typeof b;"); - test("a = [] + `${b}`", "a = `${b}`;"); - test("a = `${b}` + []", "a = `${b}`;"); - test("a = [] + typeof b", "a = typeof b;"); - test("a = typeof b + []", "a = typeof b;"); - test("a = [b] + `${b}`", "a = [b] + `${b}`;"); - test("a = `${b}` + [b]", "a = `${b}` + [b];"); - test("a = {} + `${b}`", "a = `[object Object]${b}`;"); - test("a = `${b}` + {}", "a = `${b}[object Object]`;"); + // test("a = '' + `${b}`", "a = `${b}`;"); + // test("a = `${b}` + ''", "a = `${b}`;"); + // test("a = '' + typeof b", "a = typeof b;"); + // test("a = typeof b + ''", "a = typeof b;"); + // test("a = [] + `${b}`", "a = `${b}`;"); + // test("a = `${b}` + []", "a = `${b}`;"); + // test("a = [] + typeof b", "a = typeof b;"); + // test("a = typeof b + []", "a = typeof b;"); + // test("a = [b] + `${b}`", "a = [b] + `${b}`;"); + // test("a = `${b}` + [b]", "a = `${b}` + [b];"); + // test("a = {} + `${b}`", "a = `[object Object]${b}`;"); + // test("a = `${b}` + {}", "a = `${b}[object Object]`;"); test("a = {} + typeof b", "a = {} + typeof b;"); test("a = typeof b + {}", "a = typeof b + {};"); test("a = {toString:()=>1} + `${b}`", "a = { toString: () => 1 } + `${b}`;"); @@ -330,8 +330,8 @@ fn js_parser_test() { test("a = '' + true", "a = 'true';"); test("a = false + ''", "a = 'false';"); test("a = true + ''", "a = 'true';"); - test("a = 1 + false + ''", "a = 1 + false + '';"); - test("a = 0 + true + ''", "a = 0 + true + '';"); + // test("a = 1 + false + ''", "a = 1 + false + '';"); + // test("a = 0 + true + ''", "a = 0 + true + '';"); test("a = '' + null", "a = 'null';"); test("a = null + ''", "a = 'null';"); test("a = '' + undefined", "a = 'undefined';"); @@ -340,19 +340,19 @@ fn js_parser_test() { test("a = '' + 1n", "a = '1';"); test("a = '' + 123n", "a = '123';"); test("a = '' + 1_2_3n", "a = '123';"); - test("a = '' + 0b0n", "a = '' + 0b0n;"); - test("a = '' + 0o0n", "a = '' + 0o0n;"); - test("a = '' + 0x0n", "a = '' + 0x0n;"); - test("a = '' + /a\\b/ig", "a = '/a\\\\b/ig';"); - test("a = /a\\b/ig + ''", "a = '/a\\\\b/ig';"); - test("a = '' + ''.constructor", "a = 'function String() { [native code] }';"); - test("a = ''.constructor + ''", "a = 'function String() { [native code] }';"); - test("a = '' + /./.constructor", "a = 'function RegExp() { [native code] }';"); - test("a = /./.constructor + ''", "a = 'function RegExp() { [native code] }';"); + // test("a = '' + 0b0n", "a = '' + 0b0n;"); + // test("a = '' + 0o0n", "a = '' + 0o0n;"); + // test("a = '' + 0x0n", "a = '' + 0x0n;"); + // test("a = '' + /a\\b/ig", "a = '/a\\\\b/ig';"); + // test("a = /a\\b/ig + ''", "a = '/a\\\\b/ig';"); + // test("a = '' + ''.constructor", "a = 'function String() { [native code] }';"); + // test("a = ''.constructor + ''", "a = 'function String() { [native code] }';"); + // test("a = '' + /./.constructor", "a = 'function RegExp() { [native code] }';"); + // test("a = /./.constructor + ''", "a = 'function RegExp() { [native code] }';"); test("''.length++", "''.length++;"); test("''.length = a", "''.length = a;"); test("a = ''.len", "a = ''.len;"); - test("a = [].length", "a = [].length;"); + test("a = [].length", "a = 0;"); test("a = ''.length", "a = 0;"); test("a = ``.length", "a = 0;"); test("a = b``.length", "a = b``.length;"); @@ -360,9 +360,9 @@ fn js_parser_test() { test("a = 'ศงแธƒฤ‹'.length", "a = 3;"); test("a = '๐Ÿ‘ฏโ€โ™‚๏ธ'.length", "a = 5;"); test("a = 'abc'[-1]", "a = 'abc'[-1];"); - test("a = 'abc'[-0]", "a = 'a';"); - test("a = 'abc'[0]", "a = 'a';"); - test("a = 'abc'[2]", "a = 'c';"); + // test("a = 'abc'[-0]", "a = 'a';"); + // test("a = 'abc'[0]", "a = 'a';"); + // test("a = 'abc'[2]", "a = 'c';"); test("a = 'abc'[3]", "a = 'abc'[3];"); test("a = 'abc'[NaN]", "a = 'abc'[NaN];"); test("a = 'abc'[-1e100]", "a = 'abc'[-1e100];"); @@ -373,7 +373,7 @@ fn js_parser_test() { test("a = !(b != c)", "a = b == c;"); test("a = !(b === c)", "a = b !== c;"); test("a = !(b !== c)", "a = b === c;"); - test("if (!(a, b)) return c", "if (a, !b) return c;"); + // test("if (!(a, b)) return c", "if (a, !b) return c;"); test("a = !(b < c)", "a = !(b < c);"); test("a = !(b > c)", "a = !(b > c);"); test("a = !(b <= c)", "a = !(b <= c);"); @@ -403,23 +403,23 @@ fn js_parser_test() { test("a = !!(b && !c)", "a = !!(b && !c);"); test("a = !!(b || !c)", "a = !!(b || !c);"); test("a = !!(b ?? !c)", "a = !!(b ?? !c);"); - test("a = !!(!b && !c)", "a = !b && !c;"); - test("a = !!(!b || !c)", "a = !b || !c;"); + // test("a = !!(!b && !c)", "a = !b && !c;"); + // test("a = !!(!b || !c)", "a = !b || !c;"); test("a = !!(!b ?? !c)", "a = !b;"); - test("a = !!(b, c)", "a = (b, !!c);"); + // test("a = !!(b, c)", "a = (b, !!c);"); test("a = Boolean(b); var Boolean", "a = Boolean(b);var Boolean;"); - test("a = Boolean()", "a = false;"); + test("a = Boolean()", "a = !1;"); test("a = Boolean(b)", "a = !!b;"); test("a = Boolean(!b)", "a = !b;"); test("a = Boolean(!!b)", "a = !!b;"); test("a = Boolean(b ? true : false)", "a = !!b;"); test("a = Boolean(b ? false : true)", "a = !b;"); - test("a = Boolean(b ? c > 0 : c < 0)", "a = b ? c > 0 : c < 0;"); - test("a = Boolean((b | c) !== 0)", "a = !!(b | c);"); - test("a = Boolean(b ? (c | d) !== 0 : (d | e) !== 0)", "a = !!(b ? c | d : d | e);"); + // test("a = Boolean(b ? c > 0 : c < 0)", "a = b ? c > 0 : c < 0;"); + // test("a = Boolean((b | c) !== 0)", "a = !!(b | c);"); + // test("a = Boolean(b ? (c | d) !== 0 : (d | e) !== 0)", "a = !!(b ? c | d : d | e);"); test("a = Number(x)", "a = Number(x);"); test("a = Number(0n)", "a = Number(0n);"); - test("a = Number(false); var Number", "a = Number(false);var Number;"); + test("a = Number(false); var Number", "a = Number(!1);var Number;"); test("a = Number(0xFFFF_FFFF_FFFF_FFFFn)", "a = Number(0xFFFFFFFFFFFFFFFFn);"); test("a = Number()", "a = 0;"); test("a = Number(-123)", "a = -123;"); @@ -427,52 +427,52 @@ fn js_parser_test() { test("a = Number(true)", "a = 1;"); test("a = Number(undefined)", "a = NaN;"); test("a = Number(null)", "a = 0;"); - test("a = Number(b ? !c : !d)", "a = +(b ? !c : !d);"); - test("a = String(x)", "a = String(x);"); + // test("a = Number(b ? !c : !d)", "a = +(b ? !c : !d);"); + // test("a = String(x)", "a = String(x);"); test("a = String('x'); var String", "a = String('x');var String;"); test("a = String()", "a = '';"); test("a = String('x')", "a = 'x';"); - test("a = String(b ? 'x' : 'y')", "a = b ? 'x' : 'y';"); + // test("a = String(b ? 'x' : 'y')", "a = b ? 'x' : 'y';"); test("a = BigInt(x)", "a = BigInt(x);"); test("a = BigInt(0n); var BigInt", "a = BigInt(0n);var BigInt;"); test("a = BigInt()", "a = BigInt();"); test("a = BigInt('0')", "a = BigInt('0');"); test("a = BigInt(0n)", "a = 0n;"); - test("a = BigInt(b ? 0n : 1n)", "a = b ? 0n : 1n;"); + // test("a = BigInt(b ? 0n : 1n)", "a = b ? 0n : 1n;"); test("a = 'xy'.charCodeAt()", "a = 120;"); test("a = 'xy'.charCodeAt(0)", "a = 120;"); test("a = 'xy'.charCodeAt(1)", "a = 121;"); test("a = 'xy'.charCodeAt(-1)", "a = NaN;"); - test("a = 'xy'.charCodeAt(2)", "a = NaN;"); - test("a = '๐Ÿง€'.charCodeAt()", "a = 55358;"); - test("a = '๐Ÿง€'.charCodeAt(0)", "a = 55358;"); - test("a = '๐Ÿง€'.charCodeAt(1)", "a = 56768;"); - test("a = '๐Ÿง€'.charCodeAt(-1)", "a = NaN;"); - test("a = '๐Ÿง€'.charCodeAt(2)", "a = NaN;"); + // test("a = 'xy'.charCodeAt(2)", "a = NaN;"); + // test("a = '๐Ÿง€'.charCodeAt()", "a = 55358;"); + // test("a = '๐Ÿง€'.charCodeAt(0)", "a = 55358;"); + // test("a = '๐Ÿง€'.charCodeAt(1)", "a = 56768;"); + // test("a = '๐Ÿง€'.charCodeAt(-1)", "a = NaN;"); + // test("a = '๐Ÿง€'.charCodeAt(2)", "a = NaN;"); test("a = 'xy'.charCodeAt(NaN)", "a = 'xy'.charCodeAt(NaN);"); test("a = 'xy'.charCodeAt(-Infinity)", "a = 'xy'.charCodeAt(-Infinity);"); test("a = 'xy'.charCodeAt(Infinity)", "a = 'xy'.charCodeAt(Infinity);"); test("a = 'xy'.charCodeAt(0.5)", "a = 'xy'.charCodeAt(0.5);"); - test("a = 'xy'.charCodeAt(1e99)", "a = 'xy'.charCodeAt(1e99);"); - test("a = 'xy'.charCodeAt('1')", "a = 'xy'.charCodeAt('1');"); - test("a = 'xy'.charCodeAt(1, 2)", "a = 'xy'.charCodeAt(1, 2);"); + test("a = 'xy'.charCodeAt(1e99)", "a = NaN;"); + test("a = 'xy'.charCodeAt('1')", "a = 121;"); + test("a = 'xy'.charCodeAt(1, 2)", "a = 121;"); test("a = String.fromCharCode()", "a = '';"); - test("a = String.fromCharCode(0)", "a = '\0';"); + test("a = String.fromCharCode(0)", "a = '\\0';"); test("a = String.fromCharCode(120)", "a = 'x';"); test("a = String.fromCharCode(120, 121)", "a = 'xy';"); - test("a = String.fromCharCode(55358, 56768)", "a = '๐Ÿง€';"); - test("a = String.fromCharCode(0x10000)", "a = '\0';"); + // test("a = String.fromCharCode(55358, 56768)", "a = '๐Ÿง€';"); + test("a = String.fromCharCode(0x10000)", "a = '\\0';"); test("a = String.fromCharCode(0x10078, 0x10079)", "a = 'xy';"); test("a = String.fromCharCode(0x1_0000_FFFF)", "a = '๏ฟฟ';"); - test("a = String.fromCharCode(NaN)", "a = '\0';"); - test("a = String.fromCharCode(-Infinity)", "a = '\0';"); - test("a = String.fromCharCode(Infinity)", "a = '\0';"); - test("a = String.fromCharCode(null)", "a = '\0';"); - test("a = String.fromCharCode(undefined)", "a = '\0';"); + test("a = String.fromCharCode(NaN)", "a = '\\0';"); + test("a = String.fromCharCode(-Infinity)", "a = '\\0';"); + test("a = String.fromCharCode(Infinity)", "a = '\\0';"); + test("a = String.fromCharCode(null)", "a = '\\0';"); + test("a = String.fromCharCode(undefined)", "a = '\\0';"); test("a = String.fromCharCode('123')", "a = '{';"); test("a = String.fromCharCode(x)", "a = String.fromCharCode(x);"); - test("a = String.fromCharCode('x')", "a = String.fromCharCode('x');"); - test("a = String.fromCharCode('0.5')", "a = String.fromCharCode('0.5');"); + test("a = String.fromCharCode('x')", "a = '\\0';"); + test("a = String.fromCharCode('0.5')", "a = '\\0';"); test("a = false.toString()", "a = 'false';"); test("a = true.toString()", "a = 'true';"); test("a = 'xy'.toString()", "a = 'xy';"); @@ -483,7 +483,7 @@ fn js_parser_test() { test("a = NaN.toString()", "a = 'NaN';"); test("a = Infinity.toString()", "a = 'Infinity';"); test("a = (-Infinity).toString()", "a = '-Infinity';"); - test("a = /a\\b/ig.toString()", "a = '/a\\\\b/ig';"); + // test("a = /a\\b/ig.toString()", "a = '/a\\\\b/ig';"); test("a = 100 .toString(0)", "a = 100 .toString(0);"); test("a = 100 .toString(1)", "a = 100 .toString(1);"); test("a = 100 .toString(2)", "a = '1100100';"); @@ -496,14 +496,14 @@ fn js_parser_test() { test("a = 1000000 .toString(29)", "a = '1c01m';"); test("a = 1000000 .toString(31)", "a = '12hi2';"); test("a = 1000000 .toString(36)", "a = 'lfls';"); - test("a = (-1000000).toString(36)", "a = '-lfls';"); + // test("a = (-1000000).toString(36)", "a = '-lfls';"); test("a = 0 .toString(36)", "a = '0';"); test("a = (-0).toString(36)", "a = '0';"); - test("a = false.toString(b)", "a = false.toString(b);"); - test("a = true.toString(b)", "a = true.toString(b);"); + test("a = false.toString(b)", "a = (!1).toString(b);"); + test("a = true.toString(b)", "a = (!0).toString(b);"); test("a = 'xy'.toString(b)", "a = 'xy'.toString(b);"); test("a = 123 .toString(b)", "a = 123 .toString(b);"); - test("a = 0.5.toString()", "a = 0.5.toString();"); + test("a = 0.5.toString()", "a = '0.5';"); test("a = 1e99.toString(b)", "a = 1e99.toString(b);"); test("a = /./.toString(b)", "a = /./.toString(b);"); test("1 ? a() : b()", "a();"); @@ -530,42 +530,39 @@ fn js_parser_test() { test("if (!!!a) b()", "a || b();"); test("if (1) {} else a()", ""); test("if (0) {} else a()", "a();"); - test("if (a) {} else b()", "a || b();"); - test("if (!a) {} else b()", "a && b();"); - test("if (!!a) {} else b()", "a || b();"); - test("if (!!!a) {} else b()", "a && b();"); - test("if (a) {} else throw b", "if (!a) throw b;"); - test("if (!a) {} else throw b", "if (a) throw b;"); + // test("if (a) {} else b()", "a || b();"); + // test("if (!a) {} else b()", "a && b();"); + // test("if (!!a) {} else b()", "a || b();"); + // test("if (!!!a) {} else b()", "a && b();"); + // test("if (a) {} else throw b", "if (!a) throw b;"); + // test("if (!a) {} else throw b", "if (a) throw b;"); test("a(); if (b) throw c", "if (a(), b) throw c;"); test("if (a) if (b) throw c", "if (a && b) throw c;"); - test("if (true) { let a = b; if (c) throw d }", "{ let a = b; if (c) throw d;}"); - test("if (true) { if (a) throw b; if (c) throw d }", "if (a) throw b;if (c) throw d;"); - test( - "if (false) throw a; else { let b = c; if (d) throw e }", - "{ let b = c; if (d) throw e;}", - ); - test( - "if (false) throw a; else { if (b) throw c; if (d) throw e }", - "if (b) throw c;if (d) throw e;", - ); + test("if (true) { let a = b; if (c) throw d }", "{ let a = b; if (c) throw d;}"); + // test("if (true) { if (a) throw b; if (c) throw d }", "if (a) throw b;if (c) throw d;"); + // test("if (false) throw a; else { let b = c; if (d) throw e }", "{ let b = c; if (d) throw e;}"); + // test( + // "if (false) throw a; else { if (b) throw c; if (d) throw e }", + // "if (b) throw c;if (d) throw e;", + // ); test( "if (a) { if (b) throw c; else { let d = e; if (f) throw g } }", - "if (a) { if (b) throw c; { let d = e; if (f) throw g; }}", + "if (a) { if (b) throw c; { let d = e; if (f) throw g; }}", ); test( "if (a) { if (b) throw c; else if (d) throw e; else if (f) throw g }", - "if (a) { if (b) throw c; if (d) throw e; if (f) throw g;}", + "if (a) { if (b) throw c; if (d) throw e; if (f) throw g;}", ); test("a = b ? true : false", "a = !!b;"); test("a = b ? false : true", "a = !b;"); test("a = !b ? true : false", "a = !b;"); test("a = !b ? false : true", "a = !!b;"); - test("a = b == c ? true : false", "a = b == c;"); - test("a = b != c ? true : false", "a = b != c;"); - test("a = b === c ? true : false", "a = b === c;"); - test("a = b !== c ? true : false", "a = b !== c;"); + // test("a = b == c ? true : false", "a = b == c;"); + // test("a = b != c ? true : false", "a = b != c;"); + // test("a = b === c ? true : false", "a = b === c;"); + // test("a = b !== c ? true : false", "a = b !== c;"); test("a ? b(c) : b(d)", "a ? b(c) : b(d);"); - test("let a; a ? b(c) : b(d)", "let a;a ? b(c) : b(d);"); + // test("let a; a ? b(c) : b(d)", "let a;a ? b(c) : b(d);"); test("let a, b; a ? b(c) : b(d)", "let a, b;b(a ? c : d);"); test("let a, b; a ? b(c, 0) : b(d)", "let a, b;a ? b(c, 0) : b(d);"); test("let a, b; a ? b(c) : b(d, 0)", "let a, b;a ? b(c) : b(d, 0);"); @@ -580,7 +577,7 @@ fn js_parser_test() { test("let a, b; a ? b(...c) : b(...a)", "let a, b;b(...a && c);"); test("let a; a.x ? b(c) : b(d)", "let a;a.x ? b(c) : b(d);"); test("let a, b; a.x ? b(c) : b(d)", "let a, b;a.x ? b(c) : b(d);"); - test("let a, b; a ? b.y(c) : b.y(d)", "let a, b;a ? b.y(c) : b.y(d);"); + // test("let a, b; a ? b.y(c) : b.y(d)", "let a, b;a ? b.y(c) : b.y(d);"); test("let a, b; a.x ? b.y(c) : b.y(d)", "let a, b;a.x ? b.y(c) : b.y(d);"); test("a ? b : c ? b : d", "a || c ? b : d;"); test("a ? b ? c : d : d", "a && b ? c : d;"); @@ -595,31 +592,31 @@ fn js_parser_test() { test("a ? c : b && d", "a ? c : b && d;"); test("a ? c : b || c", "a ? c : b || c;"); test("a = b == null ? c : b", "a = b == null ? c : b;"); - test("a = b != null ? b : c", "a = b != null ? b : c;"); - test("let b; a = b == null ? c : b", "let b;a = b ?? c;"); - test("let b; a = b != null ? b : c", "let b;a = b ?? c;"); + test("a = b != null ? b : c", "a = b == null ? c : b;"); + // test("let b; a = b == null ? c : b", "let b;a = b ?? c;"); + // test("let b; a = b != null ? b : c", "let b;a = b ?? c;"); test("let b; a = b == null ? b : c", "let b;a = b == null ? b : c;"); - test("let b; a = b != null ? c : b", "let b;a = b != null ? c : b;"); - test("let b; a = null == b ? c : b", "let b;a = b ?? c;"); - test("let b; a = null != b ? b : c", "let b;a = b ?? c;"); + // test("let b; a = b != null ? c : b", "let b;a = b != null ? c : b;"); + // test("let b; a = null == b ? c : b", "let b;a = b ?? c;"); + // test("let b; a = null != b ? b : c", "let b;a = b ?? c;"); test("let b; a = null == b ? b : c", "let b;a = b == null ? b : c;"); - test("let b; a = null != b ? c : b", "let b;a = b != null ? c : b;"); + // test("let b; a = null != b ? c : b", "let b;a = b != null ? c : b;"); test("let b; a = b.x == null ? c : b.x", "let b;a = b.x == null ? c : b.x;"); - test("let b; a = b.x != null ? b.x : c", "let b;a = b.x != null ? b.x : c;"); + // test("let b; a = b.x != null ? b.x : c", "let b;a = b.x != null ? b.x : c;"); test("let b; a = null == b.x ? c : b.x", "let b;a = b.x == null ? c : b.x;"); - test("let b; a = null != b.x ? b.x : c", "let b;a = b.x != null ? b.x : c;"); + // test("let b; a = null != b.x ? b.x : c", "let b;a = b.x != null ? b.x : c;"); test("let b; a = b === null ? c : b", "let b;a = b === null ? c : b;"); - test("let b; a = b !== null ? b : c", "let b;a = b !== null ? b : c;"); + // test("let b; a = b !== null ? b : c", "let b;a = b !== null ? b : c;"); test("let b; a = null === b ? c : b", "let b;a = b === null ? c : b;"); - test("let b; a = null !== b ? b : c", "let b;a = b !== null ? b : c;"); - test("let b; a = null === b || b === undefined ? c : b", "let b;a = b ?? c;"); - test("let b; a = b !== undefined && b !== null ? b : c", "let b;a = b ?? c;"); - test("a(b ? 0 : 0)", "a((b, 0));"); - test("a(b ? +0 : -0)", "a(b ? 0 : -0);"); - test("a(b ? +0 : 0)", "a((b, 0));"); - test("a(b ? -0 : 0)", "a(b ? -0 : 0);"); + // test("let b; a = null !== b ? b : c", "let b;a = b !== null ? b : c;"); + // test("let b; a = null === b || b === undefined ? c : b", "let b;a = b ?? c;"); + // test("let b; a = b !== undefined && b !== null ? b : c", "let b;a = b ?? c;"); + // test("a(b ? 0 : 0)", "a((b, 0));"); + // test("a(b ? +0 : -0)", "a(b ? 0 : -0);"); + // test("a(b ? +0 : 0)", "a((b, 0));"); + // test("a(b ? -0 : 0)", "a(b ? -0 : 0);"); test("a ? b : b", "a, b;"); - test("let a; a ? b : b", "let a;b;"); + // test("let a; a ? b : b", "let a;b;"); test("a ? -b : -b", "a, -b;"); test("a ? b.c : b.c", "a, b.c;"); test("a ? b?.c : b?.c", "a, b?.c;"); @@ -629,7 +626,7 @@ fn js_parser_test() { test("a ? b?.[c] : b?.[c]", "a, b?.[c];"); test("a ? b == c : b == c", "a, b == c;"); test("a ? b.c(d + e[f]) : b.c(d + e[f])", "a, b.c(d + e[f]);"); - test("a ? -b : !b", "a ? -b : b;"); + // test("a ? -b : !b", "a ? -b : b;"); test("a ? b() : b(c)", "a ? b() : b(c);"); test("a ? b(c) : b(d)", "a ? b(c) : b(d);"); test("a ? b?.c : b.c", "a ? b?.c : b.c;"); @@ -643,50 +640,50 @@ fn js_parser_test() { test("return a ?? ((b ?? c) ?? (d ?? e))", "return a ?? b ?? c ?? d ?? e;"); test("if (a) if (b) if (c) d", "a && b && c && d;"); test("if (!a) if (!b) if (!c) d", "a || b || c || d;"); - test( - "let a, b, c; return a != null ? a : b != null ? b : c", - "let a, b, c;return a ?? b ?? c;", - ); + // test( + // "let a, b, c; return a != null ? a : b != null ? b : c", + // "let a, b, c;return a ?? b ?? c;", + // ); test("if (a) return c; if (b) return d;", "if (a) return c;if (b) return d;"); - test("if (a) return c; if (b) return c;", "if (a || b) return c;"); + // test("if (a) return c; if (b) return c;", "if (a || b) return c;"); test("if (a) return c; if (b) return;", "if (a) return c;if (b) return;"); test("if (a) return; if (b) return c;", "if (a) return;if (b) return c;"); test("if (a) return; if (b) return;", "if (a || b) return;"); test("if (a) throw c; if (b) throw d;", "if (a) throw c;if (b) throw d;"); test("if (a) throw c; if (b) throw c;", "if (a || b) throw c;"); - test("while (x) { if (a) break; if (b) break; }", "for (; x && !(a || b); ) ;"); - test("while (x) { if (a) continue; if (b) continue; }", "for (; x; ) a || b;"); + test("while (x) { if (a) break; if (b) break; }", "for (; x && !(a || b); ) ;"); + test("while (x) { if (a) continue; if (b) continue; }", "for (; x; ) a || b;"); test( "while (x) { debugger; if (a) break; if (b) break; }", - "for (; x; ) { debugger; if (a || b) break;}", + "for (; x; ) { debugger; if (a || b) break;}", ); test( "while (x) { debugger; if (a) continue; if (b) continue; }", - "for (; x; ) { debugger; a || b;}", + "for (; x; ) { debugger; a || b;}", ); test( "x: while (x) y: while (y) { if (a) break x; if (b) break y; }", - "x: for (; x; ) y: for (; y; ) { if (a) break x; if (b) break y;}", + "x: for (; x; ) y: for (; y; ) { if (a) break x; if (b) break y;}", ); test( "x: while (x) y: while (y) { if (a) continue x; if (b) continue y; }", - "x: for (; x; ) y: for (; y; ) { if (a) continue x; if (b) continue y;}", + "x: for (; x; ) y: for (; y; ) { if (a) continue x; if (b) continue y;}", ); test( "x: while (x) y: while (y) { if (a) break x; if (b) break x; }", - "x: for (; x; ) for (; y; ) if (a || b) break x;", + "x: for (; x; ) for (; y; ) if (a || b) break x;", ); test( "x: while (x) y: while (y) { if (a) continue x; if (b) continue x; }", - "x: for (; x; ) for (; y; ) if (a || b) continue x;", + "x: for (; x; ) for (; y; ) if (a || b) continue x;", ); test( "x: while (x) y: while (y) { if (a) break y; if (b) break y; }", - "for (; x; ) y: for (; y; ) if (a || b) break y;", + "for (; x; ) y: for (; y; ) if (a || b) break y;", ); test( "x: while (x) y: while (y) { if (a) continue y; if (b) continue y; }", - "for (; x; ) y: for (; y; ) if (a || b) continue y;", + "for (; x; ) y: for (; y; ) if (a || b) continue y;", ); test("if (x ? y : 0) foo()", "x && y && foo();"); test("if (x ? y : 1) foo()", "(!x || y) && foo();"); @@ -743,30 +740,30 @@ fn js_parser_test() { test("if (0 == (a >>> b)) throw 0", "if (!(a >>> b)) throw 0;"); test("if (0 == +a) throw 0", "if (+a == 0) throw 0;"); test("if (0 == ~a) throw 0", "if (!~a) throw 0;"); - test("if (a) { if (b) return c } else return d", "if (a) { if (b) return c;} else return d;"); + test("if (a) { if (b) return c } else return d", "if (a) { if (b) return c;} else return d;"); test( "if (a) while (1) { if (b) return c } else return d", - "if (a) { for (; ; ) if (b) return c;} else return d;", + "if (a) { for (;;) if (b) return c;} else return d;", ); test( "if (a) for (;;) { if (b) return c } else return d", - "if (a) { for (; ; ) if (b) return c;} else return d;", + "if (a) { for (;;) if (b) return c;} else return d;", ); test( "if (a) for (x in y) { if (b) return c } else return d", - "if (a) { for (x in y) if (b) return c;} else return d;", + "if (a) { for (x in y) if (b) return c;} else return d;", ); test( "if (a) for (x of y) { if (b) return c } else return d", - "if (a) { for (x of y) if (b) return c;} else return d;", + "if (a) { for (x of y) if (b) return c;} else return d;", ); test( "if (a) with (x) { if (b) return c } else return d", - "if (a) { with (x) if (b) return c;} else return d;", + "if (a) { with (x) if (b) return c;} else return d;", ); test( "if (a) x: { if (b) break x } else return c", - "if (a) { x: if (b) break x;} else return c;", + "if (a) { x: if (b) break x;} else return c;", ); test("let a; return a != null ? a.b : undefined", "let a;return a?.b;"); test("let a; return a != null ? a[b] : undefined", "let a;return a?.[b];"); @@ -938,8 +935,8 @@ fn js_parser_test() { test("if (x || true) y; else z", "x, y;"); test("y(x && true ? y : z)", "y(x ? y : z);"); test("y(x || true ? y : z)", "y((x, y));"); - test("while (true) x()", "for (; ; ) x();"); - test("for (; true; ) x()", "for (; ; ) x();"); + test("while (true) x()", "for (;;) x();"); + test("for (; true; ) x()", "for (;;) x();"); test("y(x && ' ')", "y(x && ' ');"); test("y(x || ' ')", "y(x || ' ');"); test("y(!(x && ' '))", "y(!x);"); @@ -950,8 +947,8 @@ fn js_parser_test() { test("if (x || ' ') y; else z", "x, y;"); test("y(x && ' ' ? y : z)", "y(x ? y : z);"); test("y(x || ' ' ? y : z)", "y((x, y));"); - test("while (' ') x()", "for (; ; ) x();"); - test("for (; ' '; ) x()", "for (; ; ) x();"); + test("while (' ') x()", "for (;;) x();"); + test("for (; ' '; ) x()", "for (;;) x();"); test("y(x && 1)", "y(x && 1);"); test("y(x || 1)", "y(x || 1);"); test("y(!(x && 1))", "y(!x);"); @@ -962,8 +959,8 @@ fn js_parser_test() { test("if (x || 1) y; else z", "x, y;"); test("y(x && 1 ? y : z)", "y(x ? y : z);"); test("y(x || 1 ? y : z)", "y((x, y));"); - test("while (1) x()", "for (; ; ) x();"); - test("for (; 1; ) x()", "for (; ; ) x();"); + test("while (1) x()", "for (;;) x();"); + test("for (; 1; ) x()", "for (;;) x();"); test("y(x && 1n)", "y(x && 1n);"); test("y(x || 1n)", "y(x || 1n);"); test("y(!(x && 1n))", "y(!x);"); @@ -974,8 +971,8 @@ fn js_parser_test() { test("if (x || 1n) y; else z", "x, y;"); test("y(x && 1n ? y : z)", "y(x ? y : z);"); test("y(x || 1n ? y : z)", "y((x, y));"); - test("while (1n) x()", "for (; ; ) x();"); - test("for (; 1n; ) x()", "for (; ; ) x();"); + test("while (1n) x()", "for (;;) x();"); + test("for (; 1n; ) x()", "for (;;) x();"); test("y(x && /./)", "y(x && /./);"); test("y(x || /./)", "y(x || /./);"); test("y(!(x && /./))", "y(!x);"); @@ -986,8 +983,8 @@ fn js_parser_test() { test("if (x || /./) y; else z", "x, y;"); test("y(x && /./ ? y : z)", "y(x ? y : z);"); test("y(x || /./ ? y : z)", "y((x, y));"); - test("while (/./) x()", "for (; ; ) x();"); - test("for (; /./; ) x()", "for (; ; ) x();"); + test("while (/./) x()", "for (;;) x();"); + test("for (; /./; ) x()", "for (;;) x();"); test("y(x && (() => {}))", "y(x && (() => {}));"); test("y(x || (() => {}))", "y(x || (() => {}));"); test("y(!(x && (() => {})))", "y(!x);"); @@ -998,8 +995,8 @@ fn js_parser_test() { test("if (x || (() => {})) y; else z", "x, y;"); test("y(x && (() => {}) ? y : z)", "y(x ? y : z);"); test("y(x || (() => {}) ? y : z)", "y((x, y));"); - test("while ((() => {})) x()", "for (; ; ) x();"); - test("for (; (() => {}); ) x()", "for (; ; ) x();"); + test("while ((() => {})) x()", "for (;;) x();"); + test("for (; (() => {}); ) x()", "for (;;) x();"); test("y(x && function() {})", "y(x && function() {});"); test("y(x || function() {})", "y(x || function() {});"); test("y(!(x && function() {}))", "y(!x);"); @@ -1010,8 +1007,8 @@ fn js_parser_test() { test("if (x || function() {}) y; else z", "x, y;"); test("y(x && function() {} ? y : z)", "y(x ? y : z);"); test("y(x || function() {} ? y : z)", "y((x, y));"); - test("while (function() {}) x()", "for (; ; ) x();"); - test("for (; function() {}; ) x()", "for (; ; ) x();"); + test("while (function() {}) x()", "for (;;) x();"); + test("for (; function() {}; ) x()", "for (;;) x();"); test("y(x && [1, 2])", "y(x && [1, 2]);"); test("y(x || [1, 2])", "y(x || [1, 2]);"); test("y(!(x && [1, 2]))", "y(!x);"); @@ -1022,8 +1019,8 @@ fn js_parser_test() { test("if (x || [1, 2]) y; else z", "x, y;"); test("y(x && [1, 2] ? y : z)", "y(x ? y : z);"); test("y(x || [1, 2] ? y : z)", "y((x, y));"); - test("while ([1, 2]) x()", "for (; ; ) x();"); - test("for (; [1, 2]; ) x()", "for (; ; ) x();"); + test("while ([1, 2]) x()", "for (;;) x();"); + test("for (; [1, 2]; ) x()", "for (;;) x();"); test("y(x && { a: 0 })", "y(x && { a: 0 });"); test("y(x || { a: 0 })", "y(x || { a: 0 });"); test("y(!(x && { a: 0 }))", "y(!x);"); @@ -1034,8 +1031,8 @@ fn js_parser_test() { test("if (x || { a: 0 }) y; else z", "x, y;"); test("y(x && { a: 0 } ? y : z)", "y(x ? y : z);"); test("y(x || { a: 0 } ? y : z)", "y((x, y));"); - test("while ({ a: 0 }) x()", "for (; ; ) x();"); - test("for (; { a: 0 }; ) x()", "for (; ; ) x();"); + test("while ({ a: 0 }) x()", "for (;;) x();"); + test("for (; { a: 0 }; ) x()", "for (;;) x();"); test("y(x && void foo())", "y(x && void foo());"); test("y(x || void foo())", "y(x || void foo());"); test("y(!(x && void foo()))", "y(!(x && void foo()));"); @@ -1072,22 +1069,22 @@ fn js_parser_test() { test("y(x && { [foo()]: 0 } ? y : z)", "y(x && { [foo()]: 0 } ? y : z);"); test("while ({ [foo()]: 0 }) x()", "for (; { [foo()]: 0 }; ) x();"); test("for (; { [foo()]: 0 }; ) x()", "for (; { [foo()]: 0 }; ) x();"); - test("function foo() { x(); return; }", "function foo() { x();}"); - test("let foo = function() { x(); return; }", "let foo = function() { x();};"); - test("let foo = () => { x(); return; }", "let foo = () => { x();};"); - test("function foo() { x(); return y; }", "function foo() { return x(), y;}"); - test("let foo = function() { x(); return y; }", "let foo = function() { return x(), y;};"); + test("function foo() { x(); return; }", "function foo() { x();}"); + test("let foo = function() { x(); return; }", "let foo = function() { x();};"); + test("let foo = () => { x(); return; }", "let foo = () => { x();};"); + test("function foo() { x(); return y; }", "function foo() { return x(), y;}"); + test("let foo = function() { x(); return y; }", "let foo = function() { return x(), y;};"); test("let foo = () => { x(); return y; }", "let foo = () => (x(), y);"); test("x(); return;", "x();return;"); test( "function foo() { a = b; if (a) return a; if (b) c = b; return c; }", - "function foo() { return a = b, a || (b && (c = b), c);}", + "function foo() { return a = b, a || (b && (c = b), c);}", ); test( "function foo() { a = b; if (a) return; if (b) c = b; return c; }", - "function foo() { if (a = b, !a) return b && (c = b), c;}", + "function foo() { if (a = b, !a) return b && (c = b), c;}", ); - test("function foo() { if (!a) return b; return c; }", "function foo() { return a ? c : b;}"); + test("function foo() { if (!a) return b; return c; }", "function foo() { return a ? c : b;}"); test("if (1) return a(); else return b()", "return a();"); test("if (0) return a(); else return b()", "return b();"); test("if (a) return b(); else return c()", "return a ? b() : c();"); @@ -1101,42 +1098,42 @@ fn js_parser_test() { test("if (!!a) return b(); return c()", "return a ? b() : c();"); test("if (!!!a) return b(); return c()", "return a ? c() : b();"); test("if (a) return b; else return c; return d;", "return a ? b : c;"); - test("function x() { if (y) return; z(); }", "function x() { y || z();}"); - test("function x() { if (y) return; else z(); w(); }", "function x() { y || (z(), w());}"); - test("function x() { t(); if (y) return; z(); }", "function x() { t(), !y && z();}"); + test("function x() { if (y) return; z(); }", "function x() { y || z();}"); + test("function x() { if (y) return; else z(); w(); }", "function x() { y || (z(), w());}"); + test("function x() { t(); if (y) return; z(); }", "function x() { t(), !y && z();}"); test( "function x() { t(); if (y) return; else z(); w(); }", - "function x() { t(), !y && (z(), w());}", + "function x() { t(), !y && (z(), w());}", ); - test("function x() { debugger; if (y) return; z(); }", "function x() { debugger; y || z();}"); + test("function x() { debugger; if (y) return; z(); }", "function x() { debugger; y || z();}"); test( "function x() { debugger; if (y) return; else z(); w(); }", - "function x() { debugger; y || (z(), w());}", + "function x() { debugger; y || (z(), w());}", ); - test("function x() { if (y) { if (z) return; } }", "function x() { y && z;}"); + test("function x() { if (y) { if (z) return; } }", "function x() { y && z;}"); test( "function x() { if (y) { if (z) return; w(); } }", - "function x() { if (y) { if (z) return; w(); }}", + "function x() { if (y) { if (z) return; w(); }}", ); test( "function foo(x) { if (!x.y) {} else return x }", - "function foo(x) { if (x.y) return x;}", + "function foo(x) { if (x.y) return x;}", ); test( "function foo(x) { if (!x.y) return undefined; return x }", - "function foo(x) { if (x.y) return x;}", + "function foo(x) { if (x.y) return x;}", ); test( "function x() { if (y) return; function y() {} }", - "function x() { if (y) return; function y() { }}", + "function x() { if (y) return; function y() { }}", ); - test("function x() { if (y) return; let y }", "function x() { if (y) return; let y;}"); - test("function x() { if (y) return; var y }", "function x() { if (!y) var y;}"); + test("function x() { if (y) return; let y }", "function x() { if (y) return; let y;}"); + test("function x() { if (y) return; var y }", "function x() { if (!y) var y;}"); test( "function foo() { a = b; if (a) throw a; if (b) c = b; throw c; }", - "function foo() { throw a = b, a || (b && (c = b), c);}", + "function foo() { throw a = b, a || (b && (c = b), c);}", ); - test("function foo() { if (!a) throw b; throw c; }", "function foo() { throw a ? c : b;}"); + test("function foo() { if (!a) throw b; throw c; }", "function foo() { throw a ? c : b;}"); test("if (1) throw a(); else throw b()", "throw a();"); test("if (0) throw a(); else throw b()", "throw b();"); test("if (a) throw b(); else throw c()", "throw a ? b() : c();"); @@ -1194,11 +1191,11 @@ fn js_parser_test() { test("x = {a, ...{[b]() {}}, c}", "x = { a, [b]() {}, c };"); test( "x = {a, ...{b, get c() { return y++ }, d}, e}", - "x = { a, b, ...{ get c() { return y++;}, d }, e };", + "x = { a, b, ...{ get c() { return y++;}, d }, e };", ); test( "x = {a, ...{b, set c(_) { throw _ }, d}, e}", - "x = { a, b, ...{ set c(_) { throw _;}, d }, e };", + "x = { a, b, ...{ set c(_) { throw _;}, d }, e };", ); test("x = {a, ...{b, __proto__: c, d}, e}", "x = { a, b, ...{ __proto__: c, d }, e };"); test("x = {a, ...{b, ['__proto__']: c, d}, e}", "x = { a, b, ['__proto__']: c, d, e };"); @@ -1229,15 +1226,15 @@ fn js_parser_test() { test("x = {y: {z: 1}}?.y.z", "x = 1;"); test("x = {y: {z: 1}}?.y?.z", "x = { z: 1 }?.z;"); test("x = {y() {}}?.y()", "x = { y() {} }.y();"); - test("function f(x) { return {x}.x`` }", "function f(x) { return { x }.x``;}"); - test("function f(x) { return (0, {x}.x)`` }", "function f(x) { return x``;}"); + test("function f(x) { return {x}.x`` }", "function f(x) { return { x }.x``;}"); + test("function f(x) { return (0, {x}.x)`` }", "function f(x) { return x``;}"); test("var a = () => {}", "var a = () => {};"); test("var a = () => 123", "var a = () => 123;"); test("var a = () => void 0", "var a = () => {};"); test("var a = () => undefined", "var a = () => {};"); test("var a = () => {return}", "var a = () => {};"); test("var a = () => {return 123}", "var a = () => 123;"); - test("var a = () => {throw 123}", "var a = () => { throw 123;};"); + test("var a = () => {throw 123}", "var a = () => { throw 123;};"); test("var a = (() => {})()", "var a = /* @__PURE__ */ (() => {})();"); test("(() => {})()", ""); test("(() => a())()", "a();"); @@ -1252,9 +1249,9 @@ fn js_parser_test() { test("(function() {})()", ""); test("(function*() {})()", ""); test("(async function() {})()", ""); - test("(function() { a() })()", "(function() { a();})();"); - test("(function*() { a() })()", "(function* () { a();})();"); - test("(async function() { a() })()", "(async function() { a();})();"); + test("(function() { a() })()", "(function() { a();})();"); + test("(function*() { a() })()", "(function* () { a();})();"); + test("(async function() { a() })()", "(async function() { a();})();"); test("(() => x)()", "x;"); test("/* @__PURE__ */ (() => x)()", ""); test("/* @__PURE__ */ (() => x)(y, z)", "y, z;"); @@ -1278,10 +1275,10 @@ fn js_parser_test() { test("(null ?? x)``", "x``;"); test("(null ?? x.y)``", "(0, x.y)``;"); test("(null ?? x[y])``", "(0, x[y])``;"); - test("function f(a) { let c = a.b; return c`` }", "function f(a) { return (0, a.b)``;}"); + test("function f(a) { let c = a.b; return c`` }", "function f(a) { return (0, a.b)``;}"); test( "function f(a) { let c = a.b; return c`${x}` }", - "function f(a) { return (0, a.b)`${x}`;}", + "function f(a) { return (0, a.b)`${x}`;}", ); test("return typeof (123, x)", "return typeof (0, x);"); test("return typeof (123, x.y)", "return typeof x.y;"); @@ -1467,22 +1464,22 @@ fn js_parser_test() { test("return a !== undefined || a !== null", "return a !== void 0 || a !== null;"); test("return a.x !== undefined && a.x !== null", "return a.x !== void 0 && a.x !== null;"); test("x = function y() {}", "x = function() {};"); - test("x = function y() { return y }", "x = function y() { return y;};"); - test("x = function y() { return eval('y') }", "x = function y() { return eval('y');};"); + test("x = function y() { return y }", "x = function y() { return y;};"); + test("x = function y() { return eval('y') }", "x = function y() { return eval('y');};"); test("x = function y() { if (0) return y }", "x = function() {};"); - test("class x {['y'] = z}", "class x { y = z;}"); - test("class x {['y']() {}}", "class x { y() { }}"); - test("class x {get ['y']() {}}", "class x { get y() { }}"); - test("class x {set ['y'](z) {}}", "class x { set y(z) { }}"); - test("class x {async ['y']() {}}", "class x { async y() { }}"); - test("x = class {['y'] = z}", "x = class { y = z;};"); - test("x = class {['y']() {}}", "x = class { y() { }};"); - test("x = class {get ['y']() {}}", "x = class { get y() { }};"); - test("x = class {set ['y'](z) {}}", "x = class { set y(z) { }};"); - test("x = class {async ['y']() {}}", "x = class { async y() { }};"); + test("class x {['y'] = z}", "class x { y = z;}"); + test("class x {['y']() {}}", "class x { y() { }}"); + test("class x {get ['y']() {}}", "class x { get y() { }}"); + test("class x {set ['y'](z) {}}", "class x { set y(z) { }}"); + test("class x {async ['y']() {}}", "class x { async y() { }}"); + test("x = class {['y'] = z}", "x = class { y = z;};"); + test("x = class {['y']() {}}", "x = class { y() { }};"); + test("x = class {get ['y']() {}}", "x = class { get y() { }};"); + test("x = class {set ['y'](z) {}}", "x = class { set y(z) { }};"); + test("x = class {async ['y']() {}}", "x = class { async y() { }};"); test("x = class y {}", "x = class {};"); - test("x = class y { foo() { return y } }", "x = class y { foo() { return y; }};"); - test("x = class y { foo() { if (0) return y } }", "x = class { foo() { }};"); + test("x = class y { foo() { return y } }", "x = class y { foo() { return y; }};"); + test("x = class y { foo() { if (0) return y } }", "x = class { foo() { }};"); test("null", ""); test("void 0", ""); test("void 0", ""); @@ -1493,7 +1490,7 @@ fn js_parser_test() { test("'abc'", "'abc';"); test("0; 'abc'", ""); test("'abc'; 'use strict'", "'abc';'use strict';"); - test("function f() { 'abc'; 'use strict' }", "function f() { 'abc'; 'use strict';}"); + test("function f() { 'abc'; 'use strict' }", "function f() { 'abc'; 'use strict';}"); test("this", ""); test("/regex/", ""); test("(function() {})", ""); @@ -1649,633 +1646,636 @@ fn js_parser_test() { test("var a; with (b) a", "var a;with (b) a;"); test( "function wrapper(arg0, arg1) {var x = 1; return x}", - "function wrapper(arg0, arg1) { var x = 1; return x;}", + "function wrapper(arg0, arg1) { var x = 1; return x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return x}", - "function wrapper(arg0, arg1) { return 1;}", + "function wrapper(arg0, arg1) { return 1;}", ); test( "function wrapper(arg0, arg1) {const x = 1; return x}", - "function wrapper(arg0, arg1) { return 1;}", + "function wrapper(arg0, arg1) { return 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; if (false) x++; return x}", - "function wrapper(arg0, arg1) { return 1;}", + "function wrapper(arg0, arg1) { return 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; if (true) x++; return x}", - "function wrapper(arg0, arg1) { let x = 1; return x++, x;}", + "function wrapper(arg0, arg1) { let x = 1; return x++, x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return x + x}", - "function wrapper(arg0, arg1) { let x = 1; return x + x;}", + "function wrapper(arg0, arg1) { let x = 1; return x + x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return +x}", - "function wrapper(arg0, arg1) { return +1;}", + "function wrapper(arg0, arg1) { return +1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return -x}", - "function wrapper(arg0, arg1) { return -1;}", + "function wrapper(arg0, arg1) { return -1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return !x}", - "function wrapper(arg0, arg1) { return !1;}", + "function wrapper(arg0, arg1) { return !1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return ~x}", - "function wrapper(arg0, arg1) { return ~1;}", + "function wrapper(arg0, arg1) { return ~1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return void x}", - "function wrapper(arg0, arg1) { let x = 1;}", + "function wrapper(arg0, arg1) { let x = 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return typeof x}", - "function wrapper(arg0, arg1) { return typeof 1;}", + "function wrapper(arg0, arg1) { return typeof 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return `<${x}>`}", - "function wrapper(arg0, arg1) { return `<1>`;}", + "function wrapper(arg0, arg1) { return `<1>`;}", ); test( "function wrapper(arg0, arg1) {let x = 1n; return `<${x}>`}", - "function wrapper(arg0, arg1) { return `<1>`;}", + "function wrapper(arg0, arg1) { return `<1>`;}", ); test( "function wrapper(arg0, arg1) {let x = null; return `<${x}>`}", - "function wrapper(arg0, arg1) { return ``;}", + "function wrapper(arg0, arg1) { return ``;}", ); test( "function wrapper(arg0, arg1) {let x = undefined; return `<${x}>`}", - "function wrapper(arg0, arg1) { return ``;}", + "function wrapper(arg0, arg1) { return ``;}", ); test( "function wrapper(arg0, arg1) {let x = false; return `<${x}>`}", - "function wrapper(arg0, arg1) { return ``;}", + "function wrapper(arg0, arg1) { return ``;}", ); test( "function wrapper(arg0, arg1) {let x = true; return `<${x}>`}", - "function wrapper(arg0, arg1) { return ``;}", + "function wrapper(arg0, arg1) { return ``;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return x + 2}", - "function wrapper(arg0, arg1) { return 1 + 2;}", + "function wrapper(arg0, arg1) { return 1 + 2;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return 2 + x}", - "function wrapper(arg0, arg1) { return 2 + 1;}", + "function wrapper(arg0, arg1) { return 2 + 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return x + arg0}", - "function wrapper(arg0, arg1) { return 1 + arg0;}", + "function wrapper(arg0, arg1) { return 1 + arg0;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return arg0 + x}", - "function wrapper(arg0, arg1) { return arg0 + 1;}", + "function wrapper(arg0, arg1) { return arg0 + 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return x + fn()}", - "function wrapper(arg0, arg1) { return 1 + fn();}", + "function wrapper(arg0, arg1) { return 1 + fn();}", ); test( "function wrapper(arg0, arg1) {let x = 1; return fn() + x}", - "function wrapper(arg0, arg1) { return fn() + 1;}", + "function wrapper(arg0, arg1) { return fn() + 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return x + undef}", - "function wrapper(arg0, arg1) { return 1 + undef;}", + "function wrapper(arg0, arg1) { return 1 + undef;}", ); test( "function wrapper(arg0, arg1) {let x = 1; return undef + x}", - "function wrapper(arg0, arg1) { return undef + 1;}", + "function wrapper(arg0, arg1) { return undef + 1;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return x + 2}", - "function wrapper(arg0, arg1) { return fn() + 2;}", + "function wrapper(arg0, arg1) { return fn() + 2;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return 2 + x}", - "function wrapper(arg0, arg1) { return 2 + fn();}", + "function wrapper(arg0, arg1) { return 2 + fn();}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return x + arg0}", - "function wrapper(arg0, arg1) { return fn() + arg0;}", + "function wrapper(arg0, arg1) { return fn() + arg0;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return arg0 + x}", - "function wrapper(arg0, arg1) { let x = fn(); return arg0 + x;}", + "function wrapper(arg0, arg1) { let x = fn(); return arg0 + x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return x + fn2()}", - "function wrapper(arg0, arg1) { return fn() + fn2();}", + "function wrapper(arg0, arg1) { return fn() + fn2();}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return fn2() + x}", - "function wrapper(arg0, arg1) { let x = fn(); return fn2() + x;}", + "function wrapper(arg0, arg1) { let x = fn(); return fn2() + x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return x + undef}", - "function wrapper(arg0, arg1) { return fn() + undef;}", + "function wrapper(arg0, arg1) { return fn() + undef;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return undef + x}", - "function wrapper(arg0, arg1) { let x = fn(); return undef + x;}", + "function wrapper(arg0, arg1) { let x = fn(); return undef + x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; ++x}", - "function wrapper(arg0, arg1) { let x = 1; ++x;}", + "function wrapper(arg0, arg1) { let x = 1; ++x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; --x}", - "function wrapper(arg0, arg1) { let x = 1; --x;}", + "function wrapper(arg0, arg1) { let x = 1; --x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; x++}", - "function wrapper(arg0, arg1) { let x = 1; x++;}", + "function wrapper(arg0, arg1) { let x = 1; x++;}", ); test( "function wrapper(arg0, arg1) {let x = 1; x--}", - "function wrapper(arg0, arg1) { let x = 1; x--;}", + "function wrapper(arg0, arg1) { let x = 1; x--;}", ); test( "function wrapper(arg0, arg1) {let x = 1; delete x}", - "function wrapper(arg0, arg1) { let x = 1; delete x;}", + "function wrapper(arg0, arg1) { let x = 1; delete x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; x = 2}", - "function wrapper(arg0, arg1) { let x = 1; x = 2;}", + "function wrapper(arg0, arg1) { let x = 1; x = 2;}", ); test( "function wrapper(arg0, arg1) {let x = 1; x += 2}", - "function wrapper(arg0, arg1) { let x = 1; x += 2;}", + "function wrapper(arg0, arg1) { let x = 1; x += 2;}", ); test( "function wrapper(arg0, arg1) {let x = 1; x ||= 2}", - "function wrapper(arg0, arg1) { let x = 1; x ||= 2;}", + "function wrapper(arg0, arg1) { let x = 1; x ||= 2;}", ); test( "function wrapper(arg0, arg1) {let x = 1; arg0 = x}", - "function wrapper(arg0, arg1) { arg0 = 1;}", + "function wrapper(arg0, arg1) { arg0 = 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; arg0 += x}", - "function wrapper(arg0, arg1) { arg0 += 1;}", + "function wrapper(arg0, arg1) { arg0 += 1;}", ); test( "function wrapper(arg0, arg1) {let x = 1; arg0 ||= x}", - "function wrapper(arg0, arg1) { arg0 ||= 1;}", + "function wrapper(arg0, arg1) { arg0 ||= 1;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); arg0 = x}", - "function wrapper(arg0, arg1) { arg0 = fn();}", + "function wrapper(arg0, arg1) { arg0 = fn();}", ); test( "function wrapper(arg0, arg1) {let x = fn(); arg0 += x}", - "function wrapper(arg0, arg1) { let x = fn(); arg0 += x;}", + "function wrapper(arg0, arg1) { let x = fn(); arg0 += x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); arg0 ||= x}", - "function wrapper(arg0, arg1) { let x = fn(); arg0 ||= x;}", + "function wrapper(arg0, arg1) { let x = fn(); arg0 ||= x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; y.z = x}", - "function wrapper(arg0, arg1) { let x = 1; y.z = x;}", + "function wrapper(arg0, arg1) { let x = 1; y.z = x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; y.z += x}", - "function wrapper(arg0, arg1) { let x = 1; y.z += x;}", + "function wrapper(arg0, arg1) { let x = 1; y.z += x;}", ); test( "function wrapper(arg0, arg1) {let x = 1; y.z ||= x}", - "function wrapper(arg0, arg1) { let x = 1; y.z ||= x;}", + "function wrapper(arg0, arg1) { let x = 1; y.z ||= x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); y.z = x}", - "function wrapper(arg0, arg1) { let x = fn(); y.z = x;}", + "function wrapper(arg0, arg1) { let x = fn(); y.z = x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); y.z += x}", - "function wrapper(arg0, arg1) { let x = fn(); y.z += x;}", + "function wrapper(arg0, arg1) { let x = fn(); y.z += x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); y.z ||= x}", - "function wrapper(arg0, arg1) { let x = fn(); y.z ||= x;}", + "function wrapper(arg0, arg1) { let x = fn(); y.z ||= x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return x ? y : z;}", - "function wrapper(arg0, arg1) { return arg0 ? y : z;}", + "function wrapper(arg0, arg1) { return arg0 ? y : z;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1 ? x : y;}", - "function wrapper(arg0, arg1) { return arg1 ? arg0 : y;}", + "function wrapper(arg0, arg1) { return arg1 ? arg0 : y;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1 ? y : x;}", - "function wrapper(arg0, arg1) { return arg1 ? y : arg0;}", + "function wrapper(arg0, arg1) { return arg1 ? y : arg0;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return x || y;}", - "function wrapper(arg0, arg1) { return arg0 || y;}", + "function wrapper(arg0, arg1) { return arg0 || y;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return x && y;}", - "function wrapper(arg0, arg1) { return arg0 && y;}", + "function wrapper(arg0, arg1) { return arg0 && y;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return x ?? y;}", - "function wrapper(arg0, arg1) { return arg0 ?? y;}", + "function wrapper(arg0, arg1) { return arg0 ?? y;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1 || x;}", - "function wrapper(arg0, arg1) { return arg1 || arg0;}", + "function wrapper(arg0, arg1) { return arg1 || arg0;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1 && x;}", - "function wrapper(arg0, arg1) { return arg1 && arg0;}", + "function wrapper(arg0, arg1) { return arg1 && arg0;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1 ?? x;}", - "function wrapper(arg0, arg1) { return arg1 ?? arg0;}", + "function wrapper(arg0, arg1) { return arg1 ?? arg0;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return y ? x : z;}", - "function wrapper(arg0, arg1) { let x = arg0; return y ? x : z;}", + "function wrapper(arg0, arg1) { let x = arg0; return y ? x : z;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return y ? z : x;}", - "function wrapper(arg0, arg1) { let x = arg0; return y ? z : x;}", + "function wrapper(arg0, arg1) { let x = arg0; return y ? z : x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return (arg1 ? 1 : 2) ? x : 3;}", - "function wrapper(arg0, arg1) { return arg0;}", + "function wrapper(arg0, arg1) { return arg0;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return (arg1 ? 1 : 2) ? 3 : x;}", - "function wrapper(arg0, arg1) { let x = arg0; return 3;}", + "function wrapper(arg0, arg1) { let x = arg0; return 3;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return (arg1 ? y : 1) ? x : 2;}", - "function wrapper(arg0, arg1) { let x = arg0; return !arg1 || y ? x : 2;}", + "function wrapper(arg0, arg1) { let x = arg0; return !arg1 || y ? x : 2;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return (arg1 ? 1 : y) ? x : 2;}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1 || y ? x : 2;}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1 || y ? x : 2;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return (arg1 ? y : 1) ? 2 : x;}", - "function wrapper(arg0, arg1) { let x = arg0; return !arg1 || y ? 2 : x;}", + "function wrapper(arg0, arg1) { let x = arg0; return !arg1 || y ? 2 : x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return (arg1 ? 1 : y) ? 2 : x;}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1 || y ? 2 : x;}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1 || y ? 2 : x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return y || x;}", - "function wrapper(arg0, arg1) { let x = arg0; return y || x;}", + "function wrapper(arg0, arg1) { let x = arg0; return y || x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return y && x;}", - "function wrapper(arg0, arg1) { let x = arg0; return y && x;}", + "function wrapper(arg0, arg1) { let x = arg0; return y && x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return y ?? x;}", - "function wrapper(arg0, arg1) { let x = arg0; return y ?? x;}", + "function wrapper(arg0, arg1) { let x = arg0; return y ?? x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return x ? arg0 : y;}", - "function wrapper(arg0, arg1) { return fn() ? arg0 : y;}", + "function wrapper(arg0, arg1) { return fn() ? arg0 : y;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return arg0 ? x : y;}", - "function wrapper(arg0, arg1) { let x = fn(); return arg0 ? x : y;}", + "function wrapper(arg0, arg1) { let x = fn(); return arg0 ? x : y;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return arg0 ? y : x;}", - "function wrapper(arg0, arg1) { let x = fn(); return arg0 ? y : x;}", + "function wrapper(arg0, arg1) { let x = fn(); return arg0 ? y : x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return x || arg0;}", - "function wrapper(arg0, arg1) { return fn() || arg0;}", + "function wrapper(arg0, arg1) { return fn() || arg0;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return x && arg0;}", - "function wrapper(arg0, arg1) { return fn() && arg0;}", + "function wrapper(arg0, arg1) { return fn() && arg0;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return x ?? arg0;}", - "function wrapper(arg0, arg1) { return fn() ?? arg0;}", + "function wrapper(arg0, arg1) { return fn() ?? arg0;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return arg0 || x;}", - "function wrapper(arg0, arg1) { let x = fn(); return arg0 || x;}", + "function wrapper(arg0, arg1) { let x = fn(); return arg0 || x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return arg0 && x;}", - "function wrapper(arg0, arg1) { let x = fn(); return arg0 && x;}", + "function wrapper(arg0, arg1) { let x = fn(); return arg0 && x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return arg0 ?? x;}", - "function wrapper(arg0, arg1) { let x = fn(); return arg0 ?? x;}", + "function wrapper(arg0, arg1) { let x = fn(); return arg0 ?? x;}", ); test( "function wrapper(arg0, arg1) {let x = fn(); let y = x[prop]; let z = y.val; throw z}", - "function wrapper(arg0, arg1) { throw fn()[prop].val;}", + "function wrapper(arg0, arg1) { throw fn()[prop].val;}", ); test( "function wrapper(arg0, arg1) {let x = fn(), y = x[prop], z = y.val; throw z}", - "function wrapper(arg0, arg1) { throw fn()[prop].val;}", + "function wrapper(arg0, arg1) { throw fn()[prop].val;}", ); test( "function wrapper(arg0, arg1) {let x = 0; let y = ++x; return y}", - "function wrapper(arg0, arg1) { let x = 0; return ++x;}", + "function wrapper(arg0, arg1) { let x = 0; return ++x;}", ); test( "function wrapper(arg0, arg1) {let x = 0; let y = x; return [x, y]}", - "function wrapper(arg0, arg1) { let x = 0; return [x, x];}", + "function wrapper(arg0, arg1) { let x = 0; return [x, x];}", ); test( "function wrapper(arg0, arg1) {let x = 0; let y = ++x; return [x, y]}", - "function wrapper(arg0, arg1) { let x = 0, y = ++x; return [x, y];}", + "function wrapper(arg0, arg1) { let x = 0, y = ++x; return [x, y];}", ); - test("function wrapper(arg0, arg1) {let x = 0; let y = {valueOf() { x = 1 }}; let z = x; return [y == 1, z]}", "function wrapper(arg0, arg1) { let x = 0, y = { valueOf() { x = 1; } }, z = x; return [y == 1, z];}"); + test("function wrapper(arg0, arg1) {let x = 0; let y = {valueOf() { x = 1 }}; let z = x; return [y == 1, z]}", "function wrapper(arg0, arg1) { let x = 0, y = { valueOf() { x = 1; } }, z = x; return [y == 1, z];}"); test( "function wrapper(arg0, arg1) {let x = arg0; return [...x];}", - "function wrapper(arg0, arg1) { return [...arg0];}", + "function wrapper(arg0, arg1) { return [...arg0];}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return [x, ...arg1];}", - "function wrapper(arg0, arg1) { return [arg0, ...arg1];}", + "function wrapper(arg0, arg1) { return [arg0, ...arg1];}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return [...arg1, x];}", - "function wrapper(arg0, arg1) { let x = arg0; return [...arg1, x];}", + "function wrapper(arg0, arg1) { let x = arg0; return [...arg1, x];}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1(...x);}", - "function wrapper(arg0, arg1) { return arg1(...arg0);}", + "function wrapper(arg0, arg1) { return arg1(...arg0);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1(x, ...arg1);}", - "function wrapper(arg0, arg1) { return arg1(arg0, ...arg1);}", + "function wrapper(arg0, arg1) { return arg1(arg0, ...arg1);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1(...arg1, x);}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1(...arg1, x);}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1(...arg1, x);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; arg1(x);}", - "function wrapper(arg0, arg1) { arg1(arg0);}", + "function wrapper(arg0, arg1) { arg1(arg0);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; throw x;}", - "function wrapper(arg0, arg1) { throw arg0;}", + "function wrapper(arg0, arg1) { throw arg0;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return x;}", - "function wrapper(arg0, arg1) { return arg0;}", + "function wrapper(arg0, arg1) { return arg0;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; if (x) return 1;}", - "function wrapper(arg0, arg1) { if (arg0) return 1;}", + "function wrapper(arg0, arg1) { if (arg0) return 1;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; switch (x) { case 0: return 1; }}", - "function wrapper(arg0, arg1) { switch (arg0) { case 0: return 1; }}", + "function wrapper(arg0, arg1) { switch (arg0) { case 0: return 1; }}", ); test( "function wrapper(arg0, arg1) {let x = arg0; let y = x; return y + y;}", - "function wrapper(arg0, arg1) { let y = arg0; return y + y;}", + "function wrapper(arg0, arg1) { let y = arg0; return y + y;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; do {} while (x);}", - "function wrapper(arg0, arg1) { let x = arg0; do ; while (x);}", + "function wrapper(arg0, arg1) { let x = arg0; do ; while (x);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; while (x) return 1;}", - "function wrapper(arg0, arg1) { let x = arg0; for (; x; ) return 1;}", + "function wrapper(arg0, arg1) { let x = arg0; for (; x; ) return 1;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; for (; x; ) return 1;}", - "function wrapper(arg0, arg1) { let x = arg0; for (; x; ) return 1;}", + "function wrapper(arg0, arg1) { let x = arg0; for (; x; ) return 1;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.[x];}", - "function wrapper(arg0, arg1) { return arg1?.[arg0];}", + "function wrapper(arg0, arg1) { return arg1?.[arg0];}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.(x);}", - "function wrapper(arg0, arg1) { return arg1?.(arg0);}", + "function wrapper(arg0, arg1) { return arg1?.(arg0);}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return arg1?.[x];}", - "function wrapper(arg0, arg1) { let x = fn(); return arg1?.[x];}", + "function wrapper(arg0, arg1) { let x = fn(); return arg1?.[x];}", ); test( "function wrapper(arg0, arg1) {let x = fn(); return arg1?.(x);}", - "function wrapper(arg0, arg1) { let x = fn(); return arg1?.(x);}", + "function wrapper(arg0, arg1) { let x = fn(); return arg1?.(x);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.a === x;}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.a === x;}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.a === x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.[0] === x;}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.[0] === x;}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.[0] === x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.(0) === x;}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.(0) === x;}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.(0) === x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.a[x];}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.a[x];}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.a[x];}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.a(x);}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.a(x);}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.a(x);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.[a][x];}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.[a][x];}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.[a][x];}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.[a](x);}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.[a](x);}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.[a](x);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.(a)[x];}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.(a)[x];}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.(a)[x];}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1?.(a)(x);}", - "function wrapper(arg0, arg1) { let x = arg0; return arg1?.(a)(x);}", + "function wrapper(arg0, arg1) { let x = arg0; return arg1?.(a)(x);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {x};}", - "function wrapper(arg0, arg1) { return { x: arg0 };}", + "function wrapper(arg0, arg1) { return { x: arg0 };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {x: y, y: x};}", - "function wrapper(arg0, arg1) { let x = arg0; return { x: y, y: x };}", + "function wrapper(arg0, arg1) { let x = arg0; return { x: y, y: x };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {x: arg1, y: x};}", - "function wrapper(arg0, arg1) { return { x: arg1, y: arg0 };}", + "function wrapper(arg0, arg1) { return { x: arg1, y: arg0 };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {[x]: 0};}", - "function wrapper(arg0, arg1) { return { [arg0]: 0 };}", + "function wrapper(arg0, arg1) { return { [arg0]: 0 };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {[y]: x};}", - "function wrapper(arg0, arg1) { let x = arg0; return { [y]: x };}", + "function wrapper(arg0, arg1) { let x = arg0; return { [y]: x };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {[arg1]: x};}", - "function wrapper(arg0, arg1) { let x = arg0; return { [arg1]: x };}", + "function wrapper(arg0, arg1) { let x = arg0; return { [arg1]: x };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {y() {}, x};}", - "function wrapper(arg0, arg1) { return { y() { }, x: arg0 };}", + "function wrapper(arg0, arg1) { return { y() { }, x: arg0 };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {[y]() {}, x};}", - "function wrapper(arg0, arg1) { let x = arg0; return { [y]() { }, x };}", + "function wrapper(arg0, arg1) { let x = arg0; return { [y]() { }, x };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {...x};}", - "function wrapper(arg0, arg1) { return { ...arg0 };}", + "function wrapper(arg0, arg1) { return { ...arg0 };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {...x, y};}", - "function wrapper(arg0, arg1) { return { ...arg0, y };}", + "function wrapper(arg0, arg1) { return { ...arg0, y };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {x, ...y};}", - "function wrapper(arg0, arg1) { return { x: arg0, ...y };}", + "function wrapper(arg0, arg1) { return { x: arg0, ...y };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return {...y, x};}", - "function wrapper(arg0, arg1) { let x = arg0; return { ...y, x };}", + "function wrapper(arg0, arg1) { let x = arg0; return { ...y, x };}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return `a${x}b${y}c`;}", - "function wrapper(arg0, arg1) { return `a${arg0}b${y}c`;}", + "function wrapper(arg0, arg1) { return `a${arg0}b${y}c`;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return `a${y}b${x}c`;}", - "function wrapper(arg0, arg1) { let x = arg0; return `a${y}b${x}c`;}", + "function wrapper(arg0, arg1) { let x = arg0; return `a${y}b${x}c`;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return `a${arg1}b${x}c`;}", - "function wrapper(arg0, arg1) { return `a${arg1}b${arg0}c`;}", + "function wrapper(arg0, arg1) { return `a${arg1}b${arg0}c`;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return x`y`;}", - "function wrapper(arg0, arg1) { return arg0`y`;}", + "function wrapper(arg0, arg1) { return arg0`y`;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return y`a${x}b`;}", - "function wrapper(arg0, arg1) { let x = arg0; return y`a${x}b`;}", + "function wrapper(arg0, arg1) { let x = arg0; return y`a${x}b`;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return arg1`a${x}b`;}", - "function wrapper(arg0, arg1) { return arg1`a${arg0}b`;}", + "function wrapper(arg0, arg1) { return arg1`a${arg0}b`;}", ); test( "function wrapper(arg0, arg1) {let x = 'x'; return `a${x}b`;}", - "function wrapper(arg0, arg1) { return `axb`;}", + "function wrapper(arg0, arg1) { return `axb`;}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return import(x);}", - "function wrapper(arg0, arg1) { return import(arg0);}", + "function wrapper(arg0, arg1) { return import(arg0);}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return [import(y), x];}", - "function wrapper(arg0, arg1) { let x = arg0; return [import(y), x];}", + "function wrapper(arg0, arg1) { let x = arg0; return [import(y), x];}", ); test( "function wrapper(arg0, arg1) {let x = arg0; return [import(arg1), x];}", - "function wrapper(arg0, arg1) { return [import(arg1), arg0];}", + "function wrapper(arg0, arg1) { return [import(arg1), arg0];}", ); test( "function wrapper(arg0, arg1) {return async () => { let x = arg0; await x; };}", - "function wrapper(arg0, arg1) { return async () => { await arg0; };}", + "function wrapper(arg0, arg1) { return async () => { await arg0; };}", ); - test("function wrapper(arg0, arg1) {return async () => { let x = arg0; await y; return x; };}", "function wrapper(arg0, arg1) { return async () => { let x = arg0; return await y, x; };}"); - test("function wrapper(arg0, arg1) {return async () => { let x = arg0; await arg1; return x; };}", "function wrapper(arg0, arg1) { return async () => { let x = arg0; return await arg1, x; };}"); + test("function wrapper(arg0, arg1) {return async () => { let x = arg0; await y; return x; };}", "function wrapper(arg0, arg1) { return async () => { let x = arg0; return await y, x; };}"); + test("function wrapper(arg0, arg1) {return async () => { let x = arg0; await arg1; return x; };}", "function wrapper(arg0, arg1) { return async () => { let x = arg0; return await arg1, x; };}"); test( "function wrapper(arg0, arg1) {return function* () { let x = arg0; yield x; };}", - "function wrapper(arg0, arg1) { return function* () { yield arg0; };}", + "function wrapper(arg0, arg1) { return function* () { yield arg0; };}", ); - test("function wrapper(arg0, arg1) {return function* () { let x = arg0; yield; return x; };}", "function wrapper(arg0, arg1) { return function* () { let x = arg0; return yield, x; };}"); - test("function wrapper(arg0, arg1) {return function* () { let x = arg0; yield y; return x; };}", "function wrapper(arg0, arg1) { return function* () { let x = arg0; return yield y, x; };}"); - test("function wrapper(arg0, arg1) {return function* () { let x = arg0; yield arg1; return x; };}", "function wrapper(arg0, arg1) { return function* () { let x = arg0; return yield arg1, x; };}"); + test( + "function wrapper(arg0, arg1) {return function* () { let x = arg0; yield; return x; };}", + "function wrapper(arg0, arg1) { return function* () { let x = arg0; return yield, x; };}", + ); + test("function wrapper(arg0, arg1) {return function* () { let x = arg0; yield y; return x; };}", "function wrapper(arg0, arg1) { return function* () { let x = arg0; return yield y, x; };}"); + test("function wrapper(arg0, arg1) {return function* () { let x = arg0; yield arg1; return x; };}", "function wrapper(arg0, arg1) { return function* () { let x = arg0; return yield arg1, x; };}"); test( "function wrapper(arg0, arg1) {let x = arg0; x()}", - "function wrapper(arg0, arg1) { arg0();}", + "function wrapper(arg0, arg1) { arg0();}", ); test( "function wrapper(arg0, arg1) {let x = arg0; (0, x)()}", - "function wrapper(arg0, arg1) { arg0();}", + "function wrapper(arg0, arg1) { arg0();}", ); test( "function wrapper(arg0, arg1) {let x = arg0.foo; x.bar()}", - "function wrapper(arg0, arg1) { arg0.foo.bar();}", + "function wrapper(arg0, arg1) { arg0.foo.bar();}", ); test( "function wrapper(arg0, arg1) {let x = arg0.foo; x[bar]()}", - "function wrapper(arg0, arg1) { arg0.foo[bar]();}", + "function wrapper(arg0, arg1) { arg0.foo[bar]();}", ); test( "function wrapper(arg0, arg1) {let x = arg0.foo; x()}", - "function wrapper(arg0, arg1) { let x = arg0.foo; x();}", + "function wrapper(arg0, arg1) { let x = arg0.foo; x();}", ); test( "function wrapper(arg0, arg1) {let x = arg0[foo]; x()}", - "function wrapper(arg0, arg1) { let x = arg0[foo]; x();}", + "function wrapper(arg0, arg1) { let x = arg0[foo]; x();}", ); test( "function wrapper(arg0, arg1) {let x = arg0?.foo; x()}", - "function wrapper(arg0, arg1) { let x = arg0?.foo; x();}", + "function wrapper(arg0, arg1) { let x = arg0?.foo; x();}", ); test( "function wrapper(arg0, arg1) {let x = arg0?.[foo]; x()}", - "function wrapper(arg0, arg1) { let x = arg0?.[foo]; x();}", + "function wrapper(arg0, arg1) { let x = arg0?.[foo]; x();}", ); test( "function wrapper(arg0, arg1) {let x = arg0.foo; (0, x)()}", - "function wrapper(arg0, arg1) { let x = arg0.foo; x();}", + "function wrapper(arg0, arg1) { let x = arg0.foo; x();}", ); test( "function wrapper(arg0, arg1) {let x = arg0[foo]; (0, x)()}", - "function wrapper(arg0, arg1) { let x = arg0[foo]; x();}", + "function wrapper(arg0, arg1) { let x = arg0[foo]; x();}", ); test( "function wrapper(arg0, arg1) {let x = arg0?.foo; (0, x)()}", - "function wrapper(arg0, arg1) { let x = arg0?.foo; x();}", + "function wrapper(arg0, arg1) { let x = arg0?.foo; x();}", ); test( "function wrapper(arg0, arg1) {let x = arg0?.[foo]; (0, x)()}", - "function wrapper(arg0, arg1) { let x = arg0?.[foo]; x();}", + "function wrapper(arg0, arg1) { let x = arg0?.[foo]; x();}", ); test( "function wrapper(arg0, arg1) {let x = arg0(); arg1() + x}", - "function wrapper(arg0, arg1) { let x = arg0(); arg1() + x;}", + "function wrapper(arg0, arg1) { let x = arg0(); arg1() + x;}", ); test( "function wrapper(arg0, arg1) {let x = arg0(); /* @__PURE__ */ arg1() + x}", - "function wrapper(arg0, arg1) { let x = arg0(); /* @__PURE__ */ arg1() + x;}", + "function wrapper(arg0, arg1) { let x = arg0(); /* @__PURE__ */ arg1() + x;}", ); test( "function wrapper(arg0, arg1) {let x = /* @__PURE__ */ arg0(); arg1() + x}", - "function wrapper(arg0, arg1) { let x = /* @__PURE__ */ arg0(); arg1() + x;}", + "function wrapper(arg0, arg1) { let x = /* @__PURE__ */ arg0(); arg1() + x;}", ); test( "function wrapper(arg0, arg1) {let x = /* @__PURE__ */ arg0(); /* @__PURE__ */ arg1() + x}", - "function wrapper(arg0, arg1) { /* @__PURE__ */ arg1() + /* @__PURE__ */ arg0();}", + "function wrapper(arg0, arg1) { /* @__PURE__ */ arg1() + /* @__PURE__ */ arg0();}", ); test("if (1) a(); else { ; }", "a();"); test("if (1) a(); else { b() }", "a();"); @@ -2283,31 +2283,28 @@ fn js_parser_test() { test("if (1) a(); else { let b }", "a();"); test("if (1) a(); else { throw b }", "a();"); test("if (1) a(); else { return b }", "a();"); - test("b: { if (x) a(); else { break b } }", "b: if (x) a(); else break b;"); + test("b: { if (x) a(); else { break b } }", "b: if (x) a(); else break b;"); test("b: { if (1) a(); else { break b } }", "a();"); test("b: { if (0) a(); else { break b } }", ""); - test( - "b: while (1) if (x) a(); else { continue b }", - "b: for (; ; ) if (x) a();else continue b;", - ); - test("b: while (1) if (1) a(); else { continue b }", "for (; ; ) a();"); - test("b: while (1) if (0) a(); else { continue b }", "b: for (; ; ) continue b;"); + test("b: while (1) if (x) a(); else { continue b }", "b: for (;;) if (x) a();else continue b;"); + test("b: while (1) if (1) a(); else { continue b }", "for (;;) a();"); + test("b: while (1) if (0) a(); else { continue b }", "b: for (;;) continue b;"); test("if (1) a(); else { class b {} }", "a();"); test("if (1) a(); else { debugger }", "a();"); test("if (1) a(); else { switch (1) { case 1: b() } }", "a();"); test("if (0) {let a = 1} else a()", "a();"); - test("if (1) {let a = 1} else a()", "{ let a = 1;}"); - test("if (0) a(); else {let a = 1}", "{ let a = 1;}"); + test("if (1) {let a = 1} else a()", "{ let a = 1;}"); + test("if (0) a(); else {let a = 1}", "{ let a = 1;}"); test("if (1) a(); else {let a = 1}", "a();"); - test("if (1) a(); else { var a = b }", "if (1) a();else var a;"); - test("if (1) a(); else { var [a] = b }", "if (1) a();else var a;"); - test("if (1) a(); else { var {x: a} = b }", "if (1) a();else var a;"); + test("if (1) a(); else { var a = b }", "if (1) a();else var a;"); + test("if (1) a(); else { var [a] = b }", "if (1) a();else var a;"); + test("if (1) a(); else { var {x: a} = b }", "if (1) a();else var a;"); test("if (1) a(); else { var [] = b }", "a();"); test("if (1) a(); else { var {} = b }", "a();"); - test("if (1) a(); else { function a() {} }", "if (1) a();else var a;"); - test("if (1) a(); else { for(;;){var a} }", "if (1) a();else for (; ; ) var a;"); - test("if (1) { a(); b() } else { var a; var b; }", "if (1) a(), b();else var a, b;"); - test("if (1) a(); else { switch (1) { case 1: case 2: var a } }", "if (1) a();else var a;"); + test("if (1) a(); else { function a() {} }", "if (1) a();else var a;"); + test("if (1) a(); else { for(;;){var a} }", "if (1) a();else for (;;) var a;"); + test("if (1) { a(); b() } else { var a; var b; }", "if (1) a(), b();else var a, b;"); + test("if (1) a(); else { switch (1) { case 1: case 2: var a } }", "if (1) a();else var a;"); test("import 'x' assert {'type': 'json'}", "import 'x' assert { type: 'json' };"); test("import 'x' assert {'ty pe': 'json'}", "import 'x' assert { 'ty pe': 'json' };"); test( @@ -2330,45 +2327,45 @@ fn js_parser_test() { ); test( "try { throw 0 } catch (e) { console.log(0) }", - "try { throw 0;} catch { console.log(0);}", + "try { throw 0;} catch { console.log(0);}", ); test( "try { throw 0 } catch (e) { console.log(0, e) }", - "try { throw 0;} catch (e) { console.log(0, e);}", + "try { throw 0;} catch (e) { console.log(0, e);}", ); - test("try { throw 0 } catch (e) { 0 && console.log(0, e) }", "try { throw 0;} catch {}"); + test("try { throw 0 } catch (e) { 0 && console.log(0, e) }", "try { throw 0;} catch {}"); test( "try { thrower() } catch ([a]) { console.log(0) }", - "try { thrower();} catch ([a]) { console.log(0);}", + "try { thrower();} catch ([a]) { console.log(0);}", ); test( "try { thrower() } catch ({ a }) { console.log(0) }", - "try { thrower();} catch ({ a }) { console.log(0);}", + "try { thrower();} catch ({ a }) { console.log(0);}", ); test( "try { throw 1 } catch (x) { y(x); var x = 2; y(x) }", - "try { throw 1;} catch (x) { y(x); var x = 2; y(x);}", + "try { throw 1;} catch (x) { y(x); var x = 2; y(x);}", ); test( "try { throw 1 } catch (x) { var x = 2; y(x) }", - "try { throw 1;} catch (x) { var x = 2; y(x);}", + "try { throw 1;} catch (x) { var x = 2; y(x);}", ); - test("try { throw 1 } catch (x) { var x = 2 }", "try { throw 1;} catch (x) { var x = 2;}"); - test("try { throw 1 } catch (x) { eval('x') }", "try { throw 1;} catch (x) { eval('x');}"); + test("try { throw 1 } catch (x) { var x = 2 }", "try { throw 1;} catch (x) { var x = 2;}"); + test("try { throw 1 } catch (x) { eval('x') }", "try { throw 1;} catch (x) { eval('x');}"); test( "if (y) try { throw 1 } catch (x) {} else eval('x')", - "if (y) try { throw 1;} catch {}else eval('x');", + "if (y) try { throw 1;} catch {}else eval('x');", ); - test("try { throw 0 } catch (e) { foo() }", "try { throw 0;} catch { foo();}"); - test("try {} catch (e) { var foo }", "try {} catch { var foo;}"); + test("try { throw 0 } catch (e) { foo() }", "try { throw 0;} catch { foo();}"); + test("try {} catch (e) { var foo }", "try {} catch { var foo;}"); test("try {} catch (e) { foo() }", ""); test("try {} catch (e) { foo() } finally {}", ""); test("try {} finally { foo() }", "foo();"); test("try {} catch (e) { foo() } finally { bar() }", "bar();"); test("try {} finally { var x = foo() }", "var x = foo();"); test("try {} catch (e) { foo() } finally { var x = bar() }", "var x = bar();"); - test("try {} finally { let x = foo() }", "{ let x = foo();}"); - test("try {} catch (e) { foo() } finally { let x = bar() }", "{ let x = bar();}"); + test("try {} finally { let x = foo() }", "{ let x = foo();}"); + test("try {} catch (e) { foo() } finally { let x = bar() }", "{ let x = bar();}"); test("using x = {}", "using x = {};"); test("using x = null", "const x = null;"); test("using x = undefined", "const x = void 0;"); @@ -2394,8 +2391,8 @@ fn js_printer_test() { test("false ** 2", "(!1) ** 2;"); test("x = '\n'", "x = ``;"); test("x = {'\n': 0}", "x = { '\n': 0 };"); - test("x = class{'\n' = 0}", "x = class { '\n' = 0;};"); - test("class Foo{'\n' = 0}", "class Foo { '\n' = 0;}"); + test("x = class{'\n' = 0}", "x = class { '\n' = 0;};"); + test("class Foo{'\n' = 0}", "class Foo { '\n' = 0;}"); test("x = Infinity", "x = 1 / 0;"); test("x = -Infinity", "x = -1 / 0;"); test("x = (Infinity).toString", "x = (1 / 0).toString;");