Files
test-repo/tests/misc/__snapshots__/jsfmt.spec.js.snap
T
Christopher Chedeau 74bc9e7a4d Add newline for empty blocks {} (#205)
I find it weird to put `{}` together. So I figured I would change it to have an empty line and ask for feedback :)

![image](https://cloud.githubusercontent.com/assets/197597/21739279/062adc80-d44c-11e6-8bb7-5e0768f3ddde.png)

Beware: most of the test cases are not representative of real code, you almost never define blocks with no content in practice.
2017-01-16 11:31:32 -05:00

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();
"
`;