aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorDavid Glasser <glasser@davidglasser.net>2013-01-16 14:59:19 -0500
committerMihai Bazon <mihai@bazon.net>2013-01-17 11:36:10 +0200
commit1529ab965a4a434e6024977a53f8460f6a474086 (patch)
treec9bd418871d6e8352d0edfa1fd952a2be0802375 /test/compress
parent605f330e6949ca699a8770a9dd7d80bbacc6a175 (diff)
downloadtracifyjs-1529ab965a4a434e6024977a53f8460f6a474086.tar.gz
tracifyjs-1529ab965a4a434e6024977a53f8460f6a474086.zip
Fix output for arrays containing undefined values.
1b6bcca7 was a first attempt at this. That commit made Uglify stop replacing holes with undefined, but instead it started replacing undefined with holes. This is slightly problematic, because there is a difference between a hole and an undefined value. More problematically, it changed [1,undefined] to [1,] which generally doesn't even parse as a hole (just as a trailing comma), so it didn't even preserve the length of the array! Instead, parse holes as their own special AST node which prints invisibly.
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/arrays.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/compress/arrays.js b/test/compress/arrays.js
new file mode 100644
index 00000000..10fe6eb5
--- /dev/null
+++ b/test/compress/arrays.js
@@ -0,0 +1,12 @@
+holes_and_undefined: {
+ input: {
+ x = [1, 2, undefined];
+ y = [1, , 2, ];
+ z = [1, undefined, 3];
+ }
+ expect: {
+ x=[1,2,void 0];
+ y=[1,,2];
+ z=[1,void 0,3];
+ }
+}