Skip to content

Always use verify.completions when testing completions #28137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
882 changes: 499 additions & 383 deletions src/harness/fourslash.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
goTo.marker();
var text = "this.children = ch";
edit.insert(text);
verify.completionListContains("children", "(parameter) children: string[]");
verify.completions({ includes: { name: "children", text: "(parameter) children: string[]" }, isNewIdentifierLocation: true });
4 changes: 2 additions & 2 deletions tests/cases/fourslash/asOperatorCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
//// var x;
//// var y = x as /**/

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

6 changes: 2 additions & 4 deletions tests/cases/fourslash/augmentedTypesClass2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
////var r = new c5b();
////r./*2*/

goTo.marker('1');
verify.not.completionListContains('y', 'var y: number');
verify.completions({ marker: "1", excludes: ["y"] });
edit.backspace(4);
goTo.marker('2');
verify.completionListContains('foo', '(method) c5b.foo(): void');
verify.completions({ marker: "2", exact: { name: "foo", text: "(method) c5b.foo(): void" } });
4 changes: 1 addition & 3 deletions tests/cases/fourslash/augmentedTypesClass3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ verify.quickInfos({
1: "class c5b\nnamespace c5b",
2: "class c5b\nnamespace c5b"
});

goTo.marker('3');
verify.completionListContains("c5b", "class c5b\nnamespace c5b");
verify.completions({ marker: "3", includes: { name: "c5b", text: "class c5b\nnamespace c5b" }})
5 changes: 1 addition & 4 deletions tests/cases/fourslash/augmentedTypesModule1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@
////var x: m1c./*1*/;
////var /*2*/r = m1c;

goTo.marker('1');
verify.completionListContains('I');
verify.not.completionListContains('foo');

verify.completions({ marker: "1", exact: "I" });
verify.quickInfoAt("2", "var r: number");
5 changes: 2 additions & 3 deletions tests/cases/fourslash/augmentedTypesModule2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

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

goTo.marker('1');
verify.completionListContains('I');
verify.completions({ marker: "1", exact: "I" });

edit.insert('I.');
verify.not.completionListContains('foo');
verify.completions({ exact: undefined });
edit.backspace(1);

verify.quickInfoAt("2", "var r: (x: number) => void");
Expand Down
5 changes: 2 additions & 3 deletions tests/cases/fourslash/augmentedTypesModule3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
////var x: m2g./*1*/;
////var /*2*/r = m2g/*3*/;

goTo.marker('1');
verify.completionListContains('C');
verify.completions({ marker: "1", exact: "C" });

edit.insert('C.');
verify.not.completionListContains('foo');
verify.completions({ exact: undefined });
edit.backspace(1);

verify.quickInfoAt("2", "var r: typeof m2g");
Expand Down
8 changes: 3 additions & 5 deletions tests/cases/fourslash/augmentedTypesModule4.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/// <reference path='fourslash.ts'/>

////module m3d { export var y = 2; }
////module m3d { export var y = 2; }
////declare class m3d { foo(): void }
////var /*1*/r = new m3d();
////r./*2*/
////var /*4*/r2 = m3d./*3*/

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

goTo.marker('2');
verify.completionListContains('foo');
verify.completions({ marker: "2", exact: "foo" });
edit.insert('foo();');

goTo.marker('3');
verify.completionListContains('y');
verify.completions({ marker: "3", includes: "y" });
edit.insert('y;');

verify.quickInfoAt("4", "var r2: number");
8 changes: 3 additions & 5 deletions tests/cases/fourslash/augmentedTypesModule5.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
/// <reference path='fourslash.ts'/>

////declare class m3e { foo(): void }
////declare class m3e { foo(): void }
////module m3e { export var y = 2; }
////var /*1*/r = new m3e();
////r./*2*/
////var /*4*/r2 = m3e./*3*/

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

goTo.marker('2');
verify.completionListContains('foo');
verify.completions({ marker: "2", exact: "foo" });

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

goTo.marker('3');
verify.completionListContains('y');
verify.completions({ marker: "3", includes: "y" });
edit.insert('y;');

verify.quickInfoAt("4", "var r2: number");
4 changes: 1 addition & 3 deletions tests/cases/fourslash/basicClassMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@

