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.
198 lines
3.0 KiB
Plaintext
198 lines
3.0 KiB
Plaintext
exports[`test A.js 1`] = `
|
|
"
|
|
/* @providesModule A */
|
|
|
|
module.exports = {};
|
|
|
|
var A = {x:true, ...{}};
|
|
module.exports.cls = A;
|
|
|
|
function f(x:boolean) { }
|
|
module.exports.fn = f;
|
|
|
|
A.y = \"?\";
|
|
A.x = A.y;
|
|
f(A.x); // A.x is now a string, by def assign
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @providesModule A */
|
|
|
|
module.exports = {};
|
|
|
|
var A = { x: true, ...{} };
|
|
module.exports.cls = A;
|
|
|
|
function f(x: boolean) {
|
|
}
|
|
module.exports.fn = f;
|
|
|
|
A.y = \"?\";
|
|
A.x = A.y;
|
|
f(A.x); // A.x is now a string, by def assign
|
|
"
|
|
`;
|
|
|
|
exports[`test B.js 1`] = `
|
|
"
|
|
/* @providesModule B */
|
|
|
|
var A = require(\'A\').cls;
|
|
|
|
function B() {
|
|
this.b = \"...\";
|
|
}
|
|
|
|
function f():number { return this.b; }
|
|
|
|
B.prototype.s = 0;
|
|
B.prototype.fn = f;
|
|
|
|
module.exports = B;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @providesModule B */
|
|
|
|
var A = require(\"A\").cls;
|
|
|
|
function B() {
|
|
this.b = \"...\";
|
|
}
|
|
|
|
function f(): number {
|
|
return this.b;
|
|
}
|
|
|
|
B.prototype.s = 0;
|
|
B.prototype.fn = f;
|
|
|
|
module.exports = B;
|
|
"
|
|
`;
|
|
|
|
exports[`test C.js 1`] = `
|
|
"
|
|
/* @providesModule C */
|
|
|
|
var B = require(\'B\');
|
|
var f = require(\'A\').fn;
|
|
|
|
function C() {
|
|
var o = new B();
|
|
f(o.b);
|
|
f(o.s);
|
|
o.fn();
|
|
}
|
|
|
|
module.exports = C;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @providesModule C */
|
|
|
|
var B = require(\"B\");
|
|
var f = require(\"A\").fn;
|
|
|
|
function C() {
|
|
var o = new B();
|
|
f(o.b);
|
|
f(o.s);
|
|
o.fn();
|
|
}
|
|
|
|
module.exports = C;
|
|
"
|
|
`;
|
|
|
|
exports[`test D.js 1`] = `
|
|
"
|
|
/* @providesModule D */
|
|
|
|
var f = require(\'A\').fn;
|
|
|
|
function g():string { return this.i; }
|
|
|
|
var o = {fn: g, ...{}};
|
|
o.i = true;
|
|
|
|
var i = o.fn();
|
|
f(i);
|
|
|
|
module.exports = \"D for dummy\";
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @providesModule D */
|
|
|
|
var f = require(\"A\").fn;
|
|
|
|
function g(): string {
|
|
return this.i;
|
|
}
|
|
|
|
var o = { fn: g, ...{} };
|
|
o.i = true;
|
|
|
|
var i = o.fn();
|
|
f(i);
|
|
|
|
module.exports = \"D for dummy\";
|
|
"
|
|
`;
|
|
|
|
exports[`test E.js 1`] = `
|
|
"
|
|
/* @providesModule E */
|
|
|
|
function h(x:number) { }
|
|
var proto = { fn: h }
|
|
|
|
var o = Object.create(proto);
|
|
o.fn(false);
|
|
|
|
module.exports = {obj: o};
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @providesModule E */
|
|
|
|
function h(x: number) {
|
|
}
|
|
var proto = { fn: h };
|
|
|
|
var o = Object.create(proto);
|
|
o.fn(false);
|
|
|
|
module.exports = { obj: o };
|
|
"
|
|
`;
|
|
|
|
exports[`test F.js 1`] = `
|
|
"function fn2(x) { return x.length * 4; }
|
|
fn2({length: \'hi\'});
|
|
|
|
function foo(x: Array<number>): string {
|
|
return x.length;
|
|
}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
function fn2(x) {
|
|
return x.length * 4;
|
|
}
|
|
fn2({ length: \"hi\" });
|
|
|
|
function foo(x: Array<number>): string {
|
|
return x.length;
|
|
}
|
|
"
|
|
`;
|
|
|
|
exports[`test G.js 1`] = `
|
|
"var a = { length: \"duck\" };
|
|
a.length = 123;
|
|
a.length();
|
|
|
|
var b = [ 123 ];
|
|
b.length = \"duck\";
|
|
b.length();
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
var a = { length: \"duck\" };
|
|
a.length = 123;
|
|
a.length();
|
|
|
|
var b = [ 123 ];
|
|
b.length = \"duck\";
|
|
b.length();
|
|
"
|
|
`;
|