Files
test-repo/tests/refinements/void.js
T
Christopher Chedeau cf45afba61 Add testing
- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases
- This creates snapshot tests using the pretty printer for all of them
- If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.
2016-12-23 19:51:53 +00:00

96 lines
1.6 KiB
JavaScript

/* @flow */
function void_var(x: ?number) {
if (x !== null && x !== void(0)) {
var y = x * 1000;
}
}
function void_var_rev(x: ?number) {
if (x === null || x === void(0)) {
} else {
var y = x * 1000;
}
}
function void_pro(x: { x: ?number }) {
if (x.x !== null && x.x !== void(0)) {
var y = x.x * 1000;
}
}
function void_pro_rev(x: { x: ?number }) {
if (x.x === null || x.x === void(0)) {
} else {
var y = x.x * 1000;
}
}
function void_var_fail(x: ?number) {
if (x !== void(0)) {
var y = x * 1000;
}
}
function void_var_fail_rev(x: ?number) {
if (x === void(0)) {
} else {
var y = x * 1000;
}
}
function void_pro_fail(x: { x: ?number }) {
if (x.x !== void(0)) {
var y = x.x * 1000;
}
}
function void_pro_fail_rev(x: { x: ?number }) {
if (x.x === void(0)) {
} else {
var y = x.x * 1000;
}
}
function void_var_side_effect(x: ?number) {
if (x !== null && x !== void(x * 1000)) {
var y = x * 1000;
}
}
function void_var_side_effect_rev(x: ?number) {
if (x === null || x === void(x * 1000)) {
} else {
var y = x * 1000;
}
}
function void_prop_side_effect(x: { x: ?number }) {
if (x.x !== null && x.x !== void(x.x * 1000)) {
var y = x.x * 1000;
}
}
function void_prop_side_effect_rev(x: { x: ?number }) {
if (x.x === null || x.x === void(x.x * 1000)) {
} else {
var y = x.x * 1000;
}
}
function void_bogus_comparison() {
if (100 * void(0)) {
return;
}
if (void(0) * 100) {
return;
}
}
function void_redefined_undefined(x: ?number) {
var undefined = "foo";
if (x !== null && x !== void(0)) {
var y = x * 1000;
}
}