Files
test-repo/tests/singleton/__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

149 lines
2.6 KiB
Plaintext

exports[`test boolean.js 1`] = `
"/* @flow */
function veryOptimistic(isThisAwesome: true): boolean {
return isThisAwesome;
}
var x : boolean = veryOptimistic(true);
var y : boolean = veryOptimistic(false); // error
function veryPessimistic(isThisAwesome: true): boolean {
return !isThisAwesome; // test bool conversion
}
var x : boolean = veryPessimistic(true);
var y : boolean = veryPessimistic(false); // error
type MyOwnBooleanLOL = true | false
function bar(x: MyOwnBooleanLOL): false {
if (x) {
return x;
} else {
return !x;
}
}
bar(true);
bar(false);
bar(1); // error
function alwaysFalsy(x: boolean): false {
if (x) {
return !x;
} else {
return x;
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
function veryOptimistic(isThisAwesome: true): boolean {
return isThisAwesome;
}
var x: boolean = veryOptimistic(true);
var y: boolean = veryOptimistic(false);
// error
function veryPessimistic(isThisAwesome: true): boolean {
return !isThisAwesome; // test bool conversion
}
var x: boolean = veryPessimistic(true);
var y: boolean = veryPessimistic(false);
// error
type MyOwnBooleanLOL = true | false;
function bar(x: MyOwnBooleanLOL): false {
if (x) {
return x;
} else {
return !x;
}
}
bar(true);
bar(false);
bar(1);
// error
function alwaysFalsy(x: boolean): false {
if (x) {
return !x;
} else {
return x;
}
}
"
`;
exports[`test number.js 1`] = `
"/* @flow */
function highlander(howMany: 1): number {
return howMany; // there can be only one!
}
highlander(1);
highlander(2); // error
type Foo = 1 | 2
function bar(num: Foo): number {
return num + 1;
}
bar(1);
bar(2);
bar(3); // error
type ComparatorResult = -1 | 0 | 1
function sort(fn: (x: any, y: any) => ComparatorResult) {}
sort((x, y) => -1);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
function highlander(howMany: 1): number {
return howMany; // there can be only one!
}
highlander(1);
highlander(2);
// error
type Foo = 1 | 2;
function bar(num: Foo): number {
return num + 1;
}
bar(1);
bar(2);
bar(3);
// error
type ComparatorResult = -1 | 0 | 1;
function sort(fn: (x: any, y: any) => ComparatorResult) {
}
sort((x, y) => -1);
"
`;
exports[`test string.js 1`] = `
"/* @flow */
type NoSpaces = \"foobar\"
(\"foobar\": NoSpaces);
type HasSpaces = \"foo bar\"
(\"foo bar\": HasSpaces);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
type NoSpaces = \"foobar\";
(\"foobar\": NoSpaces);
type HasSpaces = \"foo bar\";
(\"foo bar\": HasSpaces);
"
`;