Skip to content

Commit c97fc64

Browse files
author
Andy
authored
Always use verify.completions when testing completions (#28137)
1 parent a695288 commit c97fc64

File tree

589 files changed

+4260
-5751
lines changed

Some content is hidden

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

589 files changed

+4260
-5751
lines changed

src/harness/fourslash.ts

Lines changed: 499 additions & 383 deletions
Large diffs are not rendered by default.

tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
goTo.marker();
1313
var text = "this.children = ch";
1414
edit.insert(text);
15-
verify.completionListContains("children", "(parameter) children: string[]");
15+
verify.completions({ includes: { name: "children", text: "(parameter) children: string[]" }, isNewIdentifierLocation: true });

tests/cases/fourslash/asOperatorCompletion.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
//// var x;
55
//// var y = x as /**/
66

7-
goTo.marker();
8-
verify.completionListContains('T');
7+
verify.completions({ marker: "", includes: "T" });
8+

tests/cases/fourslash/augmentedTypesClass2.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
////var r = new c5b();
77
////r./*2*/
88

9-
goTo.marker('1');
10-
verify.not.completionListContains('y', 'var y: number');
9+
verify.completions({ marker: "1", excludes: ["y"] });
1110
edit.backspace(4);
12-
goTo.marker('2');
13-
verify.completionListContains('foo', '(method) c5b.foo(): void');
11+
verify.completions({ marker: "2", exact: { name: "foo", text: "(method) c5b.foo(): void" } });

tests/cases/fourslash/augmentedTypesClass3.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ verify.quickInfos({
88
1: "class c5b\nnamespace c5b",
99
2: "class c5b\nnamespace c5b"
1010
});
11-
12-
goTo.marker('3');
13-
verify.completionListContains("c5b", "class c5b\nnamespace c5b");
11+
verify.completions({ marker: "3", includes: { name: "c5b", text: "class c5b\nnamespace c5b" }})

tests/cases/fourslash/augmentedTypesModule1.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
////var x: m1c./*1*/;
88
////var /*2*/r = m1c;
99

10-
goTo.marker('1');
11-
verify.completionListContains('I');
12-
verify.not.completionListContains('foo');
13-
10+
verify.completions({ marker: "1", exact: "I" });
1411
verify.quickInfoAt("2", "var r: number");

tests/cases/fourslash/augmentedTypesModule2.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77

88
verify.quickInfoAt("11", "function m2f(x: number): void\nnamespace m2f");
99

10-
goTo.marker('1');
11-
verify.completionListContains('I');
10+
verify.completions({ marker: "1", exact: "I" });
1211

1312
edit.insert('I.');
14-
verify.not.completionListContains('foo');
13+
verify.completions({ exact: undefined });
1514
edit.backspace(1);
1615

1716
verify.quickInfoAt("2", "var r: (x: number) => void");

tests/cases/fourslash/augmentedTypesModule3.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
////var x: m2g./*1*/;
66
////var /*2*/r = m2g/*3*/;
77

8-
goTo.marker('1');
9-
verify.completionListContains('C');
8+
verify.completions({ marker: "1", exact: "C" });
109

1110
edit.insert('C.');
12-
verify.not.completionListContains('foo');
11+
verify.completions({ exact: undefined });
1312
edit.backspace(1);
1413

1514
verify.quickInfoAt("2", "var r: typeof m2g");
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
/// <reference path='fourslash.ts'/>
22

3-
////module m3d { export var y = 2; }
3+
////module m3d { export var y = 2; }
44
////declare class m3d { foo(): void }
55
////var /*1*/r = new m3d();
66
////r./*2*/
77
////var /*4*/r2 = m3d./*3*/
88

99
verify.quickInfoAt("1", "var r: m3d");
1010

11-
goTo.marker('2');
12-
verify.completionListContains('foo');
11+
verify.completions({ marker: "2", exact: "foo" });
1312
edit.insert('foo();');
1413

15-
goTo.marker('3');
16-
verify.completionListContains('y');
14+
verify.completions({ marker: "3", includes: "y" });
1715
edit.insert('y;');
1816

1917
verify.quickInfoAt("4", "var r2: number");
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
/// <reference path='fourslash.ts'/>
22

3-
////declare class m3e { foo(): void }
3+
////declare class m3e { foo(): void }
44
////module m3e { export var y = 2; }
55
////var /*1*/r = new m3e();
66
////r./*2*/
77
////var /*4*/r2 = m3e./*3*/
88

99
verify.quickInfoAt("1", "var r: m3e");
1010

11-
goTo.marker('2');
12-
verify.completionListContains('foo');
11+
verify.completions({ marker: "2", exact: "foo" });
1312

1413
edit.insert('foo();');
1514

16-
goTo.marker('3');
17-
verify.completionListContains('y');
15+
verify.completions({ marker: "3", includes: "y" });
1816
edit.insert('y;');
1917

2018
verify.quickInfoAt("4", "var r2: number");

tests/cases/fourslash/basicClassMembers.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77

88
goTo.eof();
99
edit.insert('t.');
10-
verify.completionListContains('x');
11-
verify.completionListContains('y');
12-
verify.not.completionListContains('z');
10+
verify.completions({ includes: ["x", "y"], excludes: "z" });

tests/cases/fourslash/cloduleAsBaseClass.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,8 @@
2323
////d./*1*/
2424
////D./*2*/
2525

26-
goTo.marker('1');
27-
verify.completionListContains('foo');
28-
verify.completionListContains('foo2');
29-
verify.not.completionListContains('bar');
30-
verify.not.completionListContains('bar2');
31-
verify.not.completionListContains('baz');
32-
verify.not.completionListContains('x');
33-
26+
verify.completions({ marker: "1", exact: ["foo2", "foo"] });
3427
edit.insert('foo()');
35-
36-
goTo.marker('2');
37-
verify.not.completionListContains('foo');
38-
verify.not.completionListContains('foo2');
39-
verify.completionListContains('bar');
40-
verify.completionListContains('bar2');
41-
verify.completionListContains('baz');
42-
verify.completionListContains('x');
28+
verify.completions({ marker: "2", exact: ["prototype", "bar2", "bar", "baz", "x", ...completion.functionMembers] });
4329
edit.insert('bar()');
44-
45-
verify.noErrors();
30+
verify.noErrors();

tests/cases/fourslash/closedCommentsInConstructor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
//// constructor(/* /**/ */) { }
55
////}
66

7-
goTo.marker();
8-
verify.completionListIsEmpty();
7+
verify.completions({ marker: "", exact: undefined });

tests/cases/fourslash/codeCompletionEscaping.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
// @allowJs: true
55
////___foo; __foo;/**/
66

7-
goTo.marker();
8-
verify.completionListContains("__foo", undefined, undefined, "warning");
9-
verify.completionListContains("___foo", undefined, undefined, "warning");
7+
verify.completions({
8+
marker: "",
9+
includes: [
10+
{ name: "__foo", kind: "warning" },
11+
{ name: "___foo", kind: "warning" },
12+
],
13+
});

tests/cases/fourslash/commentsClass.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,26 @@ verify.quickInfos({
106106
25: ["class c6", "class with statics and constructor"]
107107
});
108108

109-
goTo.marker('26');
110-
verify.completionListContains("c2", "class c2", "This is class c2 without constructor");
111-
verify.completionListContains("i2", "var i2: c2", "");
112-
verify.completionListContains("i2_c", "var i2_c: typeof c2", "");
113-
verify.completionListContains("c3", "class c3", "");
114-
verify.completionListContains("i3", "var i3: c3", "");
115-
verify.completionListContains("i3_c", "var i3_c: typeof c3", "");
116-
verify.completionListContains("c4", "class c4", "Class comment");
117-
verify.completionListContains("i4", "var i4: c4", "");
118-
verify.completionListContains("i4_c", "var i4_c: typeof c4", "");
119-
verify.completionListContains("c5", "class c5", "Class with statics");
120-
verify.completionListContains("i5", "var i5: c5", "");
121-
verify.completionListContains("i5_c", "var i5_c: typeof c5");
122-
verify.completionListContains("c6", "class c6", "class with statics and constructor");
123-
verify.completionListContains("i6", "var i6: c6", "");
124-
verify.completionListContains("i6_c", "var i6_c: typeof c6", "");
109+
verify.completions({
110+
marker: "26",
111+
includes: [
112+
{ name: "c2", text: "class c2", documentation: "This is class c2 without constructor" },
113+
{ name: "i2", text: "var i2: c2" },
114+
{ name: "i2_c", text: "var i2_c: typeof c2" },
115+
{ name: "c3", text: "class c3" },
116+
{ name: "i3", text: "var i3: c3" },
117+
{ name: "i3_c", text: "var i3_c: typeof c3" },
118+
{ name: "c4", text: "class c4", documentation: "Class comment" },
119+
{ name: "i4", text: "var i4: c4" },
120+
{ name: "i4_c", text: "var i4_c: typeof c4" },
121+
{ name: "c5", text: "class c5", documentation: "Class with statics" },
122+
{ name: "i5", text: "var i5: c5" },
123+
{ name: "i5_c", text: "var i5_c: typeof c5" },
124+
{ name: "c6", text: "class c6", documentation: "class with statics and constructor" },
125+
{ name: "i6", text: "var i6: c6" },
126+
{ name: "i6_c", text: "var i6_c: typeof c6" },
127+
],
128+
});
125129

126130
verify.signatureHelp({
127131
marker: "27",

0 commit comments

Comments
 (0)