aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authoralexlamsl <alexlamsl@gmail.com>2017-02-18 19:01:42 +0800
committeralexlamsl <alexlamsl@gmail.com>2017-02-18 19:01:42 +0800
commite5badb954157d41dba3cc74f8813a90a145d9ca3 (patch)
tree4f9dd6c4aabd4ed9a82f90db9e1c32f5c79b8f76 /test/compress
parentfa668a28b47e06d838659d4e0910460c84ca3a61 (diff)
downloadtracifyjs-e5badb954157d41dba3cc74f8813a90a145d9ca3.tar.gz
tracifyjs-e5badb954157d41dba3cc74f8813a90a145d9ca3.zip
enable typeof "undefined" for general use
move out of unsafe, guard corner case with screw_id8 instead closes #1446
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/issue-105.js25
-rw-r--r--test/compress/issue-1446.js71
2 files changed, 71 insertions, 25 deletions
diff --git a/test/compress/issue-105.js b/test/compress/issue-105.js
deleted file mode 100644
index ca17adbf..00000000
--- a/test/compress/issue-105.js
+++ /dev/null
@@ -1,25 +0,0 @@
-typeof_eq_undefined: {
- options = {
- comparisons: true
- };
- input: { a = typeof b.c != "undefined" }
- expect: { a = "undefined" != typeof b.c }
-}
-
-typeof_eq_undefined_unsafe: {
- options = {
- comparisons: true,
- unsafe: true
- };
- input: { a = typeof b.c != "undefined" }
- expect: { a = void 0 !== b.c }
-}
-
-typeof_eq_undefined_unsafe2: {
- options = {
- comparisons: true,
- unsafe: true
- };
- input: { a = "undefined" != typeof b.c }
- expect: { a = void 0 !== b.c }
-}
diff --git a/test/compress/issue-1446.js b/test/compress/issue-1446.js
new file mode 100644
index 00000000..3d69aa09
--- /dev/null
+++ b/test/compress/issue-1446.js
@@ -0,0 +1,71 @@
+typeof_eq_undefined: {
+ options = {
+ comparisons: true
+ }
+ input: {
+ var a = typeof b != "undefined";
+ b = typeof a != "undefined";
+ var c = typeof d.e !== "undefined";
+ var f = "undefined" === typeof g;
+ g = "undefined" === typeof f;
+ var h = "undefined" == typeof i.j;
+ }
+ expect: {
+ var a = "undefined" != typeof b;
+ b = void 0 !== a;
+ var c = void 0 !== d.e;
+ var f = "undefined" == typeof g;
+ g = void 0 === f;
+ var h = void 0 === i.j;
+ }
+}
+
+typeof_eq_undefined_ie8: {
+ options = {
+ comparisons: true,
+ screw_ie8: false
+ }
+ input: {
+ var a = typeof b != "undefined";
+ b = typeof a != "undefined";
+ var c = typeof d.e !== "undefined";
+ var f = "undefined" === typeof g;
+ g = "undefined" === typeof f;
+ var h = "undefined" == typeof i.j;
+ }
+ expect: {
+ var a = "undefined" != typeof b;
+ b = void 0 !== a;
+ var c = "undefined" != typeof d.e;
+ var f = "undefined" == typeof g;
+ g = void 0 === f;
+ var h = "undefined" == typeof i.j;
+ }
+}
+
+undefined_redefined: {
+ options = {
+ comparisons: true
+ }
+ input: {
+ function f(undefined) {
+ var n = 1;
+ return typeof n == "undefined";
+ }
+ }
+ expect_exact: "function f(undefined){var n=1;return void 0===n}"
+}
+
+undefined_redefined_mangle: {
+ options = {
+ comparisons: true
+ }
+ mangle = {}
+ input: {
+ function f(undefined) {
+ var n = 1;
+ return typeof n == "undefined";
+ }
+ }
+ expect_exact: "function f(n){var r=1;return void 0===r}"
+}