Improve completions testing (#23591)

This commit is contained in:
Andy 2018-05-01 13:00:13 -07:00 committed by GitHub
parent cee4289f58
commit 9f4abe2d79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 537 additions and 834 deletions

View file

@ -22,6 +22,8 @@
namespace FourSlash {
ts.disableIncrementalParsing = false;
import Many = FourSlashInterface.Many;
// Represents a parsed source file with metadata
interface FourSlashFile {
// The contents of the file (with markers, etc stripped out)
@ -615,11 +617,11 @@ namespace FourSlash {
}
}
public verifyGoToDefinitionIs(endMarker: string | string[]) {
public verifyGoToDefinitionIs(endMarker: Many<string>) {
this.verifyGoToXWorker(toArray(endMarker), () => this.getGoToDefinition());
}
public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) {
public verifyGoToDefinition(arg0: any, endMarkerNames?: Many<string>) {
this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan());
}
@ -631,23 +633,23 @@ namespace FourSlash {
return this.languageService.getDefinitionAndBoundSpan(this.activeFile.fileName, this.currentCaretPosition);
}
public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) {
public verifyGoToType(arg0: any, endMarkerNames?: Many<string>) {
this.verifyGoToX(arg0, endMarkerNames, () =>
this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition));
}
private verifyGoToX(arg0: any, endMarkerNames: string | string[] | undefined, getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
private verifyGoToX(arg0: any, endMarkerNames: Many<string> | undefined, getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
if (endMarkerNames) {
this.verifyGoToXPlain(arg0, endMarkerNames, getDefs);
}
else if (ts.isArray(arg0)) {
const pairs = arg0 as ReadonlyArray<[string | string[], string | string[]]>;
const pairs = arg0 as ReadonlyArray<[Many<string>, Many<string>]>;
for (const [start, end] of pairs) {
this.verifyGoToXPlain(start, end, getDefs);
}
}
else {
const obj: { [startMarkerName: string]: string | string[] } = arg0;
const obj: { [startMarkerName: string]: Many<string> } = arg0;
for (const startMarkerName in obj) {
if (ts.hasProperty(obj, startMarkerName)) {
this.verifyGoToXPlain(startMarkerName, obj[startMarkerName], getDefs);
@ -656,7 +658,7 @@ namespace FourSlash {
}
}
private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
private verifyGoToXPlain(startMarkerNames: Many<string>, endMarkerNames: Many<string>, getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
for (const start of toArray(startMarkerNames)) {
this.verifyGoToXSingle(start, endMarkerNames, getDefs);
}
@ -668,17 +670,17 @@ namespace FourSlash {
}
}
private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
private verifyGoToXSingle(startMarkerName: string, endMarkerNames: Many<string>, getDefs: () => ReadonlyArray<ts.DefinitionInfo> | ts.DefinitionInfoAndBoundSpan | undefined) {
this.goToMarker(startMarkerName);
this.verifyGoToXWorker(toArray(endMarkerNames), getDefs, startMarkerName);
}
private verifyGoToXWorker(endMarkers: string[], getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) {
private verifyGoToXWorker(endMarkers: ReadonlyArray<string>, getDefs: () => ReadonlyArray<ts.DefinitionInfo> | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) {
const defs = getDefs();
let definitions: ts.DefinitionInfo[] | ReadonlyArray<ts.DefinitionInfo>;
let definitions: ReadonlyArray<ts.DefinitionInfo>;
let testName: string;
if (!defs || Array.isArray(defs)) {
if (!defs || ts.isArray(defs)) {
definitions = defs as ts.DefinitionInfo[] || [];
testName = "goToDefinitions";
}
@ -830,48 +832,121 @@ namespace FourSlash {
}
}
public verifyCompletionsAt(markerName: string | ReadonlyArray<string>, expected: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: FourSlashInterface.CompletionsAtOptions) {
if (typeof markerName !== "string") {
for (const m of markerName) this.verifyCompletionsAt(m, expected, options);
return;
public verifyCompletions(options: FourSlashInterface.VerifyCompletionsOptions) {
if (options.at !== undefined) {
if (typeof options.at === "string") {
this.goToMarker(options.at);
}
else {
for (const a of options.at) this.verifyCompletions({ ...options, at: a });
return;
}
}
this.goToMarker(markerName);
const actualCompletions = this.getCompletionListAtCaret(options);
const actualCompletions = this.getCompletionListAtCaret({ ...options.preferences, triggerCharacter: options.triggerCharacter });
if (!actualCompletions) {
if (expected === undefined) return;
if (options.are === undefined) return;
this.raiseError(`No completions at position '${this.currentCaretPosition}'.`);
}
if (actualCompletions.isNewIdentifierLocation !== (options && options.isNewIdentifierLocation || false)) {
this.raiseError(`Expected 'isNewIdentifierLocation' to be ${options && options.isNewIdentifierLocation}, got ${actualCompletions.isNewIdentifierLocation}`);
if (actualCompletions.isNewIdentifierLocation !== (options.isNewIdentifierLocation || false)) {
this.raiseError(`Expected 'isNewIdentifierLocation' to be ${options.isNewIdentifierLocation || false}, got ${actualCompletions.isNewIdentifierLocation}`);
}
const actual = actualCompletions.entries;
const actualByName = ts.createMap<ts.CompletionEntry>();
for (const entry of actualCompletions.entries) {
if (actualByName.has(entry.name)) {
// TODO: GH#23587
if (entry.name !== "undefined" && entry.name !== "require") this.raiseError(`Duplicate completions for ${entry.name}`);
}
else {
actualByName.set(entry.name, entry);
}
}
if ("are" in options) {
if (options.are === undefined) this.raiseError("Expected no completions");
this.verifyCompletionsAreExactly(actualCompletions.entries, toArray(options.are));
}
else {
if (options.includes) {
for (const include of toArray(options.includes)) {
const name = typeof include === "string" ? include : include.name;
const found = actualByName.get(name);
if (!found) this.raiseError(`No completion ${name} found`);
this.verifyCompletionEntry(found, include);
}
}
else {
for (const exclude of toArray(options.excludes)) {
if (typeof exclude === "string") {
if (actualByName.has(exclude)) {
this.raiseError(`Did not expect to get a completion named ${exclude}`);
}
}
else {
const found = actualByName.get(exclude.name);
if (found.source === exclude.source) {
this.raiseError(`Did not expect to get a completion named ${exclude.name} with source ${exclude.source}`);
}
}
}
}
}
}
private verifyCompletionEntry(actual: ts.CompletionEntry, expected: FourSlashInterface.ExpectedCompletionEntry) {
const { insertText, replacementSpan, hasAction, kind, text, documentation, sourceDisplay } = typeof expected === "string"
? { insertText: undefined, replacementSpan: undefined, hasAction: undefined, kind: undefined, text: undefined, documentation: undefined, sourceDisplay: undefined }
: expected;
if (actual.insertText !== insertText) {
this.raiseError(`Expected completion insert text to be ${insertText}, got ${actual.insertText}`);
}
const convertedReplacementSpan = replacementSpan && ts.createTextSpanFromRange(replacementSpan);
try {
assert.deepEqual(actual.replacementSpan, convertedReplacementSpan);
}
catch {
this.raiseError(`Expected completion replacementSpan to be ${stringify(convertedReplacementSpan)}, got ${stringify(actual.replacementSpan)}`);
}
if (kind !== undefined) assert.equal(actual.kind, kind);
assert.equal(actual.hasAction, hasAction);
if (text) {
const actualDetails = this.getCompletionEntryDetails(actual.name, actual.source);
assert.equal(ts.displayPartsToString(actualDetails.displayParts), text);
assert.equal(ts.displayPartsToString(actualDetails.documentation), documentation || "");
// TODO: GH#23587
// assert.equal(actualDetails.kind, actual.kind);
assert.equal(actualDetails.kindModifiers, actual.kindModifiers);
assert.equal(actualDetails.source && ts.displayPartsToString(actualDetails.source), sourceDisplay);
}
else {
assert(documentation === undefined && sourceDisplay === undefined, "If specifying completion details, should specify 'text'");
}
}
private verifyCompletionsAreExactly(actual: ReadonlyArray<ts.CompletionEntry>, expected: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>) {
if (actual.length !== expected.length) {
this.raiseError(`Expected ${expected.length} completions, got ${actual.length} (${actual.map(a => a.name)}).`);
}
ts.zipWith(actual, expected, (completion, expectedCompletion, index) => {
const { name, insertText, replacementSpan } = typeof expectedCompletion === "string" ? { name: expectedCompletion, insertText: undefined, replacementSpan: undefined } : expectedCompletion;
const name = typeof expectedCompletion === "string" ? expectedCompletion : expectedCompletion.name;
if (completion.name !== name) {
this.raiseError(`Expected completion at index ${index} to be ${name}, got ${completion.name}`);
}
if (completion.insertText !== insertText) {
this.raiseError(`Expected completion insert text at index ${index} to be ${insertText}, got ${completion.insertText}`);
}
const convertedReplacementSpan = replacementSpan && ts.createTextSpanFromRange(replacementSpan);
try {
assert.deepEqual(completion.replacementSpan, convertedReplacementSpan);
}
catch {
this.raiseError(`Expected completion replacementSpan at index ${index} to be ${stringify(convertedReplacementSpan)}, got ${stringify(completion.replacementSpan)}`);
}
this.verifyCompletionEntry(completion, expectedCompletion);
});
}
public verifyCompletionsAt(markerName: string | ReadonlyArray<string>, expected: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: FourSlashInterface.CompletionsAtOptions) {
this.verifyCompletions({ at: markerName, are: expected, isNewIdentifierLocation: options && options.isNewIdentifierLocation, preferences: options, triggerCharacter: options && options.triggerCharacter });
}
public verifyCompletionListContains(entryId: ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string | { kind?: string, kindModifiers?: string }, spanIndex?: number, hasAction?: boolean, options?: FourSlashInterface.VerifyCompletionListContainsOptions) {
const completions = this.getCompletionListAtCaret(options);
if (completions) {
@ -1105,7 +1180,7 @@ namespace FourSlash {
}
}
public verifyReferenceGroups(starts: string | string[] | Range | Range[], parts: FourSlashInterface.ReferenceGroup[] | undefined): void {
public verifyReferenceGroups(starts: Many<string> | Many<Range>, parts: ReadonlyArray<FourSlashInterface.ReferenceGroup> | undefined): void {
interface ReferenceGroupJson {
definition: string | { text: string, range: ts.TextSpan };
references: ts.ReferenceEntry[];
@ -1243,7 +1318,7 @@ Actual: ${stringify(fullActual)}`);
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
}
private getCompletionListAtCaret(options?: FourSlashInterface.CompletionsAtOptions): ts.CompletionInfo {
private getCompletionListAtCaret(options?: ts.GetCompletionsAtPositionOptions): ts.CompletionInfo {
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition, options);
}
@ -1340,7 +1415,7 @@ Actual: ${stringify(fullActual)}`);
}
}
public verifyRenameLocations(startRanges: Range | Range[], options: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: Range[] }) {
public verifyRenameLocations(startRanges: Many<Range>, options: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: Range[] }) {
let findInStrings: boolean, findInComments: boolean, ranges: Range[];
if (ts.isArray(options)) {
findInStrings = findInComments = false;
@ -3730,7 +3805,7 @@ ${code}
return ts.arrayFrom(set.keys());
}
function toArray<T>(x: T | T[]): T[] {
function toArray<T>(x: Many<T>): ReadonlyArray<T> {
return ts.isArray(x) ? x : [x];
}
@ -4018,10 +4093,16 @@ namespace FourSlashInterface {
super(state);
}
public completionsAt(markerName: string | ReadonlyArray<string>, completions: ReadonlyArray<ExpectedCompletionEntry>, options?: CompletionsAtOptions) {
public completionsAt(markerName: Many<string>, completions: ReadonlyArray<ExpectedCompletionEntry>, options?: CompletionsAtOptions) {
this.state.verifyCompletionsAt(markerName, completions, options);
}
public completions(...optionsArray: VerifyCompletionsOptions[]) {
for (const options of optionsArray) {
this.state.verifyCompletions(options);
}
}
public quickInfoIs(expectedText: string, expectedDocumentation?: string) {
this.state.verifyQuickInfoString(expectedText, expectedDocumentation);
}
@ -4067,19 +4148,19 @@ namespace FourSlashInterface {
this.state.verifyCurrentFileContent(text);
}
public goToDefinitionIs(endMarkers: string | string[]) {
public goToDefinitionIs(endMarkers: Many<string>) {
this.state.verifyGoToDefinitionIs(endMarkers);
}
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[], range?: FourSlash.Range): void;
public goToDefinition(startsAndEnds: [string | string[], string | string[]][] | { [startMarkerName: string]: string | string[] }): void;
public goToDefinition(arg0: any, endMarkerName?: string | string[]) {
public goToDefinition(startMarkerName: Many<string>, endMarkerName: Many<string>, range?: FourSlash.Range): void;
public goToDefinition(startsAndEnds: [Many<string>, Many<string>][] | { [startMarkerName: string]: Many<string> }): void;
public goToDefinition(arg0: any, endMarkerName?: Many<string>) {
this.state.verifyGoToDefinition(arg0, endMarkerName);
}
public goToType(startMarkerName: string | string[], endMarkerName: string | string[]): void;
public goToType(startsAndEnds: [string | string[], string | string[]][] | { [startMarkerName: string]: string | string[] }): void;
public goToType(arg0: any, endMarkerName?: string | string[]) {
public goToType(startMarkerName: Many<string>, endMarkerName: Many<string>): void;
public goToType(startsAndEnds: [Many<string>, Many<string>][] | { [startMarkerName: string]: Many<string> }): void;
public goToType(arg0: any, endMarkerName?: Many<string>) {
this.state.verifyGoToType(arg0, endMarkerName);
}
@ -4111,7 +4192,7 @@ namespace FourSlashInterface {
this.state.verifyReferencesOf(start, references);
}
public referenceGroups(starts: string | string[] | FourSlash.Range | FourSlash.Range[], parts: ReferenceGroup[]) {
public referenceGroups(starts: Many<string> | Many<FourSlash.Range>, parts: ReferenceGroup[]) {
this.state.verifyReferenceGroups(starts, parts);
}
@ -4343,7 +4424,7 @@ namespace FourSlashInterface {
this.state.verifyRenameInfoFailed(message);
}
public renameLocations(startRanges: FourSlash.Range | FourSlash.Range[], options: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: FourSlash.Range[] }) {
public renameLocations(startRanges: Many<FourSlash.Range>, options: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: FourSlash.Range[] }) {
this.state.verifyRenameLocations(startRanges, options);
}
@ -4656,12 +4737,33 @@ namespace FourSlashInterface {
newContent: string;
}
export type ExpectedCompletionEntry = string | { name: string, insertText?: string, replacementSpan?: FourSlash.Range };
export type ExpectedCompletionEntry = string | {
readonly name: string,
readonly insertText?: string,
readonly replacementSpan?: FourSlash.Range,
readonly hasAction?: boolean, // If not specified, will assert that this is false.
readonly kind?: string, // If not specified, won't assert about this
readonly text: string;
readonly documentation: string;
readonly sourceDisplay?: string;
};
export interface CompletionsAtOptions extends Partial<ts.UserPreferences> {
triggerCharacter?: string;
isNewIdentifierLocation?: boolean;
}
export interface VerifyCompletionsOptions {
readonly at?: Many<string>;
readonly isNewIdentifierLocation?: boolean;
readonly are?: Many<ExpectedCompletionEntry>;
readonly includes?: Many<ExpectedCompletionEntry>;
readonly excludes?: Many<string | { readonly name: string, readonly source: string }>;
readonly preferences: ts.UserPreferences;
readonly triggerCharacter?: string;
}
export type Many<T> = T | ReadonlyArray<T>;
export interface VerifyCompletionListContainsOptions extends ts.UserPreferences {
triggerCharacter?: string;
sourceDisplay: string;

View file

@ -6,8 +6,6 @@
////var r = new c5b();
////r./*2*/
goTo.marker('1');
verify.completionListContains('prototype', '(property) c5b.prototype: c5b');
verify.completions({ at: "1", includes: { name: "prototype", text: '(property) c5b.prototype: c5b' } });
edit.insert('y;');
goTo.marker('2');
verify.completionListContains('foo', '(method) c5b.foo(): void');
verify.completions({ at: "2", includes: { name: "foo", text: '(method) c5b.foo(): void' } });

View file

@ -8,25 +8,19 @@
////var r2: m3f.I = r;
////r2./*6*/
goTo.marker('1');
verify.completionListContains('I');
verify.not.completionListContains('foo');
verify.completions({ at: "1", includes: "I", excludes: "foo" });
edit.insert('I;');
goTo.marker('2');
verify.completionListContains('m3f');
verify.completions({ at: "2", includes: "m3f" });
goTo.marker('3');
verify.currentSignatureHelpIs('m3f(): m3f');
verify.quickInfoAt("4", "var r: m3f");
goTo.marker('5');
verify.completionListContains('foo');
verify.completions({ at: "5", includes: "foo" });
edit.insert('foo(1)');
goTo.marker('6');
verify.completionListContains('foo');
verify.completions({ at: "6", includes: "foo" });
edit.insert('foo(');
verify.currentSignatureHelpIs('foo(): void');

View file

@ -28,22 +28,10 @@
////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({ at: "1", are: ["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({ at: "2", includes: ["bar", "bar2", "baz", "x"], excludes: ["foo", "foo2"] });
edit.insert('bar()');
verify.noErrors();

View file

@ -14,18 +14,14 @@
//// }
////}
goTo.marker('1');
verify.completionListContains('f');
verify.completionListContains('foo');
verify.completions({ at: "1", includes: ["f", "foo"] });
edit.insert('foo(1);');
goTo.marker('2');
verify.completionListContains('x');
verify.completions({ at: "2", includes: "x" });
verify.quickInfoAt("3", "(local var) r: C<number>");
goTo.marker('4');
verify.completionListContains('x');
verify.completions({ at: "4", includes: "x" });
edit.insert('x;');
verify.quickInfoAt("5", "(local var) r2: number");

View file

@ -17,16 +17,19 @@ verify.quickInfos({
4: "var x: Colors"
});
goTo.marker('5');
verify.completionListContains("Colors", "enum Colors", "Enum of colors");
verify.completions({
at: "5",
includes: { name: "Colors", text: "enum Colors", documentation: "Enum of colors" },
isNewIdentifierLocation: true,
});
verify.quickInfoIs("enum Colors", "Enum of colors");
goTo.marker('6');
verify.completionListContains("Cornflower", "(enum member) Colors.Cornflower = 0", "Fancy name for 'blue'");
verify.completionListContains("FancyPink", "(enum member) Colors.FancyPink = 1", "Fancy name for 'pink'");
const completions = [
{ name: "Cornflower", text: "(enum member) Colors.Cornflower = 0", documentation: "Fancy name for 'blue'" },
{ name: "FancyPink", text: "(enum member) Colors.FancyPink = 1", documentation: "Fancy name for 'pink'" },
];
verify.completions({ at: "6", includes: completions });
verify.quickInfoIs("(enum member) Colors.Cornflower = 0", "Fancy name for 'blue'");
goTo.marker('7');
verify.completionListContains("Cornflower", "(enum member) Colors.Cornflower = 0", "Fancy name for 'blue'");
verify.completionListContains("FancyPink", "(enum member) Colors.FancyPink = 1", "Fancy name for 'pink'");
verify.completions({ at: "7", includes: completions });
verify.quickInfoIs("(enum member) Colors.FancyPink = 1", "Fancy name for 'pink'");

View file

@ -29,13 +29,16 @@ verify.quickInfos({
3: ['import extMod = require("./commentsImportDeclaration_file0")', "Import declaration"]
});
goTo.marker('6');
verify.completionListContains("m1", "namespace extMod.m1");
verify.completions({ at: "6", are: [{ name: "m1", text: "namespace extMod.m1", documentation: "NamespaceComment" }] });
goTo.marker('7');
verify.completionListContains("b", "var extMod.m1.b: number", "b's comment");
verify.completionListContains("fooExport", "function extMod.m1.fooExport(): number", "exported function");
verify.completionListContains("m2", "namespace extMod.m1.m2");
verify.completions({
at: "7",
are: [
{ name: "fooExport", text: "function extMod.m1.fooExport(): number", documentation: "exported function" },
{ name: "b", text: "var extMod.m1.b: number", documentation: "b's comment" },
{ name: "m2", text: "namespace extMod.m1.m2", documentation: "m2 comments" },
]
})
goTo.marker('8');
verify.currentSignatureHelpDocCommentIs("exported function");
@ -44,6 +47,10 @@ verify.quickInfos({
9: "var newVar: extMod.m1.m2.c"
});
goTo.marker('10');
verify.completionListContains("c", "constructor extMod.m1.m2.c(): extMod.m1.m2.c", "");
verify.completionListContains("i", "var extMod.m1.m2.i: extMod.m1.m2.c", "i");
verify.completions({
at: "10",
are: [
{ name: "c", text: "constructor extMod.m1.m2.c(): extMod.m1.m2.c" },
{ name: "i", text: "var extMod.m1.m2.i: extMod.m1.m2.c", documentation: "i" },
],
});

View file

@ -43,16 +43,26 @@
verify.quickInfoAt("1", "var myVariable: number", "This is my variable");
goTo.marker('2');
verify.completionListContains("myVariable", "var myVariable: number", "This is my variable");
goTo.marker('3');
verify.completionListContains("myVariable", "var myVariable: number", "This is my variable");
verify.completionListContains("d", "var d: number", "d variable");
goTo.marker('4');
verify.completionListContains("foo", "function foo(): void", "foos comment");
verify.completionListContains("fooVar", "var fooVar: () => void", "fooVar comment");
verify.completions(
{
at: "2",
includes: { name: "myVariable", text: "var myVariable: number", documentation: "This is my variable" },
},
{
at: "3",
includes: [
{ name: "myVariable", text: "var myVariable: number", documentation: "This is my variable" },
{ name: "d", text: "var d: number", documentation: "d variable" }
],
},
{
at: "4",
includes: [
{ name: "foo", text: "function foo(): void", documentation: "foos comment" },
{ name: "fooVar", text: "var fooVar: () => void", documentation:"fooVar comment" },
]
},
)
goTo.marker('5');
verify.currentSignatureHelpDocCommentIs("foos comment");
@ -62,9 +72,13 @@ goTo.marker('6');
verify.currentSignatureHelpDocCommentIs("fooVar comment");
verify.quickInfoAt("6q", "var fooVar: () => void", "fooVar comment");
goTo.marker('7');
verify.completionListContains("foo", "function foo(): void", "foos comment");
verify.completionListContains("fooVar", "var fooVar: () => void", "fooVar comment");
verify.completions({
at: "7",
includes: [
{ name: "foo", text: "function foo(): void", documentation: "foos comment" },
{ name: "fooVar", text: "var fooVar: () => void", documentation:"fooVar comment" },
],
});
goTo.marker('8');
verify.currentSignatureHelpDocCommentIs("foos comment");
@ -77,11 +91,8 @@ verify.quickInfos({
"9aq": ["var fooVar: () => void", "fooVar comment"]
});
goTo.marker('10');
verify.completionListContains("i", "var i: c", "instance comment");
goTo.marker('11');
verify.completionListContains("i1_i", "var i1_i: i1", "interface instance comments");
verify.completions({ at: "10", includes: { name: "i", text: "var i: c", documentation: "instance comment" } });
verify.completions({ at: "11", includes: { name: "i1_i", text: "var i1_i: i1", documentation: "interface instance comments" } });
verify.quickInfos({
12: ["var fooVar: () => void", "fooVar comment"],

View file

@ -17,19 +17,11 @@
// @Filename: package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: node_modules/fake-module/ts.ts
//// /*module1*/
////
// @Filename: dir1/dir2/dir3/package.json
//// { "dependencies": { "fake-module3": "latest" } }
// @Filename: dir1/dir2/dir3/node_modules/fake-module3/ts.ts
//// /*module3*/
////
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListIsEmpty();
goTo.marker(kind + "1");
verify.completionListIsEmpty();
}
verify.completions({ at: test.markerNames(), are: [], isNewIdentifierLocation: true });

View file

@ -21,18 +21,16 @@
// @Filename: node_modules/module-from-node/index.ts
//// /*module1*/
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListContains("module");
verify.not.completionListItemsCountIsGreaterThan(1);
goTo.marker(kind + "1");
verify.completionListContains("index");
verify.not.completionListItemsCountIsGreaterThan(1);
}
verify.completions(
{
at: kinds.map(k => `${k}0`),
are: "module",
isNewIdentifierLocation: true,
},
{
at: kinds.map(k => `${k}1`),
are: "index",
isNewIdentifierLocation: true,
},
)

View file

@ -15,14 +15,8 @@
//// "peerDependencies": { "peer-module": "latest" }
//// }
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListContains("module");
verify.completionListContains("dev-module");
verify.completionListContains("optional-module");
verify.completionListContains("peer-module");
verify.not.completionListItemsCountIsGreaterThan(4);
}
verify.completions({
at: test.markerNames(),
are: ["module", "dev-module", "peer-module", "optional-module"],
isNewIdentifierLocation: true,
});

View file

@ -10,25 +10,20 @@
// @Filename: package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: node_modules/fake-module/ts.ts
//// /*module1*/
////
// @Filename: dir1/package.json
//// { "dependencies": { "fake-module2": "latest" } }
// @Filename: dir1/node_modules/fake-module2/index.ts
//// /*module2*/
////
// @Filename: dir1/dir2/dir3/package.json
//// { "dependencies": { "fake-module3": "latest" } }
// @Filename: dir1/dir2/dir3/node_modules/fake-module3/ts.ts
//// /*module3*/
////
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListContains("fake-module");
verify.completionListContains("fake-module2");
verify.completionListContains("fake-module3");
verify.not.completionListItemsCountIsGreaterThan(3);
}
verify.completions({
at: test.markerNames(),
are: ["fake-module3", "fake-module2", "fake-module"],
isNewIdentifierLocation: true,
});

View file

@ -16,24 +16,18 @@
// @Filename: ambientModules.d.ts
//// declare module "ambientModule" {}
//// declare module "otherAmbientModule" {} /*dummy0*/
//// declare module "otherAmbientModule" {}
// @Filename: ambientModules2.d.ts
//// declare module "otherOtherAmbientModule" {} /*dummy1*/
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListContains("ambientModule");
verify.completionListContains("otherAmbientModule");
verify.completionListContains("otherOtherAmbientModule");
verify.not.completionListItemsCountIsGreaterThan(3);
goTo.marker(kind + "1");
verify.completionListContains("ambientModule");
verify.not.completionListItemsCountIsGreaterThan(1);
}
//// declare module "otherOtherAmbientModule" {}
verify.completions({
at: test.markerNames().filter(k => k.endsWith("0")),
are: ["ambientModule", "otherAmbientModule", "otherOtherAmbientModule"],
isNewIdentifierLocation: true,
});
verify.completions({
at: test.markerNames().filter(k => !k.endsWith("0")),
are: "ambientModule",
isNewIdentifierLocation: true,
});

View file

@ -15,16 +15,10 @@
// @Filename: package.json
//// { "dependencies": { "module-from-node": "latest" } }
// @Filename: node_modules/module-from-node/index.ts
//// /*module1*/
////
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListContains("module");
verify.completionListContains("module-from-node");
verify.not.completionListItemsCountIsGreaterThan(2);
}
verify.completions({
at: test.markerNames(),
are: ["module", "module-from-node"],
isNewIdentifierLocation: true,
});

View file

@ -40,5 +40,8 @@
// @Filename: modules/2test/suffix-only.ts
//// export var z = 5;
const markers = ts.flatMap(["import_as", "import_equals", "require"], a => [`${a}0`, `${a}1`, `${a}2`]);
verify.completionsAt(markers, ["prefix", "prefix-only", "2test", "0test", "1test"], { isNewIdentifierLocation: true });
verify.completions({
at: test.markerNames(),
are: ["prefix", "prefix-only", "2test", "0test", "1test"],
isNewIdentifierLocation: true,
});

View file

@ -25,12 +25,4 @@
// @Filename: some/other/path.ts
//// export var y = 10;
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListContains("module1");
verify.completionListContains("module2");
verify.not.completionListItemsCountIsGreaterThan(2);
}
verify.completions({ at: test.markerNames(), are: ["module1", "module2"], isNewIdentifierLocation: true });

View file

@ -31,21 +31,14 @@
//// /*e2*/
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListContains("fourslash");
verify.not.completionListItemsCountIsGreaterThan(1);
goTo.marker(kind + "1");
verify.completionListContains("fourslash");
verify.not.completionListItemsCountIsGreaterThan(1);
goTo.marker(kind + "2");
verify.completionListContains("f1");
verify.completionListContains("f2");
verify.completionListContains("e1");
verify.completionListContains("folder");
verify.completionListContains("tests");
verify.not.completionListItemsCountIsGreaterThan(5);
}
verify.completions(
{
at: [...kinds.map(k => `${k}0`), ...kinds.map(k => `${k}1`)],
are: "fourslash",
isNewIdentifierLocation: true,
},
{
at: kinds.map(k => `${k}2`),
are: ["e1", "f1", "f2", "tests", "folder"],
isNewIdentifierLocation: true,
});

View file

@ -23,30 +23,22 @@
// @Filename: f1.ts
//// /*f1*/
////
// @Filename: f2.tsx
//// /*f2*/
////
// @Filename: folder/f1.ts
//// /*subf1*/
////
// @Filename: f3.js
//// /*f3*/
////
// @Filename: f4.jsx
//// /*f4*/
////
// @Filename: e1.ts
//// /*e1*/
////
// @Filename: e2.js
//// /*e2*/
////
const kinds = ["import_as", "import_equals", "require"];
for (const kind of kinds) {
goTo.marker(kind + "0");
verify.completionListContains("module0");
verify.completionListContains("module1");
verify.completionListContains("module2");
verify.completionListContains("more");
// Should not contain itself
verify.not.completionListItemsCountIsGreaterThan(4);
}
verify.completions({
at: test.markerNames(),
are: ["module1", "module2", "more", "module0"],
isNewIdentifierLocation: true,
});

View file

@ -4,9 +4,4 @@
//// /*1*/
////
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completions({ at: "1", includes: ["foo", "x", "y", "z"] });

View file

@ -3,14 +3,5 @@
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string, c: typeof /*1*/
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c"); // questionable
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})

View file

@ -4,14 +4,5 @@
//// function bar(a: number, b: string, c: typeof /*1*/
////}
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c"); // questionable
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})

View file

@ -3,14 +3,5 @@
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string, c: typeof x = /*1*/
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c"); // questionable
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})

View file

@ -4,14 +4,5 @@
//// function bar(a: number, b: string, c: typeof x = /*1*/
////}
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c"); // questionable
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})

View file

@ -4,14 +4,5 @@
//// function bar(a: number, b: string = /*1*/, c: typeof x = "hello"
////
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c"); // definitely questionable
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})

