Add tests and accept correct baselines

This commit is contained in:
Jason Freeman 2015-02-20 18:00:03 -08:00
parent 277c931a0d
commit ec9e563238
25 changed files with 195 additions and 2 deletions

View file

@ -0,0 +1,8 @@
tests/cases/conformance/es6/for-ofStatements/for-of10.ts(2,6): error TS2322: Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/es6/for-ofStatements/for-of10.ts (1 errors) ====
var v: string;
for (v of [0]) { }
~
!!! error TS2322: Type 'number' is not assignable to type 'string'.

View file

@ -0,0 +1,7 @@
//// [for-of10.ts]
var v: string;
for (v of [0]) { }
//// [for-of10.js]
var v;
for (v of [0]) { }

View file

@ -0,0 +1,10 @@
tests/cases/conformance/es6/for-ofStatements/for-of11.ts(2,6): error TS2322: Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/es6/for-ofStatements/for-of11.ts (1 errors) ====
var v: string;
for (v of [0, ""]) { }
~
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.

View file

@ -0,0 +1,7 @@
//// [for-of11.ts]
var v: string;
for (v of [0, ""]) { }
//// [for-of11.js]
var v;
for (v of [0, ""]) { }

View file

@ -0,0 +1,10 @@
tests/cases/conformance/es6/for-ofStatements/for-of12.ts(2,6): error TS2322: Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/es6/for-ofStatements/for-of12.ts (1 errors) ====
var v: string;
for (v of [0, ""].values()) { }
~
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.

View file

@ -0,0 +1,7 @@
//// [for-of12.ts]
var v: string;
for (v of [0, ""].values()) { }
//// [for-of12.js]
var v;
for (v of [0, ""].values()) { }

View file

@ -0,0 +1,7 @@
//// [for-of13.ts]
var v: string;
for (v of [""].values()) { }
//// [for-of13.js]
var v;
for (v of [""].values()) { }

View file

@ -0,0 +1,11 @@
=== tests/cases/conformance/es6/for-ofStatements/for-of13.ts ===
var v: string;
>v : string
for (v of [""].values()) { }
>v : string
>[""].values() : IterableIterator<string>
>[""].values : () => IterableIterator<string>
>[""] : string[]
>values : () => IterableIterator<string>

View file

@ -1,8 +1,8 @@
tests/cases/conformance/es6/for-ofStatements/for-of3.ts(2,6): error TS2486: Invalid left-hand side in 'for...of' statement.
tests/cases/conformance/es6/for-ofStatements/for-of3.ts(2,6): error TS2487: Invalid left-hand side in 'for...of' statement.
==== tests/cases/conformance/es6/for-ofStatements/for-of3.ts (1 errors) ====
var v;
for (v++ of []) { }
~~~
!!! error TS2486: Invalid left-hand side in 'for...of' statement.
!!! error TS2487: Invalid left-hand side in 'for...of' statement.

View file

@ -0,0 +1,9 @@
//// [for-of9.ts]
var v: string;
for (v of ["hello"]) { }
for (v of "hello") { }
//// [for-of9.js]
var v;
for (v of ["hello"]) { }
for (v of "hello") { }

View file

@ -0,0 +1,11 @@
=== tests/cases/conformance/es6/for-ofStatements/for-of9.ts ===
var v: string;
>v : string
for (v of ["hello"]) { }
>v : string
>["hello"] : string[]
for (v of "hello") { }
>v : string

View file

@ -0,0 +1,5 @@
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement18.ts ===
for (var of of of) { }
>of : any
>of : any

View file

@ -0,0 +1,5 @@
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement8.ts ===
for (var v of X) {
>v : any
>X : unknown
}

View file

@ -0,0 +1,5 @@
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement9.ts ===
for (let v of X) {
>v : any
>X : unknown
}

View file

@ -0,0 +1,3 @@
//@target: ES6
var v: string;
for (v of [0]) { }

View file

@ -0,0 +1,3 @@
//@target: ES6
var v: string;
for (v of [0, ""]) { }

View file

@ -0,0 +1,3 @@
//@target: ES6
var v: string;
for (v of [0, ""].values()) { }

View file

@ -0,0 +1,3 @@
//@target: ES6
var v: string;
for (v of [""].values()) { }

View file

@ -0,0 +1,9 @@
//@target: ES6
var v: string;
for (v of new StringIterator) { } // Should fail because the iterator is not iterable
class StringIterator implements Iterator<string> {
next() {
return "";
}
}

View file

@ -0,0 +1,12 @@
//@target: ES6
var v: string;
for (v of new StringIterator) { } // Should succeed
class StringIterator implements Iterator<string> {
next() {
return "";
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,12 @@
//@target: ES6
var v: string;
for (v of (new StringIterator)[Symbol.iterator]()) { } // Should succeed
class StringIterator implements Iterator<string> {
next() {
return "";
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,12 @@
//@target: ES6
var v: number;
for (v of (new NumberIterator)[Symbol.iterator]().next()) { } // Should fail
class NumberIterator {
next() {
return 0;
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,15 @@
//@target: ES6
var v: string;
for (v of (new StringIterator)[Symbol.iterator]().next()) { } // Should succeed
class StringIterator {
next() {
return {
value: "",
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,15 @@
//@target: ES6
var v: string;
for (v of (new StringIterator)[Symbol.iterator]().next()) { } // Should fail
class StringIterator {
next() {
return {
value: 0,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,4 @@
//@target: ES6
var v: string;
for (v of ["hello"]) { }
for (v of "hello") { }