exports[`test array.js 1`] = ` "/* @flow */ var arrayTest1: Iterable = ([1, 2]: Array); var arrayTest2: Iterable = [1,2,\"hi\"]; var arrayTest3: Iterable<*> = [1,2,3]; // Error string ~> number var arrayTest4: Iterable = [\"hi\"]; // Error string ~> number var arrayTest5: Iterable = [\"hi\", 1]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ var arrayTest1: Iterable = ([ 1, 2 ]: Array); var arrayTest2: Iterable = [ 1, 2, \"hi\" ]; var arrayTest3: Iterable<*> = [ 1, 2, 3 ]; // Error string ~> number var arrayTest4: Iterable = [ \"hi\" ]; // Error string ~> number var arrayTest5: Iterable = [ \"hi\", 1 ]; " `; exports[`test caching_bug.js 1`] = ` "/* @flow */ /** * I\'ve hit a bug with the caching in flow_js.ml. Avik is removing that caching * so it should be fixed soon. The basic idea is I flow something like * * Array ~> Iterable * * then Flow won\'t notice when I try to flow * * Array ~> Iterable * * We shouldn\'t hit the cache because the union types are different, but we do * anyway. I\'ve fixed this temporarily by bumping the \"meaningful\" param to * Hashtbl.hash_param */ function fill_the_cache(x: Array): Iterable { return x; } // Error: number ~> string function miss_the_cache(x: Array): Iterable { return x; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ /** * I\'ve hit a bug with the caching in flow_js.ml. Avik is removing that caching * so it should be fixed soon. The basic idea is I flow something like * * Array ~> Iterable * * then Flow won\'t notice when I try to flow * * Array ~> Iterable * * We shouldn\'t hit the cache because the union types are different, but we do * anyway. I\'ve fixed this temporarily by bumping the \"meaningful\" param to * Hashtbl.hash_param */ function fill_the_cache(x: Array): Iterable { return x; } // Error: number ~> string function miss_the_cache(x: Array): Iterable { return x; } " `; exports[`test iter.js 1`] = ` "/* @flow */ function foo(strs: Iterable): void { for (var s: string of strs) { console.log(s); } } var m: Map = new Map(); foo(m.keys()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ function foo(strs: Iterable): void { for (var s: string of strs) { console.log(s); } } var m: Map = new Map(); foo(m.keys()); " `; exports[`test iterator_result.js 1`] = ` "/* @flow */ function makeIterator(coin_flip: () => boolean ): Iterator { return { \"@@iterator\"() { return makeIterator(coin_flip); }, next(): IteratorResult { var done = coin_flip(); if (!done) { return { done, value: \"still going...\" }; } else { return { done }; } } } } function makeIterator(coin_flip: () => boolean ): Iterator { return { \"@@iterator\"() { return makeIterator(coin_flip); }, next(): IteratorResult { var done = coin_flip(); if (done) { // Whoops, made a mistake and forgot to negate done return { done, value: \"still going...\" }; // Error string ~> void } else { return { done }; // Error void ~> string } } } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ function makeIterator(coin_flip: () => boolean): Iterator { return { \"@@iterator\"() { return makeIterator(coin_flip); }, next(): IteratorResult { var done = coin_flip(); if (!done) { return { done, value: \"still going...\" }; } else { return { done }; } } }; } function makeIterator(coin_flip: () => boolean): Iterator { return { \"@@iterator\"() { return makeIterator(coin_flip); }, next(): IteratorResult { var done = coin_flip(); if (done) { // Whoops, made a mistake and forgot to negate done return { done, value: \"still going...\" }; // Error string ~> void } else { return { done }; // Error void ~> string } } }; } " `; exports[`test map.js 1`] = ` "/* @flow */ function mapTest1(map: Map): Iterable<[string, number]> { return map; } function mapTest2(map: Map): Iterable<[K, V]> { return map; }; function mapTest3(map: Map): Iterable<*> { return map; } // Error - Map is an Iterable<[K, V]> function mapTest4(map: Map): Iterable { return map; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ function mapTest1(map: Map): Iterable<[string, number]> { return map; } function mapTest2(map: Map): Iterable<[K, V]> { return map; } function mapTest3(map: Map): Iterable<*> { return map; } // Error - Map is an Iterable<[K, V]> function mapTest4(map: Map): Iterable { return map; } " `; exports[`test set.js 1`] = ` "/* @flow */ function setTest1(set: Set): Iterable { return set; } function setTest2(set: Set): Iterable { return set; }; function setTest3(set: Set): Iterable<*> { return set; } // Error string ~> number function setTest4(set: Set): Iterable { return set; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ function setTest1(set: Set): Iterable { return set; } function setTest2(set: Set): Iterable { return set; } function setTest3(set: Set): Iterable<*> { return set; } // Error string ~> number function setTest4(set: Set): Iterable { return set; } " `; exports[`test string.js 1`] = ` "/* @flow */ var stringTest1: Iterable = \"hi\"; var stringTest3: Iterable<*> = \"hi\"; var stringTest3: Iterable = \"hi\"; // Error - string is a Iterable ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ var stringTest1: Iterable = \"hi\"; var stringTest3: Iterable<*> = \"hi\"; var stringTest3: Iterable = \"hi\"; // Error - string is a Iterable " `; exports[`test variance.js 1`] = ` "/* @flow */ (([]: Array): Iterable); // ok, Iterable<+T> (([]: Array).values(): Iterable); // ok, Iterator<+T> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ (([]: Array): Iterable); // ok, Iterable<+T> (([]: Array).values(): Iterable); // ok, Iterator<+T> " `;