Add tests for scoping

This commit is contained in:
Jason Freeman
2015-03-01 18:16:20 -08:00
parent 8da49aaf44
commit cb97686496
15 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
tests/cases/conformance/es6/for-ofStatements/for-of51.ts(1,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
==== tests/cases/conformance/es6/for-ofStatements/for-of51.ts (1 errors) ====
for (let let of []) {}
~~~
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.

View File

@@ -0,0 +1,5 @@
//// [for-of51.ts]
for (let let of []) {}
//// [for-of51.js]
for (let let of []) { }

View File

@@ -0,0 +1,10 @@
tests/cases/conformance/es6/for-ofStatements/for-of52.ts(1,11): error TS2451: Cannot redeclare block-scoped variable 'v'.
tests/cases/conformance/es6/for-ofStatements/for-of52.ts(1,14): error TS2451: Cannot redeclare block-scoped variable 'v'.
==== tests/cases/conformance/es6/for-ofStatements/for-of52.ts (2 errors) ====
for (let [v, v] of [[]]) {}
~
!!! error TS2451: Cannot redeclare block-scoped variable 'v'.
~
!!! error TS2451: Cannot redeclare block-scoped variable 'v'.

View File

@@ -0,0 +1,5 @@
//// [for-of52.ts]
for (let [v, v] of [[]]) {}
//// [for-of52.js]
for (let [v, v] of [[]]) { }

View File

@@ -0,0 +1,9 @@
//// [for-of53.ts]
for (let v of []) {
var v;
}
//// [for-of53.js]
for (let v of []) {
var v;
}

View File

@@ -0,0 +1,8 @@
=== tests/cases/conformance/es6/for-ofStatements/for-of53.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
var v;
>v : any
}

View File

@@ -0,0 +1,9 @@
tests/cases/conformance/es6/for-ofStatements/for-of54.ts(2,9): error TS2481: Cannot initialize outer scoped variable 'v' in the same scope as block scoped declaration 'v'.
==== tests/cases/conformance/es6/for-ofStatements/for-of54.ts (1 errors) ====
for (let v of []) {
var v = 0;
~
!!! error TS2481: Cannot initialize outer scoped variable 'v' in the same scope as block scoped declaration 'v'.
}

View File

@@ -0,0 +1,9 @@
//// [for-of54.ts]
for (let v of []) {
var v = 0;
}
//// [for-of54.js]
for (let v of []) {
var v = 0;
}

View File

@@ -0,0 +1,11 @@
//// [for-of55.ts]
let v = [1];
for (let v of v) {
v;
}
//// [for-of55.js]
let v = [1];
for (let v of v) {
v;
}

View File

@@ -0,0 +1,12 @@
=== tests/cases/conformance/es6/for-ofStatements/for-of55.ts ===
let v = [1];
>v : number[]
>[1] : number[]
for (let v of v) {
>v : any
>v : any
v;
>v : any
}

View File

@@ -0,0 +1,2 @@
//@target: ES6
for (let let of []) {}

View File

@@ -0,0 +1,2 @@
//@target: ES6
for (let [v, v] of [[]]) {}

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
//@target: ES6
let v = [1];
for (let v of v) {
v;
}