Skip to content

Commit 34624a0

Browse files
committed
More Tests
1 parent e41533a commit 34624a0

File tree

72 files changed

+331
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+331
-278
lines changed

tests/cases/fourslash/localGetReferences.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// @Filename: localGetReferences_1.ts
44
////// Comment Refence Test: g/*1*/lobalVar
55
////// References to a variable declared in global.
6-
////var [|{| "isWriteAccess": true, "isDefinition": true |}globalVar|]: number = 2;
6+
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}globalVar|]: number = 2;|]
77
////
88
////class fooCls {
99
//// // References to static variable declared in a class.
10-
//// static [|{| "isWriteAccess": true, "isDefinition": true |}clsSVar|] = 1;
10+
//// [|static [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}clsSVar|] = 1;|]
1111
//// // References to a variable declared in a class.
12-
//// [|{| "isWriteAccess": true, "isDefinition": true |}clsVar|] = 1;
12+
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}clsVar|] = 1;|]
1313
////
14-
//// constructor (public [|{| "isWriteAccess": true, "isDefinition": true |}clsParam|]: number) {
14+
//// constructor ([|public [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}clsParam|]: number|]) {
1515
//// //Increments
1616
//// [|{| "isWriteAccess": true |}globalVar|]++;
1717
//// this.[|{| "isWriteAccess": true |}clsVar|]++;
@@ -23,9 +23,9 @@
2323
////}
2424
////
2525
////// References to a function parameter.
26-
////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|]([|{| "isWriteAccess": true, "isDefinition": true |}x|]: number) {
26+
////[|function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 12 |}foo|]([|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 14 |}x|]: number|]) {
2727
//// // References to a variable declared in a function.
28-
//// var [|{| "isWriteAccess": true, "isDefinition": true |}fnVar|] = 1;
28+
//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 16 |}fnVar|] = 1;|]
2929
////
3030
//// //Increments
3131
//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++;
@@ -35,7 +35,7 @@
3535
////
3636
//// //Return
3737
//// return [|{| "isWriteAccess": true |}x|]++;
38-
////}
38+
////}|]
3939
////
4040
////module modTest {
4141
//// //Declare
@@ -85,7 +85,7 @@
8585
/////*3*/err = err++;
8686
/////*4*/
8787
//////Shadowed fn Parameter
88-
////function shdw([|{| "isWriteAccess": true, "isDefinition": true, "shadow": true |}globalVar|]: number) {
88+
////function shdw([|[|{| "isWriteAccess": true, "isDefinition": true, "shadow": true, "declarationRangeIndex": 39 |}globalVar|]: number|]) {
8989
//// //Increments
9090
//// [|{| "isWriteAccess": true, "shadow": true |}globalVar|]++;
9191
//// return [|{| "shadow": true |}globalVar|];
@@ -117,7 +117,7 @@
117117
////array.forEach(
118118
////
119119
////
120-
////function([|{| "isWriteAccess": true, "isDefinition": true |}str|]) {
120+
////function([|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 43 |}str|]) {
121121
////
122122
////
123123
////
@@ -198,6 +198,30 @@ goTo.marker("4");
198198
verify.noReferences();
199199

