Test case for destructuring of variable statement

This commit is contained in:
Sheetal Nandi
2015-12-09 12:38:13 -08:00
parent 383cbf06c4
commit e28272235c
6 changed files with 581 additions and 0 deletions
@@ -0,0 +1,35 @@
//// [sourceMapValidationDestructuringVariableStatement.ts]
interface Robot {
name: string;
skill: string;
}
declare var console: {
log(msg: string): void;
}
var hello = "hello";
var robotA: Robot = { name: "mower", skill: "mowing" };
var robotB: Robot = { name: "trimmer", skill: "trimming" };
var { name: nameA } = robotA;
var { name: nameB, skill: skillB } = robotB;
var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" };
if (nameA == nameB) {
console.log(skillB);
}
else {
console.log(nameC);
}
//// [sourceMapValidationDestructuringVariableStatement.js]
var hello = "hello";
var robotA = { name: "mower", skill: "mowing" };
var robotB = { name: "trimmer", skill: "trimming" };
var nameA = robotA.name;
var nameB = robotB.name, skillB = robotB.skill;
var _a = { name: "Edger", skill: "cutting edges" }, nameC = _a.name, skillC = _a.skill;
if (nameA == nameB) {
console.log(skillB);
}
else {
console.log(nameC);
}
//# sourceMappingURL=sourceMapValidationDestructuringVariableStatement.js.map
@@ -0,0 +1,2 @@
//// [sourceMapValidationDestructuringVariableStatement.js.map]
{"version":3,"file":"sourceMapValidationDestructuringVariableStatement.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatement.ts"],"names":[],"mappings":"AAOA,IAAI,KAAK,GAAG,OAAO,CAAC;AACpB,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvD,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC3D,IAAY,KAAK,GAAK,MAAM,KAAA,CAAC;AAC7B,IAAY,KAAK,GAAoB,MAAM,OAAjB,MAAM,GAAK,MAAM,MAAA,CAAC;AAC5C,IAAI,KAAiC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,EAAlE,KAAK,YAAS,MAAM,WAA8C,CAAC;AAC/E,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AACD,IAAI,CAAC,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,373 @@
===================================================================
JsFile: sourceMapValidationDestructuringVariableStatement.js
mapUrl: sourceMapValidationDestructuringVariableStatement.js.map
sourceRoot:
sources: sourceMapValidationDestructuringVariableStatement.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatement.js
sourceFile:sourceMapValidationDestructuringVariableStatement.ts
-------------------------------------------------------------------
>>>var hello = "hello";
1 >
2 >^^^^
3 > ^^^^^
4 > ^^^
5 > ^^^^^^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >interface Robot {
> name: string;
> skill: string;
>}
>declare var console: {
> log(msg: string): void;
>}
>
2 >var
3 > hello
4 > =
5 > "hello"
6 > ;
1 >Emitted(1, 1) Source(8, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(8, 5) + SourceIndex(0)
3 >Emitted(1, 10) Source(8, 10) + SourceIndex(0)
4 >Emitted(1, 13) Source(8, 13) + SourceIndex(0)
5 >Emitted(1, 20) Source(8, 20) + SourceIndex(0)
6 >Emitted(1, 21) Source(8, 21) + SourceIndex(0)
---
>>>var robotA = { name: "mower", skill: "mowing" };
1->
2 >^^^^
3 > ^^^^^^
4 > ^^^
5 > ^^
6 > ^^^^
7 > ^^
8 > ^^^^^^^
9 > ^^
10> ^^^^^
11> ^^
12> ^^^^^^^^
13> ^^
14> ^
15> ^^^^^->
1->
>
2 >var
3 > robotA
4 > : Robot =
5 > {
6 > name
7 > :
8 > "mower"
9 > ,
10> skill
11> :
12> "mowing"
13> }
14> ;
1->Emitted(2, 1) Source(9, 1) + SourceIndex(0)
2 >Emitted(2, 5) Source(9, 5) + SourceIndex(0)
3 >Emitted(2, 11) Source(9, 11) + SourceIndex(0)
4 >Emitted(2, 14) Source(9, 21) + SourceIndex(0)
5 >Emitted(2, 16) Source(9, 23) + SourceIndex(0)
6 >Emitted(2, 20) Source(9, 27) + SourceIndex(0)
7 >Emitted(2, 22) Source(9, 29) + SourceIndex(0)
8 >Emitted(2, 29) Source(9, 36) + SourceIndex(0)
9 >Emitted(2, 31) Source(9, 38) + SourceIndex(0)
10>Emitted(2, 36) Source(9, 43) + SourceIndex(0)
11>Emitted(2, 38) Source(9, 45) + SourceIndex(0)
12>Emitted(2, 46) Source(9, 53) + SourceIndex(0)
13>Emitted(2, 48) Source(9, 55) + SourceIndex(0)
14>Emitted(2, 49) Source(9, 56) + SourceIndex(0)
---
>>>var robotB = { name: "trimmer", skill: "trimming" };
1->
2 >^^^^
3 > ^^^^^^
4 > ^^^
5 > ^^
6 > ^^^^
7 > ^^
8 > ^^^^^^^^^
9 > ^^
10> ^^^^^
11> ^^
12> ^^^^^^^^^^
13> ^^
14> ^
1->
>
2 >var
3 > robotB
4 > : Robot =
5 > {
6 > name
7 > :
8 > "trimmer"
9 > ,
10> skill
11> :
12> "trimming"
13> }
14> ;
1->Emitted(3, 1) Source(10, 1) + SourceIndex(0)
2 >Emitted(3, 5) Source(10, 5) + SourceIndex(0)
3 >Emitted(3, 11) Source(10, 11) + SourceIndex(0)
4 >Emitted(3, 14) Source(10, 21) + SourceIndex(0)
5 >Emitted(3, 16) Source(10, 23) + SourceIndex(0)
6 >Emitted(3, 20) Source(10, 27) + SourceIndex(0)
7 >Emitted(3, 22) Source(10, 29) + SourceIndex(0)
8 >Emitted(3, 31) Source(10, 38) + SourceIndex(0)
9 >Emitted(3, 33) Source(10, 40) + SourceIndex(0)
10>Emitted(3, 38) Source(10, 45) + SourceIndex(0)
11>Emitted(3, 40) Source(10, 47) + SourceIndex(0)
12>Emitted(3, 50) Source(10, 57) + SourceIndex(0)
13>Emitted(3, 52) Source(10, 59) + SourceIndex(0)
14>Emitted(3, 53) Source(10, 60) + SourceIndex(0)
---
>>>var nameA = robotA.name;
1 >
2 >^^^^
3 > ^^^^^
4 > ^^^
5 > ^^^^^^
6 > ^^^^^
7 > ^
8 > ^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >var { name:
3 > nameA
4 > } =
5 > robotA
6 >
7 > ;
1 >Emitted(4, 1) Source(11, 1) + SourceIndex(0)
2 >Emitted(4, 5) Source(11, 13) + SourceIndex(0)
3 >Emitted(4, 10) Source(11, 18) + SourceIndex(0)
4 >Emitted(4, 13) Source(11, 23) + SourceIndex(0)
5 >Emitted(4, 19) Source(11, 29) + SourceIndex(0)
6 >Emitted(4, 24) Source(11, 29) + SourceIndex(0)
7 >Emitted(4, 25) Source(11, 30) + SourceIndex(0)
---
>>>var nameB = robotB.name, skillB = robotB.skill;
1->
2 >^^^^
3 > ^^^^^
4 > ^^^
5 > ^^^^^^
6 > ^^^^^^^
7 > ^^^^^^
8 > ^^^
9 > ^^^^^^
10> ^^^^^^
11> ^
12> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1->
>
2 >var { name:
3 > nameB
4 > , skill: skillB } =
5 > robotB
6 >
7 > skillB
8 > } =
9 > robotB
10>
11> ;
1->Emitted(5, 1) Source(12, 1) + SourceIndex(0)
2 >Emitted(5, 5) Source(12, 13) + SourceIndex(0)
3 >Emitted(5, 10) Source(12, 18) + SourceIndex(0)
4 >Emitted(5, 13) Source(12, 38) + SourceIndex(0)
5 >Emitted(5, 19) Source(12, 44) + SourceIndex(0)
6 >Emitted(5, 26) Source(12, 27) + SourceIndex(0)
7 >Emitted(5, 32) Source(12, 33) + SourceIndex(0)
8 >Emitted(5, 35) Source(12, 38) + SourceIndex(0)
9 >Emitted(5, 41) Source(12, 44) + SourceIndex(0)
10>Emitted(5, 47) Source(12, 44) + SourceIndex(0)
11>Emitted(5, 48) Source(12, 45) + SourceIndex(0)
---
>>>var _a = { name: "Edger", skill: "cutting edges" }, nameC = _a.name, skillC = _a.skill;
1->
2 >^^^^
3 > ^^^^^
4 > ^^
5 > ^^^^
6 > ^^
7 > ^^^^^^^
8 > ^^
9 > ^^^^^
10> ^^
11> ^^^^^^^^^^^^^^^
12> ^^
13> ^^
14> ^^^^^
15> ^^^^^^^^^^^^
16> ^^^^^^
17> ^^^^^^^^^^^
18> ^
1->
>
2 >var
3 > { name: nameC, skill: skillC } =
4 > {
5 > name
6 > :
7 > "Edger"
8 > ,
9 > skill
10> :
11> "cutting edges"
12> }
13>
14> nameC
15> , skill:
16> skillC
17> } = { name: "Edger", skill: "cutting edges" }
18> ;
1->Emitted(6, 1) Source(13, 1) + SourceIndex(0)
2 >Emitted(6, 5) Source(13, 5) + SourceIndex(0)
3 >Emitted(6, 10) Source(13, 38) + SourceIndex(0)
4 >Emitted(6, 12) Source(13, 40) + SourceIndex(0)
5 >Emitted(6, 16) Source(13, 44) + SourceIndex(0)
6 >Emitted(6, 18) Source(13, 46) + SourceIndex(0)
7 >Emitted(6, 25) Source(13, 53) + SourceIndex(0)
8 >Emitted(6, 27) Source(13, 55) + SourceIndex(0)
9 >Emitted(6, 32) Source(13, 60) + SourceIndex(0)
10>Emitted(6, 34) Source(13, 62) + SourceIndex(0)
11>Emitted(6, 49) Source(13, 77) + SourceIndex(0)
12>Emitted(6, 51) Source(13, 79) + SourceIndex(0)
13>Emitted(6, 53) Source(13, 13) + SourceIndex(0)
14>Emitted(6, 58) Source(13, 18) + SourceIndex(0)
15>Emitted(6, 70) Source(13, 27) + SourceIndex(0)
16>Emitted(6, 76) Source(13, 33) + SourceIndex(0)
17>Emitted(6, 87) Source(13, 79) + SourceIndex(0)
18>Emitted(6, 88) Source(13, 80) + SourceIndex(0)
---
>>>if (nameA == nameB) {
1 >
2 >^^
3 > ^
4 > ^
5 > ^^^^^
6 > ^^^^
7 > ^^^^^
8 > ^
9 > ^
10> ^
11> ^^^^->
1 >
>
2 >if
3 >
4 > (
5 > nameA
6 > ==
7 > nameB
8 > )
9 >
10> {
1 >Emitted(7, 1) Source(14, 1) + SourceIndex(0)
2 >Emitted(7, 3) Source(14, 3) + SourceIndex(0)
3 >Emitted(7, 4) Source(14, 4) + SourceIndex(0)
4 >Emitted(7, 5) Source(14, 5) + SourceIndex(0)
5 >Emitted(7, 10) Source(14, 10) + SourceIndex(0)
6 >Emitted(7, 14) Source(14, 14) + SourceIndex(0)
7 >Emitted(7, 19) Source(14, 19) + SourceIndex(0)
8 >Emitted(7, 20) Source(14, 20) + SourceIndex(0)
9 >Emitted(7, 21) Source(14, 21) + SourceIndex(0)
10>Emitted(7, 22) Source(14, 22) + SourceIndex(0)
---
>>> console.log(skillB);
1->^^^^
2 > ^^^^^^^
3 > ^
4 > ^^^
5 > ^
6 > ^^^^^^
7 > ^
8 > ^
1->
>
2 > console
3 > .
4 > log
5 > (
6 > skillB
7 > )
8 > ;
1->Emitted(8, 5) Source(15, 5) + SourceIndex(0)
2 >Emitted(8, 12) Source(15, 12) + SourceIndex(0)
3 >Emitted(8, 13) Source(15, 13) + SourceIndex(0)
4 >Emitted(8, 16) Source(15, 16) + SourceIndex(0)
5 >Emitted(8, 17) Source(15, 17) + SourceIndex(0)
6 >Emitted(8, 23) Source(15, 23) + SourceIndex(0)
7 >Emitted(8, 24) Source(15, 24) + SourceIndex(0)
8 >Emitted(8, 25) Source(15, 25) + SourceIndex(0)
---
>>>}
1 >
2 >^
3 > ^^^^^^->
1 >
>
2 >}
1 >Emitted(9, 1) Source(16, 1) + SourceIndex(0)
2 >Emitted(9, 2) Source(16, 2) + SourceIndex(0)
---
>>>else {
1->
2 >^^^^
3 > ^
4 > ^
5 > ^^^^^^^^^^^^^^^^^^->
1->
>
2 >else
3 >
4 > {
1->Emitted(10, 1) Source(17, 1) + SourceIndex(0)
2 >Emitted(10, 5) Source(17, 5) + SourceIndex(0)
3 >Emitted(10, 6) Source(17, 6) + SourceIndex(0)
4 >Emitted(10, 7) Source(17, 7) + SourceIndex(0)
---
>>> console.log(nameC);
1->^^^^
2 > ^^^^^^^
3 > ^
4 > ^^^
5 > ^
6 > ^^^^^
7 > ^
8 > ^
1->
>
2 > console
3 > .
4 > log
5 > (
6 > nameC
7 > )
8 > ;
1->Emitted(11, 5) Source(18, 5) + SourceIndex(0)
2 >Emitted(11, 12) Source(18, 12) + SourceIndex(0)
3 >Emitted(11, 13) Source(18, 13) + SourceIndex(0)
4 >Emitted(11, 16) Source(18, 16) + SourceIndex(0)
5 >Emitted(11, 17) Source(18, 17) + SourceIndex(0)
6 >Emitted(11, 22) Source(18, 22) + SourceIndex(0)
7 >Emitted(11, 23) Source(18, 23) + SourceIndex(0)
8 >Emitted(11, 24) Source(18, 24) + SourceIndex(0)
---
>>>}
1 >
2 >^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >}
1 >Emitted(12, 1) Source(19, 1) + SourceIndex(0)
2 >Emitted(12, 2) Source(19, 2) + SourceIndex(0)
---
>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatement.js.map
@@ -0,0 +1,69 @@
=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatement.ts ===
interface Robot {
>Robot : Symbol(Robot, Decl(sourceMapValidationDestructuringVariableStatement.ts, 0, 0))
name: string;
>name : Symbol(name, Decl(sourceMapValidationDestructuringVariableStatement.ts, 0, 17))
skill: string;
>skill : Symbol(skill, Decl(sourceMapValidationDestructuringVariableStatement.ts, 1, 17))
}
declare var console: {
>console : Symbol(console, Decl(sourceMapValidationDestructuringVariableStatement.ts, 4, 11))
log(msg: string): void;
>log : Symbol(log, Decl(sourceMapValidationDestructuringVariableStatement.ts, 4, 22))
>msg : Symbol(msg, Decl(sourceMapValidationDestructuringVariableStatement.ts, 5, 8))
}
var hello = "hello";
>hello : Symbol(hello, Decl(sourceMapValidationDestructuringVariableStatement.ts, 7, 3))
var robotA: Robot = { name: "mower", skill: "mowing" };
>robotA : Symbol(robotA, Decl(sourceMapValidationDestructuringVariableStatement.ts, 8, 3))
>Robot : Symbol(Robot, Decl(sourceMapValidationDestructuringVariableStatement.ts, 0, 0))
>name : Symbol(name, Decl(sourceMapValidationDestructuringVariableStatement.ts, 8, 21))
>skill : Symbol(skill, Decl(sourceMapValidationDestructuringVariableStatement.ts, 8, 36))
var robotB: Robot = { name: "trimmer", skill: "trimming" };
>robotB : Symbol(robotB, Decl(sourceMapValidationDestructuringVariableStatement.ts, 9, 3))
>Robot : Symbol(Robot, Decl(sourceMapValidationDestructuringVariableStatement.ts, 0, 0))
>name : Symbol(name, Decl(sourceMapValidationDestructuringVariableStatement.ts, 9, 21))
>skill : Symbol(skill, Decl(sourceMapValidationDestructuringVariableStatement.ts, 9, 38))
var { name: nameA } = robotA;
>name : Symbol(Robot.name, Decl(sourceMapValidationDestructuringVariableStatement.ts, 0, 17))
>nameA : Symbol(nameA, Decl(sourceMapValidationDestructuringVariableStatement.ts, 10, 5))
>robotA : Symbol(robotA, Decl(sourceMapValidationDestructuringVariableStatement.ts, 8, 3))
var { name: nameB, skill: skillB } = robotB;
>name : Symbol(Robot.name, Decl(sourceMapValidationDestructuringVariableStatement.ts, 0, 17))
>nameB : Symbol(nameB, Decl(sourceMapValidationDestructuringVariableStatement.ts, 11, 5))
>skill : Symbol(Robot.skill, Decl(sourceMapValidationDestructuringVariableStatement.ts, 1, 17))
>skillB : Symbol(skillB, Decl(sourceMapValidationDestructuringVariableStatement.ts, 11, 18))
>robotB : Symbol(robotB, Decl(sourceMapValidationDestructuringVariableStatement.ts, 9, 3))
var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" };
>name : Symbol(name, Decl(sourceMapValidationDestructuringVariableStatement.ts, 12, 38))
>nameC : Symbol(nameC, Decl(sourceMapValidationDestructuringVariableStatement.ts, 12, 5))
>skill : Symbol(skill, Decl(sourceMapValidationDestructuringVariableStatement.ts, 12, 53))
>skillC : Symbol(skillC, Decl(sourceMapValidationDestructuringVariableStatement.ts, 12, 18))
>name : Symbol(name, Decl(sourceMapValidationDestructuringVariableStatement.ts, 12, 38))
>skill : Symbol(skill, Decl(sourceMapValidationDestructuringVariableStatement.ts, 12, 53))
if (nameA == nameB) {
>nameA : Symbol(nameA, Decl(sourceMapValidationDestructuringVariableStatement.ts, 10, 5))
>nameB : Symbol(nameB, Decl(sourceMapValidationDestructuringVariableStatement.ts, 11, 5))
console.log(skillB);
>console.log : Symbol(log, Decl(sourceMapValidationDestructuringVariableStatement.ts, 4, 22))
>console : Symbol(console, Decl(sourceMapValidationDestructuringVariableStatement.ts, 4, 11))
>log : Symbol(log, Decl(sourceMapValidationDestructuringVariableStatement.ts, 4, 22))
>skillB : Symbol(skillB, Decl(sourceMapValidationDestructuringVariableStatement.ts, 11, 18))
}
else {
console.log(nameC);
>console.log : Symbol(log, Decl(sourceMapValidationDestructuringVariableStatement.ts, 4, 22))
>console : Symbol(console, Decl(sourceMapValidationDestructuringVariableStatement.ts, 4, 11))
>log : Symbol(log, Decl(sourceMapValidationDestructuringVariableStatement.ts, 4, 22))
>nameC : Symbol(nameC, Decl(sourceMapValidationDestructuringVariableStatement.ts, 12, 5))
}
@@ -0,0 +1,82 @@
=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatement.ts ===
interface Robot {
>Robot : Robot
name: string;
>name : string
skill: string;
>skill : string
}
declare var console: {
>console : { log(msg: string): void; }
log(msg: string): void;
>log : (msg: string) => void
>msg : string
}
var hello = "hello";
>hello : string
>"hello" : string
var robotA: Robot = { name: "mower", skill: "mowing" };
>robotA : Robot
>Robot : Robot
>{ name: "mower", skill: "mowing" } : { name: string; skill: string; }
>name : string
>"mower" : string
>skill : string
>"mowing" : string
var robotB: Robot = { name: "trimmer", skill: "trimming" };
>robotB : Robot
>Robot : Robot
>{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; }
>name : string
>"trimmer" : string
>skill : string
>"trimming" : string
var { name: nameA } = robotA;
>name : any
>nameA : string
>robotA : Robot
var { name: nameB, skill: skillB } = robotB;
>name : any
>nameB : string
>skill : any
>skillB : string
>robotB : Robot
var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" };
>name : any
>nameC : string
>skill : any
>skillC : string
>{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; }
>name : string
>"Edger" : string
>skill : string
>"cutting edges" : string
if (nameA == nameB) {
>nameA == nameB : boolean
>nameA : string
>nameB : string
console.log(skillB);
>console.log(skillB) : void
>console.log : (msg: string) => void
>console : { log(msg: string): void; }
>log : (msg: string) => void
>skillB : string
}
else {
console.log(nameC);
>console.log(nameC) : void
>console.log : (msg: string) => void
>console : { log(msg: string): void; }
>log : (msg: string) => void
>nameC : string
}
@@ -0,0 +1,20 @@
// @sourcemap: true
interface Robot {
name: string;
skill: string;
}
declare var console: {
log(msg: string): void;
}
var hello = "hello";
var robotA: Robot = { name: "mower", skill: "mowing" };
var robotB: Robot = { name: "trimmer", skill: "trimming" };
var { name: nameA } = robotA;
var { name: nameB, skill: skillB } = robotB;
var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" };
if (nameA == nameB) {
console.log(skillB);
}
else {
console.log(nameC);
}