Files
test-repo/tests/flow/forof/forof.js
T
Christopher Chedeau 3375cfe605 Move tests around (#454)
* new_tests

* move_all_clobbered_tests

* remove all the tests that no longer exist

* re-run flow tests

* Move all the flow tests to tests/flow and prettier to tests/

* Move prettier tests to their own folders

* Add jsfmt files

* run prettier snapshot tests
2017-01-24 14:35:37 -08:00

54 lines
1.0 KiB
JavaScript

/**
* @flow
*/
function testArray(arr: Array<number>): void {
for (var x of arr) {
(x: string); // Error - number ~> string
}
}
function testIterable1(iterable: Iterable<number>): void {
for (var x of iterable) {
(x: string); // Error - number ~> string
}
}
function testIterable2(iterable: Iterable<*>): void {
for (var x of iterable) {
(x: string);
}
}
function testString(str: string): void {
for (var x of str) {
(x: number); // Error - string ~> number
}
}
function testMap1(map: Map<string, number>): void {
for (var elem of map) {
(elem: [string, number]);
(elem: number); // Error - tuple ~> number
}
}
function testMap2(map: Map<*, *>): void {
for (var elem of map) {
(elem: [number, string]); // Any tuple is fine
(elem: number); // Error - tuple ~> number
}
}
function testSet1(set: Set<string>): void {
for (var x of set) {
(x: number); // Error - string ~> number
}
}
function testSet2(set: Set<*>): void {
for (var x of set) {
(x: number); // Anything goes
}
}