- 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.
37 lines
620 B
JavaScript
37 lines
620 B
JavaScript
// @flow
|
|
|
|
let ws = new WeakSet();
|
|
let obj: Object = {};
|
|
let dict: {foo: string} = {foo: 'bar'};
|
|
|
|
ws.add(window);
|
|
ws.add(obj);
|
|
ws.add(dict);
|
|
ws.has(window);
|
|
ws.has(obj);
|
|
ws.has(dict);
|
|
ws.delete(window);
|
|
ws.delete(obj);
|
|
ws.delete(dict);
|
|
|
|
let ws2 = new WeakSet([obj, dict]);
|
|
|
|
let ws3 = new WeakSet([1, 2, 3]); // error, must be objects
|
|
|
|
function* generator(): Iterable<{foo: string}> {
|
|
while (true) {
|
|
yield {foo: 'bar'};
|
|
}
|
|
}
|
|
|
|
let ws4 = new WeakSet(generator());
|
|
|
|
function* numbers(): Iterable<number> {
|
|
let i = 0;
|
|
while (true) {
|
|
yield i++;
|
|
}
|
|
}
|
|
|
|
let ws5 = new WeakSet(numbers()); // error, must be objects
|