171 lines
3.7 KiB
Plaintext
171 lines
3.7 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`boolean.js 1`] = `
|
|
====================================options=====================================
|
|
parsers: ["flow"]
|
|
printWidth: 80
|
|
| printWidth
|
|
=====================================input======================================
|
|
/* @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;
|
|
}
|
|
}
|
|
|
|
=====================================output=====================================
|
|
/* @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[`number.js 1`] = `
|
|
====================================options=====================================
|
|
parsers: ["flow"]
|
|
printWidth: 80
|
|
| printWidth
|
|
=====================================input======================================
|
|
/* @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);
|
|
|
|
=====================================output=====================================
|
|
/* @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[`string.js 1`] = `
|
|
====================================options=====================================
|
|
parsers: ["flow"]
|
|
printWidth: 80
|
|
| printWidth
|
|
=====================================input======================================
|
|
/* @flow */
|
|
|
|
type NoSpaces = "foobar"
|
|
("foobar": NoSpaces);
|
|
|
|
type HasSpaces = "foo bar"
|
|
("foo bar": HasSpaces);
|
|
|
|
=====================================output=====================================
|
|
/* @flow */
|
|
|
|
type NoSpaces = "foobar";
|
|
("foobar": NoSpaces);
|
|
|
|
type HasSpaces = "foo bar";
|
|
("foo bar": HasSpaces);
|
|
|
|
================================================================================
|
|
`;
|