200200
test.rangesByText().forEach((ranges, text) => {
201+
switch (text) {
202+
case "var globalVar: number = 2;":
203+
case "static clsSVar = 1;":
204+
case "clsVar = 1;":
205+
case "public clsParam: number":
206+
case `function foo(x: number) {
207+
// References to a variable declared in a function.
208+
var fnVar = 1;
209+
210+
//Increments
211+
fooCls.clsSVar++;
212+
globalVar++;
213+
modTest.modVar++;
214+
fnVar++;
215+
216+
//Return
217+
return x++;
218+
}`:
219+
case "x: number":
220+
case "var fnVar = 1;":
221+
case "globalVar: number":
222+
return;
223+
}
224+
201225
if (text === "globalVar") {
202226
verify.singleReferenceGroup("(parameter) globalVar: number", ranges.filter(isShadow));
203227
verify.singleReferenceGroup("var globalVar: number", ranges.filter(r => !isShadow(r)));

tests/cases/fourslash/referenceToClass.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// Class references should work across file and not find local variables.
44

55
// @Filename: referenceToClass_1.ts
6-
////class [|{| "isWriteAccess": true, "isDefinition": true |}foo|] {
6+
////[|class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}foo|] {
77
//// public n: [|foo|];
88
//// public foo: number;
9-
////}
9+
////}|]
1010
////
1111
////class bar {
1212
//// public n: [|foo|];
@@ -20,4 +20,5 @@
2020
// @Filename: referenceToClass_2.ts
2121
////var k: [|foo|];
2222

23-
verify.singleReferenceGroup("class foo");
23+
const [rDef, ...ranges] = test.ranges();
24+
verify.singleReferenceGroup("class foo", ranges);

tests/cases/fourslash/referencesBloomFilters.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Ensure BloomFilter building logic is correct, by having one reference per file
44

55
// @Filename: declaration.ts
6-
////var container = { [|{| "isWriteAccess": true, "isDefinition": true |}searchProp|] : 1 };
6+
////var container = { [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}searchProp|] : 1|] };
77

88
// @Filename: expression.ts
99
////function blah() { return (1 + 2 + container.[|searchProp|]()) === 2; };
@@ -12,6 +12,6 @@
1212
////function blah2() { container["[|searchProp|]"] };
1313

1414
// @Filename: redeclaration.ts
15-
////container = { "[|{| "isWriteAccess": true, "isDefinition": true |}searchProp|]" : 18 };
15+
////container = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}searchProp|]" : 18|] };
1616

17-
verify.singleReferenceGroup("(property) searchProp: number");
17+
verify.singleReferenceGroup("(property) searchProp: number", test.rangesByText().get("searchProp"));

tests/cases/fourslash/referencesBloomFilters2.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Ensure BloomFilter building logic is correct, by having one reference per file
44

55
// @Filename: declaration.ts
6-
////var container = { [|{| "isWriteAccess": true, "isDefinition": true |}42|]: 1 };
6+
////var container = { [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}42|]: 1|] };
77

88
// @Filename: expression.ts
99
////function blah() { return (container[[|42|]]) === 2; };
@@ -12,6 +12,6 @@
1212
////function blah2() { container["[|42|]"] };
1313

1414
// @Filename: redeclaration.ts
15-
////container = { "[|{| "isWriteAccess": true, "isDefinition": true |}42|]" : 18 };
15+
////container = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}42|]" : 18|] };
1616

17-
verify.singleReferenceGroup("(property) 42: number");
17+
verify.singleReferenceGroup("(property) 42: number", test.rangesByText().get("42"));

tests/cases/fourslash/referencesBloomFilters3.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
// @Filename: declaration.ts
7-
////enum Test { "[|{| "isWriteAccess": true, "isDefinition": true |}42|]" = 1 };
7+
////enum Test { [|"[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}42|]" = 1|] };
88

99
// @Filename: expression.ts
1010
////(Test[[|42|]]);
1111

12-
verify.singleReferenceGroup('(enum member) Test["42"] = 1');
12+
verify.singleReferenceGroup('(enum member) Test["42"] = 1', test.rangesByText().get("42"));

tests/cases/fourslash/referencesForAmbients.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/// <reference path='fourslash.ts'/>
22

3-
////declare module "[|{| "isWriteAccess": true, "isDefinition": true |}foo|]" {
4-
//// var [|{| "isWriteAccess": true, "isDefinition": true |}f|]: number;
5-
////}
3+
////[|declare module "[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}foo|]" {
4+
//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}f|]: number;|]
5+
////}|]
66
////
7-
////declare module "[|{| "isWriteAccess": true, "isDefinition": true |}bar|]" {
8-
//// export import [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = require("[|foo|]");
7+
////[|declare module "[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}bar|]" {
8+
//// [|export import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}foo|] = require("[|foo|]");|]
99
//// var f2: typeof [|foo|].[|f|];
10-
////}
10+
////}|]
1111
////
1212
////declare module "baz" {
1313
//// import bar = require("[|bar|]");
1414
//// var f2: typeof bar.[|foo|];
1515
////}
1616

17-
const [moduleFoo0, f0, moduleBar0, foo0, moduleFoo1, foo1, f1, moduleBar1, foo2] = test.ranges();
17+
const [moduleFoo0Def, moduleFoo0, f0Def, f0, moduleBar0Def, moduleBar0, foo0Def, foo0, moduleFoo1, foo1, f1, moduleBar1, foo2] = test.ranges();
1818
verify.singleReferenceGroup('module "foo"', [moduleFoo0, moduleFoo1]);
1919
verify.singleReferenceGroup('module "bar"', [moduleBar0, moduleBar1]);
2020
verify.singleReferenceGroup('(alias) module "foo"\nimport foo = require("foo")', [foo0, foo1, foo2]);

tests/cases/fourslash/referencesForAmbients2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// @Filename: /defA.ts
44
////declare module "a" {
5-
//// export type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = number;
5+
//// [|export type [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}T|] = number;|]
66
////}
77

88
// @Filename: /defB.ts
@@ -18,4 +18,4 @@
1818
////}
1919

2020
verify.noErrors();
21-
verify.singleReferenceGroup("type T = number");
21+
verify.singleReferenceGroup("type T = number", test.rangesByText().get("T"));

tests/cases/fourslash/referencesForClassLocal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
////var n = 14;
66
////
77
////class foo {
8-
//// private [|{| "isWriteAccess": true, "isDefinition": true |}n|] = 0;
8+
//// [|private [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}n|] = 0;|]
99
////
1010
//// public bar() {
1111
//// this.[|{| "isWriteAccess": true |}n|] = 9;
@@ -20,4 +20,4 @@
2020
//// }
2121
////}
2222

23-
verify.singleReferenceGroup("(property) foo.n: number");
23+
verify.singleReferenceGroup("(property) foo.n: number", test.rangesByText().get("n"));

tests/cases/fourslash/referencesForClassMembers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// <reference path='fourslash.ts'/>
22

33
////class Base {
4-
//// [|{| "isDefinition": true |}a|]: number;
5-
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { }
4+
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}a|]: number;|]
5+
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}method|](): void { }|]
66
////}
77
////class MyClass extends Base {
8-
//// [|{| "isDefinition": true |}a|];
9-
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { }
8+
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 4 |}a|];|]
9+
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}method|]() { }|]
1010
////}
1111
////
1212
////var c: MyClass;

tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// <reference path='fourslash.ts'/>
22

33
////abstract class Base {
4-
//// abstract [|{| "isDefinition": true |}a|]: number;
5-
//// abstract [|{| "isDefinition": true |}method|](): void;
4+
//// [|abstract [|{| "isDefinition": true, "declarationRangeIndex": 0 |}a|]: number;|]
5+
//// [|abstract [|{| "isDefinition": true, "declarationRangeIndex": 2 |}method|](): void;|]
66
////}
77
////class MyClass extends Base {
8-
//// [|{| "isDefinition": true |}a|];
9-
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { }
8+
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 4 |}a|];|]
9+
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}method|]() { }|]
1010
////}
1111
////
1212
////var c: MyClass;

0 commit comments

Comments
 (0)