Merge pull request #7165 from Microsoft/add-tests-for-let

Add tests for let declarations/identifier variables
This commit is contained in:
Daniel Rosenwasser
2016-02-20 13:16:47 -08:00
11 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
//// [VariableDeclaration12_es6.ts]
let
x
//// [VariableDeclaration12_es6.js]
let x;

View File

@@ -0,0 +1,6 @@
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration12_es6.ts ===
let
x
>x : Symbol(x, Decl(VariableDeclaration12_es6.ts, 1, 3))

View File

@@ -0,0 +1,6 @@
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration12_es6.ts ===
let
x
>x : any

View File

@@ -0,0 +1,20 @@
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,5): error TS1181: Array element destructuring pattern expected.
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,6): error TS1005: ',' expected.
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,8): error TS1134: Variable declaration expected.
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,10): error TS1134: Variable declaration expected.
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts (4 errors) ====
// An ExpressionStatement cannot start with the two token sequence `let [` because
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
var let: any;
let[0] = 100;
~
!!! error TS1181: Array element destructuring pattern expected.
~
!!! error TS1005: ',' expected.
~
!!! error TS1134: Variable declaration expected.
~~~
!!! error TS1134: Variable declaration expected.

View File

@@ -0,0 +1,13 @@
//// [VariableDeclaration13_es6.ts]
// An ExpressionStatement cannot start with the two token sequence `let [` because
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
var let: any;
let[0] = 100;
//// [VariableDeclaration13_es6.js]
// An ExpressionStatement cannot start with the two token sequence `let [` because
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
var let;
let [] = 0;
100;

View File

@@ -0,0 +1,7 @@
//// [letIdentifierInElementAccess01.ts]
var let: any = {};
(let[0] = 100);
//// [letIdentifierInElementAccess01.js]
var let = {};
(let[0] = 100);

View File

@@ -0,0 +1,7 @@
=== tests/cases/conformance/expressions/elementAccess/letIdentifierInElementAccess01.ts ===
var let: any = {};
>let : Symbol(let, Decl(letIdentifierInElementAccess01.ts, 0, 3))
(let[0] = 100);
>let : Symbol(let, Decl(letIdentifierInElementAccess01.ts, 0, 3))

View File

@@ -0,0 +1,13 @@
=== tests/cases/conformance/expressions/elementAccess/letIdentifierInElementAccess01.ts ===
var let: any = {};
>let : any
>{} : {}
(let[0] = 100);
>(let[0] = 100) : number
>let[0] = 100 : number
>let[0] : any
>let : any
>0 : number
>100 : number

View File

@@ -0,0 +1,4 @@
// @target:es6
let
x

View File

@@ -0,0 +1,6 @@
// @target:es6
// An ExpressionStatement cannot start with the two token sequence `let [` because
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
var let: any;
let[0] = 100;

View File

@@ -0,0 +1,2 @@
var let: any = {};
(let[0] = 100);