aboutsummaryrefslogtreecommitdiff
path: root/test/compress/classes.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-05-22 03:12:37 +0100
committerGitHub <noreply@github.com>2021-05-22 10:12:37 +0800
commitd2a45ba441ed6975021b3524215c01a011dfb46a (patch)
treeff68f99235009ef8098b2c6c57a2f0ec50cc8a8e /test/compress/classes.js
parentde376c3d3316fc4a33a876793eb4d693422415a0 (diff)
downloadtracifyjs-d2a45ba441ed6975021b3524215c01a011dfb46a.tar.gz
tracifyjs-d2a45ba441ed6975021b3524215c01a011dfb46a.zip
fix corner case in parsing private field/method (#4952)
fixes #4951
Diffstat (limited to 'test/compress/classes.js')
-rw-r--r--test/compress/classes.js31
1 files changed, 29 insertions, 2 deletions
diff --git a/test/compress/classes.js b/test/compress/classes.js
index e201bd3d..69d7047e 100644
--- a/test/compress/classes.js
+++ b/test/compress/classes.js
@@ -72,7 +72,7 @@ fields: {
console.log(k, o[k]);
console.log(o.q);
}
- expect_exact: 'var o=new class A{"#p";static #p="PASS";async;get q(){return A.#p}[6*7]=console?"foo":"bar"};for(var k in o)console.log(k,o[k]);console.log(o.q);'
+ expect_exact: 'var o=new class A{"#p";static#p="PASS";async;get q(){return A.#p}[6*7]=console?"foo":"bar"};for(var k in o)console.log(k,o[k]);console.log(o.q);'
expect_stdout: [
"42 foo",
"#p undefined",
@@ -136,7 +136,7 @@ private_methods: {
}
}().q.then(console.log);
}
- expect_exact: "(new class A{static*#f(){yield 3*A.#p}async #g(){for(var a of A.#f())return a*await 2}static get #p(){return 7}get q(){return this.#g()}}).q.then(console.log);"
+ expect_exact: "(new class A{static*#f(){yield 3*A.#p}async#g(){for(var a of A.#f())return a*await 2}static get#p(){return 7}get q(){return this.#g()}}).q.then(console.log);"
expect_stdout: "42"
node_version: ">=14.6"
}
@@ -1563,3 +1563,30 @@ drop_unused_self_reference: {
expect_stdout: "PASS"
node_version: ">=4"
}
+
+issue_4951_1: {
+ input: {
+ class A {
+ static#p = console.log("PASS");
+ }
+ }
+ expect_exact: 'class A{static#p=console.log("PASS")}'
+ expect_stdout: "PASS"
+ node_version: ">=12"
+}
+
+issue_4951_2: {
+ input: {
+ new class {
+ constructor() {
+ this.#f().then(console.log);
+ }
+ async#f() {
+ return await "PASS";
+ }
+ }();
+ }
+ expect_exact: 'new class{constructor(){this.#f().then(console.log)}async#f(){return await"PASS"}};'
+ expect_stdout: "PASS"
+ node_version: ">=14.6"
+}