- 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.
27 lines
674 B
JavaScript
27 lines
674 B
JavaScript
/**
|
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
*/
|
|
var tests = [
|
|
() => {
|
|
// erroneous typcasts raise errors...
|
|
var n = ("hey" : number);
|
|
// ...but 'any' does dynamic downcasts, if you must
|
|
var x: number = ("hey": any);
|
|
var y = (("hey": any): number);
|
|
},
|
|
|
|
() => {
|
|
// typecasts in sequences
|
|
// (parens always required around typecasts)
|
|
var s: string = ((0: number), ("hey": string));
|
|
},
|
|
|
|
() => {
|
|
// TODO pending array element inference issues
|
|
// control case:
|
|
// var a : Array<?number> = [0, 1, 2, 3, 4, 5, 6, 7, null];
|
|
// typecast case:
|
|
// var b = [(0 : ?number), 1, 2, 3, 4, 5, 6, 7, null];
|
|
}
|
|
];
|