View file

@ -4,14 +4,5 @@
//// function bar(a: number, b: string = /*1*/, c: typeof x = "hello"
////}
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c"); // definitely questionable
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})

View file

@ -4,16 +4,5 @@
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = /*1*/
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c");
verify.completionListContains("v"); // questionable
// Note: "v" questionable since we're in its initializer
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v"], isNewIdentifierLocation: true });

View file

@ -5,16 +5,5 @@
//// var v = /*1*/
////}
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c");
verify.completionListContains("v"); // questionable
// Note: "v" questionable since we're in its initializer
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v"], isNewIdentifierLocation: true });

View file

@ -7,6 +7,4 @@
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (p: /*1*/
goTo.marker("1");
verify.completionListContains("MyType");
verify.completions({ at: "1", includes: "MyType" });

View file

@ -7,6 +7,4 @@
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (p: /*1*/
goTo.marker("1");
verify.completionListContains("MyType");
verify.completions({ at: "1", includes: "MyType" });

View file

@ -8,6 +8,4 @@
//// var v = (p: /*1*/
////}
goTo.marker("1");
verify.completionListContains("MyType");
verify.completions({ at: "1", includes: "MyType" });

View file

@ -9,6 +9,4 @@
//// }
////}
goTo.marker("1");
verify.completionListContains("MyType");
verify.completions({ at: "1", includes: "MyType" });

View file

@ -9,17 +9,4 @@
//// }
////}
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c");
verify.completionListContains("v");
verify.completionListContains("p");
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });

