fix missing parentheses around NaN/Infinity shorthands (#1726)

fixes #1724
fixes #1725
This commit is contained in:
Alex Lam S.L
2017-03-29 20:53:03 +08:00
committed by GitHub
parent 09f77c7d4d
commit 2e41cd6394
2 changed files with 27 additions and 1 deletions

View File

@@ -107,3 +107,27 @@ beautify_on_2: {
}
expect_exact: "console.log(null.toString(), (void 0).toString());"
}
issue_1724: {
input: {
var a = 0;
++a % Infinity | Infinity ? a++ : 0;
console.log(a);
}
expect: {
var a = 0;
++a % (1/0) | 1/0 ? a++ : 0;
console.log(a);
}
expect_stdout: "2"
}
issue_1725: {
input: {
([].length === 0) % Infinity ? console.log("PASS") : console.log("FAIL");
}
expect: {
(0 === [].length) % (1/0) ? console.log("PASS") : console.log("FAIL");
}
expect_stdout: "PASS"
}