goTo.eof();
edit.insert('t.');
verify.completionListContains('x');
verify.completionListContains('y');
verify.not.completionListContains('z');
verify.completions({ includes: ["x", "y"], excludes: "z" });
21 changes: 3 additions & 18 deletions tests/cases/fourslash/cloduleAsBaseClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,8 @@
////d./*1*/
////D./*2*/

goTo.marker('1');
verify.completionListContains('foo');
verify.completionListContains('foo2');
verify.not.completionListContains('bar');
verify.not.completionListContains('bar2');
verify.not.completionListContains('baz');
verify.not.completionListContains('x');

verify.completions({ marker: "1", exact: ["foo2", "foo"] });
edit.insert('foo()');

goTo.marker('2');
verify.not.completionListContains('foo');
verify.not.completionListContains('foo2');
verify.completionListContains('bar');
verify.completionListContains('bar2');
verify.completionListContains('baz');
verify.completionListContains('x');
verify.completions({ marker: "2", exact: ["prototype", "bar2", "bar", "baz", "x", ...completion.functionMembers] });
edit.insert('bar()');

verify.noErrors();
verify.noErrors();
3 changes: 1 addition & 2 deletions tests/cases/fourslash/closedCommentsInConstructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
//// constructor(/* /**/ */) { }
////}

goTo.marker();
verify.completionListIsEmpty();
verify.completions({ marker: "", exact: undefined });
10 changes: 7 additions & 3 deletions tests/cases/fourslash/codeCompletionEscaping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
// @allowJs: true
////___foo; __foo;/**/

goTo.marker();
verify.completionListContains("__foo", undefined, undefined, "warning");
verify.completionListContains("___foo", undefined, undefined, "warning");
verify.completions({
marker: "",
includes: [
{ name: "__foo", kind: "warning" },
{ name: "___foo", kind: "warning" },
],
});
36 changes: 20 additions & 16 deletions tests/cases/fourslash/commentsClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,26 @@ verify.quickInfos({
25: ["class c6", "class with statics and constructor"]
});

goTo.marker('26');
verify.completionListContains("c2", "class c2", "This is class c2 without constructor");
verify.completionListContains("i2", "var i2: c2", "");
verify.completionListContains("i2_c", "var i2_c: typeof c2", "");
verify.completionListContains("c3", "class c3", "");
verify.completionListContains("i3", "var i3: c3", "");
verify.completionListContains("i3_c", "var i3_c: typeof c3", "");
verify.completionListContains("c4", "class c4", "Class comment");
verify.completionListContains("i4", "var i4: c4", "");
verify.completionListContains("i4_c", "var i4_c: typeof c4", "");
verify.completionListContains("c5", "class c5", "Class with statics");
verify.completionListContains("i5", "var i5: c5", "");
verify.completionListContains("i5_c", "var i5_c: typeof c5");
verify.completionListContains("c6", "class c6", "class with statics and constructor");
verify.completionListContains("i6", "var i6: c6", "");
verify.completionListContains("i6_c", "var i6_c: typeof c6", "");
verify.completions({
marker: "26",
includes: [
{ name: "c2", text: "class c2", documentation: "This is class c2 without constructor" },
{ name: "i2", text: "var i2: c2" },
{ name: "i2_c", text: "var i2_c: typeof c2" },
{ name: "c3", text: "class c3" },
{ name: "i3", text: "var i3: c3" },
{ name: "i3_c", text: "var i3_c: typeof c3" },
{ name: "c4", text: "class c4", documentation: "Class comment" },
{ name: "i4", text: "var i4: c4" },
{ name: "i4_c", text: "var i4_c: typeof c4" },
{ name: "c5", text: "class c5", documentation: "Class with statics" },
{ name: "i5", text: "var i5: c5" },
{ name: "i5_c", text: "var i5_c: typeof c5" },
{ name: "c6", text: "class c6", documentation: "class with statics and constructor" },
{ name: "i6", text: "var i6: c6" },
{ name: "i6_c", text: "var i6_c: typeof c6" },
],
});

verify.signatureHelp({
marker: "27",
Expand Down
Loading