I find it weird to put `{}` together. So I figured I would change it to have an empty line and ask for feedback :)

Beware: most of the test cases are not representative of real code, you almost never define blocks with no content in practice.
120 lines
2.1 KiB
Plaintext
120 lines
2.1 KiB
Plaintext
exports[`test in.js 1`] = `
|
|
"// @flow
|
|
|
|
let tests = [
|
|
// objects on RHS
|
|
function() {
|
|
(\'foo\' in {});
|
|
(\'foo\' in { foo: null });
|
|
(0 in {});
|
|
(0 in { \"0\": null });
|
|
},
|
|
|
|
// arrays on RHS
|
|
function() {
|
|
(\'foo\' in []);
|
|
(0 in []);
|
|
(\'length\' in []);
|
|
},
|
|
|
|
// primitive classes on RHS
|
|
function() {
|
|
(\'foo\' in new String(\'bar\'));
|
|
(\'foo\' in new Number(123));
|
|
},
|
|
|
|
// primitives on RHS
|
|
function() {
|
|
(\'foo\' in 123); // error
|
|
(\'foo\' in \'bar\'); // error
|
|
(\'foo\' in void 0); // error
|
|
(\'foo\' in null); // error
|
|
},
|
|
|
|
// bogus stuff on LHS
|
|
function() {
|
|
(null in {}); // error
|
|
(void 0 in {}); // error
|
|
({} in {}); // error
|
|
([] in {}); // error
|
|
(false in []); // error
|
|
},
|
|
|
|
// in predicates
|
|
function() {
|
|
if (\'foo\' in 123) {} // error
|
|
if (!\'foo\' in {}) {} // error, !\'foo\' is a boolean
|
|
if (!(\'foo\' in {})) {}
|
|
},
|
|
|
|
// annotations on RHS
|
|
function(x: Object, y: mixed) {
|
|
(\'foo\' in x); // ok
|
|
(\'foo\' in y); // error
|
|
},
|
|
]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// @flow
|
|
|
|
let tests = [
|
|
// objects on RHS
|
|
function() {
|
|
\"foo\" in {};
|
|
\"foo\" in { foo: null };
|
|
0 in {};
|
|
0 in { \"0\": null };
|
|
},
|
|
// arrays on RHS
|
|
function() {
|
|
\"foo\" in [];
|
|
0 in [];
|
|
\"length\" in [];
|
|
},
|
|
// primitive classes on RHS
|
|
function() {
|
|
\"foo\" in new String(\"bar\");
|
|
\"foo\" in new Number(123);
|
|
},
|
|
// primitives on RHS
|
|
function() {
|
|
\"foo\" in 123;
|
|
// error
|
|
\"foo\" in \"bar\";
|
|
// error
|
|
\"foo\" in void 0;
|
|
// error
|
|
\"foo\" in null; // error
|
|
},
|
|
// bogus stuff on LHS
|
|
function() {
|
|
null in {};
|
|
// error
|
|
void 0 in {};
|
|
// error
|
|
({}) in {};
|
|
// error
|
|
[] in {};
|
|
// error
|
|
false in []; // error
|
|
},
|
|
// in predicates
|
|
function() {
|
|
if (\"foo\" in 123) {
|
|
}
|
|
// error
|
|
if (!\"foo\" in {}) {
|
|
}
|
|
// error, !\'foo\' is a boolean
|
|
if (!(\"foo\" in {})) {
|
|
}
|
|
},
|
|
// annotations on RHS
|
|
function(x: Object, y: mixed) {
|
|
\"foo\" in x;
|
|
// ok
|
|
\"foo\" in y; // error
|
|
}
|
|
];
|
|
"
|
|
`;
|