[Pkg-javascript-commits] [uglifyjs] 441/491: fix `join_vars` property assignment for negative array index (#2810)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:52:02 UTC 2018
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.
commit 983e69128b0e6da78d71ad9b77d798f31a10ca44
Author: kzc <kzc at users.noreply.github.com>
Date: Thu Jan 18 08:52:54 2018 -0500
fix `join_vars` property assignment for negative array index (#2810)
fixes #2790
---
lib/compress.js | 2 +-
test/compress/properties.js | 204 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 205 insertions(+), 1 deletion(-)
diff --git a/lib/compress.js b/lib/compress.js
index 6417822..8905679 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1746,7 +1746,7 @@ merge(Compressor.prototype, {
}
if (prop instanceof AST_Node) break;
def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
- key: prop,
+ key: "" + prop,
value: node.right
}));
exprs.shift();
diff --git a/test/compress/properties.js b/test/compress/properties.js
index af115ff..53684da 100644
--- a/test/compress/properties.js
+++ b/test/compress/properties.js
@@ -1357,3 +1357,207 @@ join_object_assignments_forin: {
}
expect_stdout: "PASS"
}
+
+join_object_assignments_negative: {
+ options = {
+ evaluate: true,
+ join_vars: true,
+ properties: true,
+ }
+ input: {
+ var o = {};
+ o[0] = 0;
+ o[-0] = 1;
+ o[-1] = 2;
+ console.log(o[0], o[-0], o[-1]);
+ }
+ expect: {
+ var o = {
+ 0: 0,
+ 0: 1,
+ "-1": 2
+ };
+ console.log(o[0], o[-0], o[-1]);
+ }
+ expect_stdout: "1 1 2"
+}
+
+join_object_assignments_NaN_1: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ var o = {};
+ o[NaN] = 1;
+ o[0/0] = 2;
+ console.log(o[NaN], o[NaN]);
+ }
+ expect: {
+ var o = {};
+ o[NaN] = 1;
+ o[0/0] = 2;
+ console.log(o[NaN], o[NaN]);
+ }
+ expect_stdout: "2 2"
+}
+
+join_object_assignments_NaN_2: {
+ options = {
+ evaluate: true,
+ join_vars: true,
+ properties: true,
+ }
+ input: {
+ var o = {};
+ o[NaN] = 1;
+ o[0/0] = 2;
+ console.log(o[NaN], o[NaN]);
+ }
+ expect: {
+ var o = {
+ NaN: 1,
+ NaN: 2
+ };
+ console.log(o.NaN, o.NaN);
+ }
+ expect_stdout: "2 2"
+}
+
+join_object_assignments_null_0: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ var o = {};
+ o[null] = 1;
+ console.log(o[null]);
+ }
+ expect: {
+ var o = {};
+ o[null] = 1;
+ console.log(o[null]);
+ }
+ expect_stdout: "1"
+}
+
+join_object_assignments_null_1: {
+ options = {
+ evaluate: true,
+ join_vars: true,
+ properties: true,
+ }
+ input: {
+ var o = {};
+ o[null] = 1;
+ console.log(o[null]);
+ }
+ expect: {
+ var o = {
+ null: 1
+ };
+ console.log(o.null);
+ }
+ expect_stdout: "1"
+}
+
+join_object_assignments_void_0: {
+ options = {
+ evaluate: true,
+ join_vars: true,
+ }
+ input: {
+ var o = {};
+ o[void 0] = 1;
+ console.log(o[void 0]);
+ }
+ expect: {
+ var o = {
+ undefined: 1
+ };
+ console.log(o[void 0]);
+ }
+ expect_stdout: "1"
+}
+
+join_object_assignments_undefined_1: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ var o = {};
+ o[undefined] = 1;
+ console.log(o[undefined]);
+ }
+ expect: {
+ var o = {};
+ o[void 0] = 1;
+ console.log(o[void 0]);
+ }
+ expect_stdout: "1"
+}
+
+join_object_assignments_undefined_2: {
+ options = {
+ evaluate: true,
+ join_vars: true,
+ properties: true,
+ }
+ input: {
+ var o = {};
+ o[undefined] = 1;
+ console.log(o[undefined]);
+ }
+ expect: {
+ var o = {
+ undefined : 1
+ };
+ console.log(o[void 0]);
+ }
+ expect_stdout: "1"
+}
+
+join_object_assignments_Infinity: {
+ options = {
+ evaluate: true,
+ join_vars: true,
+ properties: true,
+ }
+ input: {
+ var o = {};
+ o[Infinity] = 1;
+ o[1/0] = 2;
+ o[-Infinity] = 3;
+ o[-1/0] = 4;
+ console.log(o[Infinity], o[1/0], o[-Infinity], o[-1/0]);
+ }
+ expect: {
+ var o = {
+ Infinity: 1,
+ Infinity: 2,
+ "-Infinity": 3,
+ "-Infinity": 4
+ };
+ console.log(o[1/0], o[1/0], o[-1/0], o[-1/0]);
+ }
+ expect_stdout: "2 2 4 4"
+}
+
+join_object_assignments_regex: {
+ options = {
+ evaluate: true,
+ join_vars: true,
+ properties: true,
+ }
+ input: {
+ var o = {};
+ o[/rx/] = 1;
+ console.log(o[/rx/]);
+ }
+ expect: {
+ var o = {
+ "/rx/": 1
+ };
+ console.log(o[/rx/]);
+ }
+ expect_stdout: "1"
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list