mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Added fourslash tests.
This commit is contained in:
parent
55e772cfe0
commit
b285ef165b
23
tests/cases/fourslash/scriptLexicalStructureFunctions.ts
Normal file
23
tests/cases/fourslash/scriptLexicalStructureFunctions.ts
Normal 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
|
||||
@ -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.
|
||||
@ -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.
|
||||
@ -49,3 +49,4 @@ test.markers().forEach((marker) => {
|
||||
}
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(23);
|
||||
|
||||
@ -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
|
||||
|
||||
44
tests/cases/fourslash/scriptLexicalStructureModules.ts
Normal file
44
tests/cases/fourslash/scriptLexicalStructureModules.ts
Normal 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);
|
||||
Loading…
x
Reference in New Issue
Block a user