Added fourslash tests.

This commit is contained in:
Daniel Rosenwasser 2014-09-17 17:40:32 -07:00
parent 55e772cfe0
commit b285ef165b
6 changed files with 95 additions and 2 deletions

View File

@ -0,0 +1,23 @@
/// <reference path="fourslash.ts"/>
////{| "itemName": "<global>", "kind": "module" |}
////
////{| "itemName": "foo", "kind": "function" |}function foo() {
//// var x = 10;
//// {| "itemName": "bar", "kind": "function", "parentName": "foo" |}function bar() {
//// var y = 10;
//// {| "itemName": "biz", "kind": "function", "parentName": "bar" |}function biz() {
//// var z = 10;
//// }
//// }
////}
////
////{| "itemName": "baz", "kind": "function" |}function baz() {
//// var v = 10;
////}
test.markers().forEach((marker) => {
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
});
verify.getScriptLexicalStructureListCount(5); // 4 functions + global

View File

@ -0,0 +1,12 @@
/// <reference path="fourslash.ts"/>
////{| "itemName": "f", "kind": "function" |}
////function f() {
//// function;
////}
test.markers().forEach((marker) => {
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
});
verify.getScriptLexicalStructureListCount(1); // 1 function - no global since the inner function thinks it has a declaration.

View File

@ -0,0 +1,13 @@
/// <reference path="fourslash.ts"/>
////function;
////{| "itemName": "f", "kind": "function" |}
////function f() {
//// function;
////}
test.markers().forEach((marker) => {
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
});
verify.getScriptLexicalStructureListCount(1); // 1 function with no global - the broken declaration adds nothing for us at the global scope.

View File

@ -49,3 +49,4 @@ test.markers().forEach((marker) => {
}
});
verify.getScriptLexicalStructureListCount(23);

View File

@ -4,8 +4,8 @@
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
////}
verify.getScriptLexicalStructureListCount(2); // external module node + class + property
test.markers().forEach((marker) => {
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
});
verify.getScriptLexicalStructureListCount(2); // external module node + class + property

View File

@ -0,0 +1,44 @@

////{| "itemName": "\"X.Y.Z\"", "kind": "module" |}
////declare module "X.Y.Z" {
////}
////
////{| "itemName": "A.B.C", "kind": "module" |}
////module A.B.C {
//// {| "itemName": "x", "kind": "var", "parent": "A.B.C" |}
//// export var x;
////}
////
////{| "itemName": "A.B", "kind": "module" |}
////module A.B {
//// {| "itemName": "y", "kind": "var", "parent": "A.B" |}
//// export var y;
////}
////
////{| "itemName": "A", "kind": "module" |}
////module A {
//// {| "itemName": "z", "kind": "var", "parent": "A" |}
//// export var z;
////}
////
////{| "itemName": "A", "kind": "module" |}
////module A {
//// {| "itemName": "B", "kind": "module", "parent": "E" |}
//// module B {
//// {| "itemName": "C", "kind": "module", "parent": "F" |}
//// module C {
//// {| "itemName": "x", "kind": "var", "parent": "C" |}
//// declare var x;
//// }
//// }
////}
test.markers().forEach((marker) => {
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
});
/// We have 7 module keywords, and 4 var keywords.
/// The declarations of A.B.C.x do not get merged, so the 4 vars are independent.
/// The two 'A' modules, however, do get merged, so in reality we have 6 modules.
verify.getScriptLexicalStructureListCount(10);