aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compress/hoist_props.js2
-rw-r--r--test/compress/numbers.js82
2 files changed, 81 insertions, 3 deletions
diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js
index 0d8e771a..c647ccc1 100644
--- a/test/compress/hoist_props.js
+++ b/test/compress/hoist_props.js
@@ -664,7 +664,7 @@ issue_2519: {
}
expect: {
function testFunc() {
- return 1 * ((6 + 5) / 2);
+ return +((6 + 5) / 2);
}
console.log(testFunc());
}
diff --git a/test/compress/numbers.js b/test/compress/numbers.js
index 673ce23a..c432a435 100644
--- a/test/compress/numbers.js
+++ b/test/compress/numbers.js
@@ -91,7 +91,7 @@ evaluate_1: {
expect: {
console.log(
x + 1 + 2,
- 1 * x * 2,
+ 2 * x,
+x + 1 + 2,
1 + x + 2 + 3,
3 | x,
@@ -173,7 +173,7 @@ evaluate_2: {
var x = "42", y = null;
[
x + 1 + 2,
- 1 * x * 2,
+ 2 * x,
+x + 1 + 2,
1 + x + 2 + 3,
3 | x,
@@ -979,3 +979,81 @@ unsafe_math_swap_constant: {
}
expect_stdout: "6 6 7 6 6 8 9 10"
}
+
+identity_1: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ 0 + a;
+ a + 0;
+ 0 - a;
+ a - 0;
+ 1 * a;
+ a * 1;
+ 1 / a;
+ a / 1;
+ }
+ expect: {
+ 0 + a;
+ a + 0;
+ -a;
+ +a;
+ +a;
+ +a;
+ 1 / a;
+ +a;
+ }
+}
+
+identity_2: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ 0 + !a;
+ !a + 0;
+ 0 - !a;
+ !a - 0;
+ 1 * !a;
+ !a * 1;
+ 1 / !a;
+ !a / 1;
+ }
+ expect: {
+ +!a;
+ +!a;
+ -!a;
+ +!a;
+ +!a;
+ +!a;
+ 1 / !a;
+ +!a;
+ }
+}
+
+identity_3: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ 0 + --a;
+ --a + 0;
+ 0 - --a;
+ --a - 0;
+ 1 * --a;
+ --a * 1;
+ 1 / --a;
+ --a / 1;
+ }
+ expect: {
+ --a;
+ --a;
+ - --a;
+ --a;
+ --a;
+ --a;
+ 1 / --a;
+ --a;
+ }
+}