View file

@ -8,17 +8,4 @@
//// var v = (p: MyType) => /*1*/
////}
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c");
verify.completionListContains("v");
verify.completionListContains("p");
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });

View file

@ -7,17 +7,4 @@
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (p: MyType) => /*1*/
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c");
verify.completionListContains("v");
verify.completionListContains("p");
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });

View file

@ -7,17 +7,4 @@
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (p: MyType) => y + /*1*/
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c");
verify.completionListContains("v");
verify.completionListContains("p");
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });

View file

@ -8,17 +8,4 @@
//// var v = (p: MyType) => y + /*1*/
////}
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c");
verify.completionListContains("v");
verify.completionListContains("p");
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });

View file

@ -7,17 +7,4 @@
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (p: MyType) => { return y + /*1*/
goTo.marker("1");
verify.completionListContains("foo");
verify.completionListContains("x");
verify.completionListContains("y");
verify.completionListContains("z");
verify.completionListContains("bar");
verify.completionListContains("a");
verify.completionListContains("b");
verify.completionListContains("c");
verify.completionListContains("v");
verify.completionListContains("p");
verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });

View file

@ -7,12 +7,8 @@
////
////declare function foo<TString, TNumber>(obj: I<TString, TNumber>): { str: TStr/*1*/
goTo.marker("1");
verify.completionListContains("I");
verify.completionListContains("TString");
verify.completionListContains("TNumber"); // REVIEW: Is this intended behavior?
// Ideally the following shouldn't show up since they're not types.
verify.not.completionListContains("foo");
verify.not.completionListContains("obj");
verify.completions({
at: "1",
includes: ["I", "TString", "TNumber"], // REVIEW: Is TNumber intended behavior?
excludes: ["foo", "obj"], // These shouldn't show up since they're not types.
})

