diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-02-01 16:50:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-01 16:50:54 +0800 |
commit | fad6766a905350574b698af707958294e22184f3 (patch) | |
tree | 351ba576da9fcfc99a020d06dfc9f53e094689fe /test | |
parent | aa664dea0a07656d1fa61263e3a03e7d8b5c4cc9 (diff) | |
download | tracifyjs-fad6766a905350574b698af707958294e22184f3.tar.gz tracifyjs-fad6766a905350574b698af707958294e22184f3.zip |
simplify comparisons with `undefined` & `null` (#2862)
fixes #2857
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/comparing.js | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/test/compress/comparing.js b/test/compress/comparing.js index e374b585..d581d086 100644 --- a/test/compress/comparing.js +++ b/test/compress/comparing.js @@ -112,3 +112,133 @@ self_comparison_2: { } expect_stdout: "false true" } + +issue_2857_1: { + options = { + comparisons: true, + } + input: { + a === undefined || a === null; + a === undefined || a !== null; + a !== undefined || a === null; + a !== undefined || a !== null; + a === undefined && a === null; + a === undefined && a !== null; + a !== undefined && a === null; + a !== undefined && a !== null; + } + expect: { + null == a; + void 0 === a || null !== a; + void 0 !== a || null === a; + void 0 !== a || null !== a; + void 0 === a && null === a; + void 0 === a && null !== a; + void 0 !== a && null === a; + null != a; + } +} + +issue_2857_2: { + options = { + comparisons: true, + } + input: { + a === undefined || a === null || p; + a === undefined || a !== null || p; + a !== undefined || a === null || p; + a !== undefined || a !== null || p; + a === undefined && a === null || p; + a === undefined && a !== null || p; + a !== undefined && a === null || p; + a !== undefined && a !== null || p; + } + expect: { + null == a || p; + void 0 === a || null !== a || p; + void 0 !== a || null === a || p; + void 0 !== a || null !== a || p; + void 0 === a && null === a || p; + void 0 === a && null !== a || p; + void 0 !== a && null === a || p; + null != a || p; + } +} + +issue_2857_3: { + options = { + comparisons: true, + } + input: { + a === undefined || a === null && p; + a === undefined || a !== null && p; + a !== undefined || a === null && p; + a !== undefined || a !== null && p; + a === undefined && a === null && p; + a === undefined && a !== null && p; + a !== undefined && a === null && p; + a !== undefined && a !== null && p; + } + expect: { + void 0 === a || null === a && p; + void 0 === a || null !== a && p; + void 0 !== a || null === a && p; + void 0 !== a || null !== a && p; + void 0 === a && null === a && p; + void 0 === a && null !== a && p; + void 0 !== a && null === a && p; + null != a && p; + } +} + +issue_2857_4: { + options = { + comparisons: true, + } + input: { + p || a === undefined || a === null; + p || a === undefined || a !== null; + p || a !== undefined || a === null; + p || a !== undefined || a !== null; + p || a === undefined && a === null; + p || a === undefined && a !== null; + p || a !== undefined && a === null; + p || a !== undefined && a !== null; + } + expect: { + p || null == a; + p || void 0 === a || null !== a; + p || void 0 !== a || null === a; + p || void 0 !== a || null !== a; + p || void 0 === a && null === a; + p || void 0 === a && null !== a; + p || void 0 !== a && null === a; + p || null != a; + } +} + +issue_2857_5: { + options = { + comparisons: true, + } + input: { + p && a === undefined || a === null; + p && a === undefined || a !== null; + p && a !== undefined || a === null; + p && a !== undefined || a !== null; + p && a === undefined && a === null; + p && a === undefined && a !== null; + p && a !== undefined && a === null; + p && a !== undefined && a !== null; + } + expect: { + p && void 0 === a || null === a; + p && void 0 === a || null !== a; + p && void 0 !== a || null === a; + p && void 0 !== a || null !== a; + p && void 0 === a && null === a; + p && void 0 === a && null !== a; + p && void 0 !== a && null === a; + p && null != a; + } +} |