aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-04-30 15:21:15 +0100
committerGitHub <noreply@github.com>2021-04-30 22:21:15 +0800
commit8e4a19ffec0506c25aebb05e2c84ec32ff307642 (patch)
treea038cd39f9becc9b3b80674ee2645ea1ce8c08bd /test
parentd833e66d23cab3c9c03a99a9cf118647bf862868 (diff)
downloadtracifyjs-8e4a19ffec0506c25aebb05e2c84ec32ff307642.tar.gz
tracifyjs-8e4a19ffec0506c25aebb05e2c84ec32ff307642.zip
fix corner case in `spreads` (#4883)
fixes #4882
Diffstat (limited to 'test')
-rw-r--r--test/compress/spreads.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/test/compress/spreads.js b/test/compress/spreads.js
index 4e5d0d98..6e37bf18 100644
--- a/test/compress/spreads.js
+++ b/test/compress/spreads.js
@@ -1068,3 +1068,91 @@ issue_4849: {
expect_stdout: "object"
node_version: ">=8"
}
+
+issue_4882_1: {
+ options = {
+ objects: true,
+ spreads: true,
+ }
+ input: {
+ var o = {
+ p: "PASS",
+ ... {
+ __proto__: {
+ p: "FAIL 1",
+ q: "FAIL 2",
+ },
+ },
+ };
+ console.log(o.p);
+ console.log(o.q);
+ }
+ expect: {
+ var o = {
+ p: "PASS",
+ };
+ console.log(o.p);
+ console.log(o.q);
+ }
+ expect_stdout: [
+ "PASS",
+ "undefined",
+ ]
+ node_version: ">=8"
+}
+
+issue_4882_2: {
+ options = {
+ objects: true,
+ spreads: true,
+ }
+ input: {
+ console.log(null == Object.getPrototypeOf({
+ ... {
+ __proto__: (console.log(42), null),
+ },
+ }) ? "FAIL" : "PASS");
+ }
+ expect: {
+ console.log(null == Object.getPrototypeOf({
+ ... {
+ __proto__: (console.log(42), null),
+ },
+ }) ? "FAIL" : "PASS");
+ }
+ expect_stdout: [
+ "42",
+ "PASS",
+ ]
+ node_version: ">=8"
+}
+
+issue_4882_3: {
+ options = {
+ objects: true,
+ spreads: true,
+ }
+ input: {
+ var o = {
+ __proto__: { p: 42 },
+ ... {
+ set __proto__(v) {},
+ },
+ };
+ console.log(o.__proto__ === Object.getPrototypeOf(o) ? "FAIL" : "PASS");
+ console.log(o.p);
+ }
+ expect: {
+ var o = {
+ __proto__: { p: 42 },
+ ["__proto__"]: void 0,
+ };
+ console.log(o.__proto__ === Object.getPrototypeOf(o) ? "FAIL" : "PASS");
+ console.log(o.p);
+ }
+ expect_stdout: [
+ "PASS",
+ "42",
+ ]
+ node_version: ">=8"
+}