- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases - This creates snapshot tests using the pretty printer for all of them - If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.
32 lines
743 B
JavaScript
32 lines
743 B
JavaScript
/**
|
|
* Tests for intersections of function types.
|
|
*
|
|
* Note: Flow abuses intersection types to model
|
|
* function overloading, which precludes using a
|
|
* correct intersection of return types in the result.
|
|
*
|
|
* Here we test the special case where return types
|
|
* are equal. Tests of the overloading behavior can
|
|
* be found in tests/overload
|
|
*
|
|
* Definitions lin lib/lib.js
|
|
*
|
|
* @noflow
|
|
*/
|
|
|
|
// intersection of function types satisfies union of param types
|
|
|
|
type F = (_: ObjA) => void;
|
|
type G = (_: ObjB) => void;
|
|
type FG = (_: ObjA | ObjB) => void;
|
|
|
|
declare var fun1 : F & G;
|
|
|
|
(fun1 : FG);
|
|
|
|
var fun2 : FG = fun1;
|
|
|
|
// simpler variation
|
|
declare var f : ((_: number) => void) & ((_: string) => void);
|
|
var g: (_: number | string) => void = f;
|