View file

@ -1,12 +1,5 @@
/// <reference path="fourslash.ts"/>
/////**/
////
goTo.marker();
verify.completionListContains("any");
verify.completionListContains("boolean");
verify.completionListContains("null");
verify.completionListContains("number");
verify.completionListContains("string");
verify.completionListContains("undefined");
verify.completionListContains("void");
verify.completions({ includes: ["any", "boolean", "null", "number", "string", "undefined", "void"] })

View file

@ -18,27 +18,10 @@
////var b: Base;
////f./*5*/
goTo.marker("1");
verify.completionListContains("y");
verify.completionListContains("x");
verify.not.completionListContains("z");
goTo.marker("2");
verify.completionListContains("y");
verify.completionListContains("x");
verify.completionListContains("z");
goTo.marker("3");
verify.completionListContains("y");
verify.completionListContains("x");
verify.not.completionListContains("z");
goTo.marker("4");
verify.completionListContains("y");
verify.completionListContains("x");
verify.completionListContains("z");
goTo.marker("5");
verify.not.completionListContains("x");
verify.not.completionListContains("y");
verify.not.completionListContains("z");
verify.completions(
{ at: "1", are: ["y", "x", "method"] },
{ at: "2", are: ["z", "method1", "y", "x", "method"] },
{ at: "3", are: ["method2", "y", "x", "method"] },
{ at: "4", are: ["method2", "z", "method1", "y", "x", "method"] },
{ at: "5", are: undefined },
);

