diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-07-06 09:04:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-06 16:04:11 +0800 |
commit | 0668fad5e9000fc8d4857f033c3e90b1cedb4563 (patch) | |
tree | c54ae9e72ee956c68234dbc4f22e0ad5ed60a8e9 /test/compress | |
parent | d0e3f6955d956a4977d701e9027eb54d15b6f77c (diff) | |
download | tracifyjs-0668fad5e9000fc8d4857f033c3e90b1cedb4563.tar.gz tracifyjs-0668fad5e9000fc8d4857f033c3e90b1cedb4563.zip |
fix corner case with `class` (#5054)
fixes #5053
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/classes.js | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/test/compress/classes.js b/test/compress/classes.js index c57842f9..d4047a8a 100644 --- a/test/compress/classes.js +++ b/test/compress/classes.js @@ -1875,3 +1875,136 @@ issue_5015_3: { expect_stdout: "PASS" node_version: ">=4" } + +issue_5053_1: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + "use strict"; + try { + console.log(new class A { + constructor() { + A = 42; + } + }()); + } catch (e) { + console.log("PASS"); + } + } + expect: { + "use strict"; + try { + console.log(new class A { + constructor() { + A = 42; + } + }()); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=4" +} + +issue_5053_2: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + "use strict"; + try { + console.log(new class A { + f() { + A = 42; + } + }().f()); + } catch (e) { + console.log("PASS"); + } + } + expect: { + "use strict"; + try { + console.log(new class A { + f() { + A = 42; + } + }().f()); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=4" +} + +issue_5053_3: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + try { + console.log(new class A { + p = A = 42; + }().p); + } catch (e) { + console.log("PASS"); + } + } + expect: { + try { + console.log(new class A { + p = A = 42; + }().p); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=12" +} + +issue_5053_4: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + "use strict"; + class A { + constructor() { + A = 42; + } + } + try { + console.log(new A()); + } catch (e) { + console.log("PASS"); + } + } + expect: { + "use strict"; + class A { + constructor() { + A = 42; + } + } + try { + console.log(new A()); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=4" +} |