View file

@ -25,35 +25,16 @@
//// protected static protectedOverriddenProperty;
////}
// Same class, everything is visible
goTo.marker("1");
verify.completionListContains('privateMethod');
verify.completionListContains('privateProperty');
verify.completionListContains('protectedMethod');
verify.completionListContains('protectedProperty');
verify.completionListContains('publicMethod');
verify.completionListContains('publicProperty');
verify.completionListContains('protectedOverriddenMethod');
verify.completionListContains('protectedOverriddenProperty');
goTo.marker("2");
verify.completionListContains('privateMethod');
verify.completionListContains('privateProperty');
verify.completionListContains('protectedMethod');
verify.completionListContains('protectedProperty');
verify.completionListContains('publicMethod');
verify.completionListContains('publicProperty');
verify.completionListContains('protectedOverriddenMethod');
verify.completionListContains('protectedOverriddenProperty');
// Can not access protected properties overridden in subclass
goTo.marker("3");
verify.completionListContains('privateMethod');
verify.completionListContains('privateProperty');
verify.completionListContains('protectedMethod');
verify.completionListContains('protectedProperty');
verify.completionListContains('publicMethod');
verify.completionListContains('publicProperty');
verify.not.completionListContains('protectedOverriddenMethod');
verify.not.completionListContains('protectedOverriddenProperty');
verify.completions(
{
at: ["1", "2"],
// Same class, everything is visible
includes: ["privateMethod", "privateProperty", "protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "protectedOverriddenMethod", "protectedOverriddenProperty"],
},
{
at: "3",
includes: ["privateMethod", "privateProperty", "protectedMethod", "protectedProperty", "publicMethod", "publicProperty"],
// Can not access protected properties overridden in subclass
excludes: ["protectedOverriddenMethod", "protectedOverriddenProperty"],
},
);

View file

@ -23,13 +23,16 @@
//// }
////}
goTo.marker();
verify.not.completionListContains("publicProperty");
verify.completionListContains("publicInstanceMethod");
// No statics
verify.not.completionListContains("publicStaticProperty");
verify.not.completionListContains("publicStaticMethod");
// No privates
verify.not.completionListContains("privateProperty");
verify.not.completionListContains("privateInstanceMethod");
verify.completions({
at: "",
includes: "publicInstanceMethod",
excludes: [
"publicProperty",
// No statics
"publicStaticProperty",
"publicStaticMethod",
// No privates
"privateProperty",
"privateInstanceMethod",
]
});

View file

@ -7,8 +7,8 @@
//// declare module 'https' {
//// }
//// /*2*/
goTo.marker("1");
verify.not.completionListContains("http");
goTo.marker("2");
verify.not.completionListContains("http");
verify.not.completionListContains("https");
verify.completions(
{ at: "1", excludes: "http" },
{ at: "2", excludes: ["http", "https"] },
);

View file

@ -14,22 +14,10 @@
////B./*2*/
////A./*3*/
goTo.marker('1');
verify.completionListContains('foo');
verify.completionListContains('bar');
verify.completionListContains('baz');
edit.insert('foo;');
goTo.eachMarker((_, i) => {
const all = ["foo", "bar", "baz"];
verify.completions({ includes: all.slice(0, 3 - i), excludes: all.slice(3 - i) });
edit.insert("foo;");
});
goTo.marker('2');
verify.completionListContains('foo');
verify.completionListContains('bar');
verify.not.completionListContains('baz');
edit.insert('foo;');
goTo.marker('3');
verify.completionListContains('foo');
verify.not.completionListContains('bar');
verify.not.completionListContains('baz');
edit.insert('foo;');
verify.noErrors();
verify.noErrors();

View file

@ -17,22 +17,10 @@
////var a = new A();
////a./*3*/
goTo.marker('1');
verify.completionListContains('foo');
verify.completionListContains('bar');
verify.completionListContains('baz');
edit.insert('foo;');
goTo.marker('2');
verify.completionListContains('foo');
verify.completionListContains('bar');
verify.not.completionListContains('baz');
edit.insert('foo;');
goTo.marker('3');
verify.completionListContains('foo');
verify.not.completionListContains('bar');
verify.not.completionListContains('baz');
edit.insert('foo;');
goTo.eachMarker((_, i) => {
const all = ["foo", "bar", "baz"];
verify.completions({ includes: all.slice(0, 3 - i), excludes: all.slice(3 - i) });
edit.insert("foo;");
});
verify.noErrors();

View file

@ -24,17 +24,9 @@
////const a = import("./a"); // Does not make this an external module
////fo/*d2*/
for (const marker of ["b", "c", "d"]) {
goTo.marker(marker);
verify.not.completionListContains({ name: "foo", source: "/node_modules/a/index" }, undefined, undefined, undefined, undefined, undefined, {
includeCompletionsForModuleExports: true
});
}
for (const marker of ["c2", "d2"]) {
goTo.marker(marker);
verify.completionListContains({ name: "foo", source: "/node_modules/a/index" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, {
includeCompletionsForModuleExports: true,
sourceDisplay: "a",
});
}
verify.completions({ at: ["b", "c", "d"], excludes: "foo", preferences: { includeCompletionsForModuleExports: true } });
verify.completions({
at: ["c2", "d2"],
includes: [{ name: "foo", source: "/node_modules/a/index", text: "const foo: 0", kind: "const", hasAction: true, sourceDisplay: "a" }],
preferences: { includeCompletionsForModuleExports: true },
});

View file

@ -11,14 +11,11 @@
////fooB/*1*/
goTo.marker("0");
const options = {
includeExternalModuleExports: true,
sourceDisplay: "./foo-bar",
};
verify.not.completionListContains({ name: "default", source: "/src/foo-bar" }, undefined, undefined, undefined, undefined, undefined, options);
goTo.marker("1");
verify.completionListContains({ name: "fooBar", source: "/src/foo-bar" }, "(property) default: 0", "", "property", /*spanIndex*/ undefined, /*hasAction*/ true, options);
const preferences = { includeCompletionsForModuleExports: true };
verify.completions(
{ at: "0", excludes: { name: "default", source: "/src/foo-bar" }, preferences },
{ at: "1", includes: { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) default: 0", kind: "property", hasAction: true }, preferences }
);
verify.applyCodeActionFromCompletion("1", {
name: "fooBar",
source: "/src/foo-bar",

View file

@ -14,12 +14,10 @@
// @Filename: /b.ts
////bdf/**/
goTo.marker("");
const options = { includeExternalModuleExports: true, sourceDisplay: "./a" };
verify.not.completionListContains({ name: "abcde", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options);
verify.not.completionListContains({ name: "dbf", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options);
verify.completionListContains({ name: "bdf", source: "/a" }, "function bdf(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, options);
verify.completionListContains({ name: "abcdef", source: "/a" }, "function abcdef(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, options);
verify.completionListContains({ name: "BDF", source: "/a" }, "function BDF(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, options);
verify.completions({
at: "",
includes: ["bdf", "abcdef", "BDF"].map(name =>
({ name, source: "/a", text: `function ${name}(): void`, hasAction: true, kind: "function", sourceDisplay: "./a" })),
excludes: ["abcde", "dbf"],
preferences: { includeCompletionsForModuleExports: true },
})

View file

@ -9,11 +9,15 @@
////import { Test2 } from "./a";
////t/**/
goTo.marker("");
const options = { includeExternalModuleExports: true, sourceDisplay: undefined };
verify.completionListContains({ name: "Test1", source: "/a" }, "function Test1(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./a" });
verify.completionListContains("Test2", "(alias) function Test2(): void\nimport Test2", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ undefined, options);
verify.not.completionListContains({ name: "Test2", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options);
verify.completions({
at: "",
includes: [
{ name: "Test1", source: "/a", sourceDisplay: "./a", text: "function Test1(): void", kind: "function", hasAction: true },
{ name: "Test2", text: "(alias) function Test2(): void\nimport Test2", kind: "alias" },
],
excludes: [{ name: "Test2", source: "/a" }],
preferences: { includeCompletionsForModuleExports: true },
});
verify.applyCodeActionFromCompletion("", {
name: "Test1",

View file

@ -8,5 +8,4 @@
// @Filename: /src/b.ts
////fo/**/;
goTo.marker("");
verify.not.completionListContains({ name: "foo", source: "/unrelated/node_modules/@types/foo/index" }, undefined, undefined, undefined, undefined, undefined, { includeExternalModuleExports: true });
verify.completions({ at: "", excludes: "foo", preferences: { includeCompletionsForModuleExports: true } });

View file

@ -19,11 +19,12 @@
// @Filename: /b.ts
////fo/**/
goTo.marker("");
const options = { includeExternalModuleExports: true, sourceDisplay: "./a" };
verify.completionListContains({ name: "foo", source: "/a" }, "(alias) const foo: 0\nexport foo", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ true, options);
verify.not.completionListContains({ name: "foo", source: "/a_reexport" }, undefined, undefined, undefined, undefined, undefined, options);
verify.not.completionListContains({ name: "foo", source: "/a_reexport_2" }, undefined, undefined, undefined, undefined, undefined, options);
verify.completions({
at: "",
includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "(alias) const foo: 0\nexport foo", kind: "alias", hasAction: true },
excludes: [{ name: "foo", source: "/a_reexport" }, { name: "foo", source: "/a_reexport_2" }],
preferences: { includeCompletionsForModuleExports: true },
});
verify.applyCodeActionFromCompletion("", {
name: "foo",

View file

@ -15,11 +15,12 @@
// @Filename: /user.ts
////fo/**/
goTo.marker("");
const options = { includeExternalModuleExports: true, sourceDisplay: "./foo" };
verify.completionListContains({ name: "foo", source: "/foo/lib/foo" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, options);
verify.not.completionListContains({ name: "foo", source: "/foo/index" }, undefined, undefined, undefined, undefined, undefined, options);
verify.completions({
at: "",
includes: { name: "foo", source: "/foo/lib/foo", sourceDisplay: "./foo", text: "const foo: 0", kind: "const", hasAction: true },
excludes: { name: "foo", source: "/foo/index" },
preferences: { includeCompletionsForModuleExports: true },
});
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/foo/lib/foo",

View file

@ -7,7 +7,9 @@
////const foo = 1;
////fo/**/
goTo.marker("");
const options = { includeExternalModuleExports: true, sourceDisplay: undefined };
verify.completionListContains("foo", "const foo: 1", "", "const", undefined, undefined, options);
verify.not.completionListContains({ name: "foo", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options);
verify.completions({
at: "",
includes: "foo",
excludes: { name: "foo", source: "/a" },
preferences: { includeCompletionsForModuleExports: true },
})

View file

@ -20,11 +20,8 @@
//// }
////}
goTo.marker("0");
verify.completionListContains("dir", undefined, undefined, "directory");
verify.completionListContains("b", undefined, undefined, "script");
goTo.marker("1");
verify.completionListContains("dir", undefined, undefined, "directory");
verify.completionListContains("b", undefined, undefined, "script");
verify.completions({
at: ["0", "1"],
are: [{ name: "b", kind: "script" }, { name: "dir", kind: "directory" }],
isNewIdentifierLocation: true
});

View file

@ -19,21 +19,19 @@
////const ctr = </*openTag*/
////const less = 1 </*lessThan*/
verify.completionsAt("openQuote", ["a", "b"], { triggerCharacter: '"' });
verify.completionsAt("closeQuote", undefined, { triggerCharacter: '"' });
verify.completions(
{ at: "openQuote", are: ["a", "b"], triggerCharacter: '"' },
{ at: "closeQuote", are: undefined, triggerCharacter: '"' },
verify.completionsAt("openSingleQuote", ["a", "b"], { triggerCharacter: "'" });
verify.completionsAt("closeSingleQuote", undefined, { triggerCharacter: "'" });
{ at: "openSingleQuote", are: ["a", "b"], triggerCharacter: "'" },
{ at: "closeSingleQuote", are: undefined, triggerCharacter: "'" },
verify.completionsAt("openTemplate", ["a", "b"], { triggerCharacter: "`" });
verify.completionsAt("closeTemplate", undefined, { triggerCharacter: "`" });
{ at: "openTemplate", are: ["a", "b"], triggerCharacter: "`" },
{ at: "closeTemplate", are: undefined, triggerCharacter: "`" },
verify.completionsAt("openTemplateInQuote", undefined, { triggerCharacter: '`' });
verify.completionsAt("closeTemplateInQuote", undefined, { triggerCharacter: '`' });
{ at: "quoteInComment", are: undefined, triggerCharacter: '"' },
{ at: "lessInComment", are: undefined, triggerCharacter: "<" },
verify.completionsAt("quoteInComment", undefined, { triggerCharacter: '"' });
verify.completionsAt("lessInComment", undefined, { triggerCharacter: "<" });
goTo.marker("openTag");
verify.completionListContains("div", undefined, undefined, undefined, undefined, undefined, { triggerCharacter: "<" });
verify.completionsAt("lessThan", undefined, { triggerCharacter: "<" });
{ at: "openTag", includes: "div", triggerCharacter: "<" },
{ at: "lessThan", are: undefined, triggerCharacter: "<" },
);

View file

@ -13,27 +13,23 @@
////var c3: Collection<Collection<number>>;
////var _: Combinators;
////var r = _.forEach(c2, (x) => { return x./*1*/toFixed() });
////var r2 = _.forEach(c3, (x) => { return x./*2*/toFixed() });
////var r2 = _.forEach(c3, (x) => { return x./*2*/toFixed() });
/////*3*/
goTo.marker('1');
verify.completionListContains('toFixed');
goTo.marker('2');
verify.completionListContains('add');
verify.completionListContains('length');
verify.completionListContains('remove');
const verifyCompletions = () =>
verify.completions(
{ at: "1", includes: "toFixed" },
{ at: "2", are: ["length", "add", "remove"] },
);
verifyCompletions();
goTo.marker('3');
edit.insert("class A {\
foo() { }\
}\
var c4: Collection<A>;\
var r3 = _.forEach(c4, (x) => { return x.foo() });\
");
edit.insert(`class A {
foo() { }
}
var c4: Collection<A>;
var r3 = _.forEach(c4, (x) => { return x.foo() });
`);
goTo.marker('1');
verify.completionListContains('toFixed');
goTo.marker('2');
verify.completionListContains('add');
verify.completionListContains('length');
verify.completionListContains('remove');
verifyCompletions();

View file

@ -201,7 +201,16 @@ declare namespace FourSlashInterface {
class verify extends verifyNegatable {
assertHasRanges(ranges: Range[]): void;
caretAtMarker(markerName?: string): void;
completionsAt(markerName: string | ReadonlyArray<string>, completions: ReadonlyArray<string | { name: string, insertText?: string, replacementSpan?: Range }>, options?: CompletionsAtOptions): void;
completions(...options: {
readonly at?: Many<string>,
readonly isNewIdentifierLocation?: boolean;
readonly are?: Many<ExpectedCompletionEntry>;
readonly includes?: Many<ExpectedCompletionEntry>;
readonly excludes?: Many<string | { name: string, source: string }>;
readonly preferences?: UserPreferences;
readonly triggerCharacter?: string;
}[]): void;
completionsAt(markerName: Many<string>, completions: ReadonlyArray<ExpectedCompletionEntry>, options?: CompletionsAtOptions): void;
applyCodeActionFromCompletion(markerName: string, options: {
name: string,
source?: string,
@ -222,23 +231,23 @@ declare namespace FourSlashInterface {
currentLineContentIs(text: string): void;
currentFileContentIs(text: string): void;
/** Verifies that goToDefinition at the current position would take you to `endMarker`. */
goToDefinitionIs(endMarkers: string | string[]): void;
goToDefinitionIs(endMarkers: Many<string>): void;
goToDefinitionName(name: string, containerName: string): void;
/**
* `verify.goToDefinition("a", "b");` verifies that go-to-definition at marker "a" takes you to marker "b".
* `verify.goToDefinition(["a", "aa"], "b");` verifies that markers "a" and "aa" have the same definition "b".
* `verify.goToDefinition("a", ["b", "bb"]);` verifies that "a" has multiple definitions available.
*/
goToDefinition(startMarkerNames: string | string[], endMarkerNames: string | string[]): void;
goToDefinition(startMarkerNames: string | string[], endMarkerNames: string | string[], range: Range): void;
goToDefinition(startMarkerNames: Many<string>, endMarkerNames: Many<string>): void;
goToDefinition(startMarkerNames: Many<string>, endMarkerNames: Many<string>, range: Range): void;
/** Performs `goToDefinition` for each pair. */
goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void;
goToDefinition(startsAndEnds: [Many<string>, Many<string>][]): void;
/** Performs `goToDefinition` on each key and value. */
goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
goToDefinition(startsAndEnds: { [startMarkerName: string]: Many<string> }): void;
/** Verifies goToDefinition for each `${markerName}Reference` -> `${markerName}Definition` */
goToDefinitionForMarkers(...markerNames: string[]): void;
goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
goToType(startMarkerNames: string | string[], endMarkerNames: string | string[]): void;
goToType(startsAndEnds: { [startMarkerName: string]: Many<string> }): void;
goToType(startMarkerNames: Many<string>, endMarkerNames: Many<string>): void;
verifyGetEmitOutputForCurrentFile(expected: string): void;
verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void;
noReferences(markerNameOrRange?: string | Range): void;
@ -254,7 +263,7 @@ declare namespace FourSlashInterface {
* For each of starts, asserts the ranges that are referenced from there.
* This uses the 'findReferences' command instead of 'getReferencesAtPosition', so references are grouped by their definition.
*/
referenceGroups(starts: string | string[] | Range | Range[], parts: Array<{ definition: ReferencesDefinition, ranges: Range[] }>): void;
referenceGroups(starts: Many<string> | Many<Range>, parts: Array<{ definition: ReferencesDefinition, ranges: Range[] }>): void;
singleReferenceGroup(definition: ReferencesDefinition, ranges?: Range[]): void;
rangesAreOccurrences(isWriteAccess?: boolean): void;
rangesWithSameTextAreRenameLocations(): void;
@ -325,7 +334,7 @@ declare namespace FourSlashInterface {
}[]): void;
renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string): void;
renameInfoFailed(message?: string): void;
renameLocations(startRanges: Range | Range[], options: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: Range[] }): void;
renameLocations(startRanges: Many<Range>, options: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: Range[] }): void;
/** Verify the quick info available at the current marker. */
quickInfoIs(expectedText: string, expectedDocumentation?: string): void;
@ -539,6 +548,21 @@ declare namespace FourSlashInterface {
triggerCharacter?: string;
isNewIdentifierLocation?: boolean;
}
type ExpectedCompletionEntry = string | {
readonly name: string,
readonly source?: string,
readonly insertText?: string,
readonly replacementSpan?: Range,
readonly hasAction?: boolean,
readonly kind?: string,
// details
readonly text?: string,
readonly documentation?: string,
readonly sourceDisplay?: string,
};
type Many<T> = T | ReadonlyArray<T>;
}
declare function verifyOperationIsCancelled(f: any): void;
declare var test: FourSlashInterface.test_;

View file

@ -21,15 +21,4 @@
////l./*7*/prototype = Object.prototype;
verify.noErrors();
for (var i = 1; i <= 7; i++) {
goTo.marker('' + i);
verify.completionListCount(8);
verify.completionListContains('apply');
verify.completionListContains('arguments');
verify.completionListContains('bind');
verify.completionListContains('call');
verify.completionListContains('length');
verify.completionListContains('caller');
verify.completionListContains('prototype');
verify.completionListContains('toString');
}
verify.completionsAt(test.markerNames(), ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]);

View file

@ -23,14 +23,8 @@
//// */
////var test1 = function(x) { return x./*4*/ }, test2 = function(a) { return a./*5*/ };
goTo.marker("1");
verify.completionListContains("charCodeAt", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
goTo.marker("2");
verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
goTo.marker("3");
verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
goTo.marker("4");
verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
goTo.marker("5");
verify.completionListContains("test1", /*displayText:*/ undefined, /*documentation*/ undefined, "warning");
verify.completions(
{ at: "1", includes: { name: "charCodeAt", kind: "method" }, isNewIdentifierLocation: true },
{ at: ["2", "3", "4"], includes: { name: "toExponential", kind: "method" } },
{ at: "5", includes: { name: "test1", kind: "warning" } },
);

View file

@ -13,14 +13,7 @@
/////*1*/
////file2Identifier2./*2*/
goTo.marker("1");
verify.completionListContains("file2Identifier1");
verify.completionListContains("file2Identifier2");
verify.completionListContains("file1Identifier");
verify.not.completionListContains("FooProp");
goTo.marker("2");
verify.completionListContains("file2Identifier1");
verify.completionListContains("file2Identifier2");
verify.not.completionListContains("file1Identifier")
verify.not.completionListContains("FooProp");
verify.completions(
{ at: "1", includes: ["file2Identifier1", "file2Identifier2", "file1Identifier"], excludes: "FooProp" },
{ at: "2", includes: ["file2Identifier1", "file2Identifier2"], excludes: ["file1Identifier", "FooProp"] },
)

View file

@ -19,13 +19,11 @@
goTo.marker();
edit.insert('.');
verify.completionListContains("bar", /*displayText*/ undefined, /*documentation*/ undefined, "property");
verify.completionListContains("thing", /*displayText*/ undefined, /*documentation*/ undefined, "property");
verify.completionListContains("union", /*displayText*/ undefined, /*documentation*/ undefined, "property");
verify.completions({ are: ["bar", "thing", "union", "Foo", "x"] });
edit.insert('bar.');
verify.completionListContains("substr", /*displayText*/ undefined, /*documentation*/ undefined, "method");
verify.completions({ includes: ["substr"], isNewIdentifierLocation: true });
edit.backspace('bar.'.length);
edit.insert('union.');
verify.completionListContains("toString", /*displayText*/ undefined, /*documentation*/ undefined, "method", undefined, undefined, { allowDuplicate: true });
verify.completions({ includes: "toString" });

View file

@ -12,7 +12,7 @@
//// var y;
//// if(true) {
//// y = require('fs');
//// }
//// }
//// /*2*/
// @Filename: glob1.js
@ -26,32 +26,8 @@
// @Filename: consumer.js
//// /*5*/
goTo.marker('1');
verify.completionListContains('x');
verify.not.completionListContains('y');
verify.completionListContains('a');
verify.completionListContains('b');
goTo.marker('2');
verify.not.completionListContains('x');
verify.completionListContains('y');
verify.completionListContains('a');
verify.completionListContains('b');
goTo.marker('3');
verify.not.completionListContains('x');
verify.not.completionListContains('y');
verify.completionListContains('a');
verify.completionListContains('b');
goTo.marker('4');
verify.not.completionListContains('x');
verify.not.completionListContains('y');
verify.completionListContains('a');
verify.completionListContains('b');
goTo.marker('5');
verify.not.completionListContains('x');
verify.not.completionListContains('y');
verify.completionListContains('a');
verify.completionListContains('b');
verify.completions(
{ at: "1", includes: ["x", "a", "b"], excludes: "y" },
{ at: "2", includes: ["y", "a", "b"], excludes: "x" },
{ at: ["3", "4", "5"], includes: ["a", "b"], excludes: ["x", "y"] },
);

View file

@ -10,7 +10,7 @@
//// }
//// myCtor.prototype.foo = function() { return 32 };
//// myCtor.prototype.bar = function() { return '' };
////
////
//// var m = new myCtor(10);
//// m/*1*/
//// var x = m.qua;
@ -20,17 +20,15 @@
// Verify the instance property exists
goTo.marker('1');
edit.insert('.');
verify.completionListContains('qua', undefined, undefined, 'property');
verify.completions({ includes: { name: "qua", kind: "property" } });
edit.backspace();
// Verify the type of the instance property
goTo.marker('2');
edit.insert('.');
verify.completionListContains('toFixed', undefined, undefined, 'method');
verify.completions({ includes: { name: "toFixed", kind: "method" } });
goTo.marker('3');
edit.insert('.');
// Make sure symbols don't leak out into the constructor
verify.completionListContains('qua', undefined, undefined, 'warning');
verify.completionListContains('foo', undefined, undefined, 'warning');
verify.completionListContains('bar', undefined, undefined, 'warning');
verify.completions({ includes: ["qua", "foo", "bar"].map(name => ({ name, kind: "warning" })) });

View file

@ -13,22 +13,8 @@
//// v./*V*/; // IFoo
////}
goTo.marker("S");
verify.completionListIsEmpty();
goTo.marker("T");
verify.completionListContains("x", "(property) IFoo.x: number");
verify.completionListContains("y", "(property) IFoo.y: string");
verify.completionListCount(2);
goTo.marker("U");
verify.completionListContains("toString", "(method) Object.toString(): string");
verify.completionListCount(7); // constructor, toString, toLocaleString, valueOf, hasOwnProperty, isPrototypeOf, propertyIsEnumerable
goTo.marker("V");
verify.completionListContains("x", "(property) IFoo.x: number");
verify.completionListContains("y", "(property) IFoo.y: string");
verify.completionListCount(2);
verify.completions(
{ at: "S", are: undefined },
{ at: ["T", "V"], are: [{ name: "x", text: "(property) IFoo.x: number" }, { name: "y", text: "(property) IFoo.y: string" }]},
{ at: "U", are: ["constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable"] },
);

View file

@ -24,18 +24,9 @@
//// };
////}
// Literal member completion inside empty literal.
goTo.marker("1");
verify.completionListContains("x1", "(property) MyPoint.x1: number");
verify.completionListContains("y1", "(property) MyPoint.y1: number");
// Literal member completion for 2nd member name.
goTo.marker("2");
verify.completionListContains("y1", "(property) MyPoint.y1: number");
// Literal member completion at existing member name location.
goTo.marker("3");
verify.completionListContains("y1", "(property) MyPoint.y1: number");
goTo.marker("4");
verify.completionListContains("x1", "(property) MyPoint.x1: number");
const x1 = { name: "x1", text: "(property) MyPoint.x1: number" };
const y1 = { name: "y1", text: "(property) MyPoint.y1: number" };
verify.completions(
{ at: ["1", "3", "4"], are: [x1, y1] }, // Literal member completion inside empty literal or at existing member name location
{ at: ["2"], are: y1 }, // Literal member completion for 2nd member name
);

View file

@ -10,26 +10,18 @@
//// /// <reference path="./f/*2*/
// @Filename: f1.ts
//// /*f1*/
////
// @Filename: f1.js
//// /*f1j*/
////
// @Filename: f1.d.ts
//// /*f1d*/
////
// @Filename: f1.tsx
//// /f2*/
////
// @Filename: f1.js
//// /*f3*/
////
// @Filename: f1.jsx
//// /*f4*/
////
// @Filename: f1.cs
//// /*f5*/
////
for (let i = 0; i < 3; i++) {
goTo.marker("" + i);
verify.completionListContains("f1.ts");
verify.completionListContains("f1.d.ts");
verify.completionListContains("f1.tsx");
verify.completionListContains("f1.js");
verify.completionListContains("f1.jsx");
verify.not.completionListItemsCountIsGreaterThan(5);
}
verify.completions({ at: test.markerNames(), are: ["f1.d.ts", "f1.js", "f1.jsx", "f1.ts", "f1.tsx"], isNewIdentifierLocation: true });

View file

@ -22,23 +22,7 @@
//// var x3 = <Exp.Thing /*3*/ ></Exp.Thing>;
//// var x4 = <Exp.M.SFCComp /*4*/ ></Exp.M.SFCComp>;
goTo.marker("1");
verify.completionListCount(2);
verify.completionListContains('ONE');
verify.completionListContains('TWO');
goTo.marker("2");
verify.completionListCount(2);
verify.completionListContains("Three");
verify.completionListContains("Four");
goTo.marker("3");
verify.completionListCount(2);
verify.completionListContains('ONE');
verify.completionListContains('TWO');
goTo.marker("4");
verify.completionListCount(2);
verify.completionListContains("Three");
verify.completionListContains("Four");
verify.completions(
{ at: ["1", "3"], are: ["ONE", "TWO"] },
{ at: ["2", "4"], are: ["Three", "Four"] },
);

View file

@ -9,11 +9,4 @@
//// }
//// var x = <div /*1*/ autoComplete /*2*/ />;
goTo.marker('1');
verify.completionListContains("ONE");
verify.not.completionListAllowsNewIdentifier();
goTo.marker('2');
verify.completionListContains("ONE");
verify.not.completionListAllowsNewIdentifier();
verify.completions({ at: ["1", "2"], are: ["ONE", "TWO"] });

View file

@ -5,6 +5,7 @@
////[].map<numb/*b*/;
////1 < Infini/*c*/;
verify.completions({ at: "a", includes: "number", excludes: "SVGNumber" })
for (const marker of ["a", "b"]) {
goTo.marker(marker);
verify.completionListContains("number");

View file

@ -11,10 +11,4 @@
//// <h1> Hello world </ /*2*/>
//// </ /*1*/>
goTo.marker("1");
verify.completionListCount(1);
verify.completionListContains('div');
goTo.marker("2");
verify.completionListCount(1);
verify.completionListContains('h1')
verify.completions({ at: "1", are: ["div"] }, { at: "2", are: ["h1"] });

View file

@ -5,10 +5,4 @@
//// <h1> Hello world </ /*2*/>
//// </ /*1*/>
goTo.marker("1");
verify.completionListCount(1);
verify.completionListContains('div');
goTo.marker("2");
verify.completionListCount(1);
verify.completionListContains('h1')
verify.completions({ at: "1", are: ["div"] }, { at: "2", are: ["h1"] });