From feb1c62db9915ac774c486b28372f91b0e6540e6 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 10 Apr 2018 16:01:39 -0700 Subject: [PATCH] Improve completions testing --- src/harness/fourslash.ts | 198 +++++++++++++----- tests/cases/fourslash/augmentedTypesClass1.ts | 6 +- .../cases/fourslash/augmentedTypesModule6.ts | 14 +- tests/cases/fourslash/cloduleAsBaseClass2.ts | 16 +- tests/cases/fourslash/cloduleTypeOf1.ts | 10 +- tests/cases/fourslash/commentsEnums.ts | 19 +- .../fourslash/commentsImportDeclaration.ts | 25 ++- tests/cases/fourslash/commentsVariables.ts | 47 +++-- ...tionForStringLiteralNonrelativeImport10.ts | 14 +- ...tionForStringLiteralNonrelativeImport11.ts | 26 ++- ...tionForStringLiteralNonrelativeImport12.ts | 16 +- ...etionForStringLiteralNonrelativeImport4.ts | 21 +- ...etionForStringLiteralNonrelativeImport5.ts | 32 ++- ...etionForStringLiteralNonrelativeImport7.ts | 18 +- ...etionForStringLiteralNonrelativeImport8.ts | 7 +- ...etionForStringLiteralNonrelativeImport9.ts | 10 +- ...mpletionForStringLiteralRelativeImport3.ts | 29 +-- ...mpletionForStringLiteralRelativeImport4.ts | 32 ++- .../completionListInUnclosedFunction01.ts | 7 +- .../completionListInUnclosedFunction02.ts | 13 +- .../completionListInUnclosedFunction03.ts | 13 +- .../completionListInUnclosedFunction04.ts | 13 +- .../completionListInUnclosedFunction05.ts | 13 +- .../completionListInUnclosedFunction06.ts | 13 +- .../completionListInUnclosedFunction07.ts | 13 +- .../completionListInUnclosedFunction08.ts | 15 +- .../completionListInUnclosedFunction09.ts | 15 +- .../completionListInUnclosedFunction10.ts | 4 +- .../completionListInUnclosedFunction11.ts | 4 +- .../completionListInUnclosedFunction12.ts | 4 +- .../completionListInUnclosedFunction13.ts | 4 +- .../completionListInUnclosedFunction14.ts | 15 +- .../completionListInUnclosedFunction15.ts | 15 +- .../completionListInUnclosedFunction16.ts | 15 +- .../completionListInUnclosedFunction17.ts | 15 +- .../completionListInUnclosedFunction18.ts | 15 +- .../completionListInUnclosedFunction19.ts | 15 +- ...nUnclosedObjectTypeLiteralInSignature02.ts | 14 +- .../fourslash/completionListPrimitives.ts | 11 +- .../completionListProtectedMembers.ts | 31 +-- .../completionListStaticProtectedMembers.ts | 45 ++-- .../fourslash/completionListSuperMembers.ts | 23 +- .../completionListWithAmbientDeclaration.ts | 10 +- ...letionListsThroughTransitiveBaseClasses.ts | 24 +-- ...etionListsThroughTransitiveBaseClasses2.ts | 22 +- ...completionsImport_compilerOptionsModule.ts | 20 +- .../completionsImport_default_anonymous.ts | 13 +- .../fourslash/completionsImport_matching.ts | 16 +- ...mpletionsImport_named_didNotExistBefore.ts | 14 +- ...tionsImport_notFromUnrelatedNodeModules.ts | 3 +- .../fourslash/completionsImport_ofAlias.ts | 12 +- ...mpletionsImport_ofAlias_preferShortPath.ts | 11 +- .../completionsImport_shadowedByLocal.ts | 10 +- .../cases/fourslash/completionsPaths_kinds.ts | 13 +- .../fourslash/completionsTriggerCharacter.ts | 26 ++- .../distinctTypesInCallbacksWithSameNames.ts | 34 ++- tests/cases/fourslash/fourslash.ts | 44 +++- tests/cases/fourslash/functionTypes.ts | 13 +- .../fourslash/getJavaScriptCompletions12.ts | 16 +- .../fourslash/getJavaScriptCompletions13.ts | 15 +- tests/cases/fourslash/javaScriptClass1.ts | 8 +- tests/cases/fourslash/javaScriptModules12.ts | 36 +--- tests/cases/fourslash/javaScriptPrototype2.ts | 10 +- .../memberCompletionOnTypeParameters.ts | 24 +-- .../memberListInsideObjectLiterals.ts | 21 +- ...hRefPathCompletionExtensionsAllowJSTrue.ts | 24 +-- tests/cases/fourslash/tsxCompletion14.ts | 24 +-- tests/cases/fourslash/tsxCompletion8.ts | 9 +- .../fourslash/tsxCompletionNonTagLessThan.ts | 1 + .../fourslash/tsxCompletionOnClosingTag2.ts | 8 +- .../tsxCompletionOnClosingTagWithoutJSX2.ts | 8 +- 71 files changed, 538 insertions(+), 836 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 643a39e5e683b..a29a25af19bd3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -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) @@ -617,11 +619,11 @@ namespace FourSlash { } } - public verifyGoToDefinitionIs(endMarker: string | string[]) { + public verifyGoToDefinitionIs(endMarker: Many) { this.verifyGoToXWorker(toArray(endMarker), () => this.getGoToDefinition()); } - public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) { + public verifyGoToDefinition(arg0: any, endMarkerNames?: Many) { this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan()); } @@ -633,23 +635,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) { 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 | 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, Many]>; for (const [start, end] of pairs) { this.verifyGoToXPlain(start, end, getDefs); } } else { - const obj: { [startMarkerName: string]: string | string[] } = arg0; + const obj: { [startMarkerName: string]: Many } = arg0; for (const startMarkerName in obj) { if (ts.hasProperty(obj, startMarkerName)) { this.verifyGoToXPlain(startMarkerName, obj[startMarkerName], getDefs); @@ -658,7 +660,7 @@ namespace FourSlash { } } - private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { + private verifyGoToXPlain(startMarkerNames: Many, endMarkerNames: Many, getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { for (const start of toArray(startMarkerNames)) { this.verifyGoToXSingle(start, endMarkerNames, getDefs); } @@ -670,17 +672,17 @@ namespace FourSlash { } } - private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { + private verifyGoToXSingle(startMarkerName: string, endMarkerNames: Many, getDefs: () => ReadonlyArray | 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, getDefs: () => ReadonlyArray | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) { const defs = getDefs(); - let definitions: ts.DefinitionInfo[] | ReadonlyArray; + let definitions: ReadonlyArray; let testName: string; - if (!defs || Array.isArray(defs)) { + if (!defs || ts.isArray(defs)) { definitions = defs as ts.DefinitionInfo[] || []; testName = "goToDefinitions"; } @@ -832,48 +834,121 @@ namespace FourSlash { } } - public verifyCompletionsAt(markerName: string | ReadonlyArray, expected: ReadonlyArray, 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(); + 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, expected: ReadonlyArray) { 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, expected: ReadonlyArray, 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) { @@ -1107,7 +1182,7 @@ namespace FourSlash { } } - public verifyReferenceGroups(starts: string | string[] | Range | Range[], parts: FourSlashInterface.ReferenceGroup[] | undefined): void { + public verifyReferenceGroups(starts: Many | Many, parts: ReadonlyArray | undefined): void { interface ReferenceGroupJson { definition: string | { text: string, range: ts.TextSpan }; references: ts.ReferenceEntry[]; @@ -1245,7 +1320,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); } @@ -1342,7 +1417,7 @@ Actual: ${stringify(fullActual)}`); } } - public verifyRenameLocations(startRanges: Range | Range[], options: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: Range[] }) { + public verifyRenameLocations(startRanges: Many, options: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: Range[] }) { let findInStrings: boolean, findInComments: boolean, ranges: Range[]; if (ts.isArray(options)) { findInStrings = findInComments = false; @@ -3739,7 +3814,7 @@ ${code} return ts.arrayFrom(set.keys()); } - function toArray(x: T | T[]): T[] { + function toArray(x: Many): ReadonlyArray { return ts.isArray(x) ? x : [x]; } @@ -4027,10 +4102,16 @@ namespace FourSlashInterface { super(state); } - public completionsAt(markerName: string | ReadonlyArray, completions: ReadonlyArray, options?: CompletionsAtOptions) { + public completionsAt(markerName: Many, completions: ReadonlyArray, 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); } @@ -4076,19 +4157,19 @@ namespace FourSlashInterface { this.state.verifyCurrentFileContent(text); } - public goToDefinitionIs(endMarkers: string | string[]) { + public goToDefinitionIs(endMarkers: Many) { 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, endMarkerName: Many, range?: FourSlash.Range): void; + public goToDefinition(startsAndEnds: [Many, Many][] | { [startMarkerName: string]: Many }): void; + public goToDefinition(arg0: any, endMarkerName?: Many) { 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, endMarkerName: Many): void; + public goToType(startsAndEnds: [Many, Many][] | { [startMarkerName: string]: Many }): void; + public goToType(arg0: any, endMarkerName?: Many) { this.state.verifyGoToType(arg0, endMarkerName); } @@ -4120,7 +4201,7 @@ namespace FourSlashInterface { this.state.verifyReferencesOf(start, references); } - public referenceGroups(starts: string | string[] | FourSlash.Range | FourSlash.Range[], parts: ReferenceGroup[]) { + public referenceGroups(starts: Many | Many, parts: ReferenceGroup[]) { this.state.verifyReferenceGroups(starts, parts); } @@ -4352,7 +4433,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, options: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: FourSlash.Range[] }) { this.state.verifyRenameLocations(startRanges, options); } @@ -4665,12 +4746,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 { triggerCharacter?: string; isNewIdentifierLocation?: boolean; } + export interface VerifyCompletionsOptions { + readonly at?: Many; + readonly isNewIdentifierLocation?: boolean; + readonly are?: Many; + readonly includes?: Many; + readonly excludes?: Many; + readonly preferences: ts.UserPreferences; + readonly triggerCharacter?: string; + } + + export type Many = T | ReadonlyArray; + export interface VerifyCompletionListContainsOptions extends ts.UserPreferences { triggerCharacter?: string; sourceDisplay: string; diff --git a/tests/cases/fourslash/augmentedTypesClass1.ts b/tests/cases/fourslash/augmentedTypesClass1.ts index 54c0d75dd293f..3aae8acc63f2a 100644 --- a/tests/cases/fourslash/augmentedTypesClass1.ts +++ b/tests/cases/fourslash/augmentedTypesClass1.ts @@ -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'); \ No newline at end of file +verify.completions({ at: "2", includes: { name: "foo", text: '(method) c5b.foo(): void' } }); diff --git a/tests/cases/fourslash/augmentedTypesModule6.ts b/tests/cases/fourslash/augmentedTypesModule6.ts index 4412e930e70b1..de127c87f12d6 100644 --- a/tests/cases/fourslash/augmentedTypesModule6.ts +++ b/tests/cases/fourslash/augmentedTypesModule6.ts @@ -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'); - diff --git a/tests/cases/fourslash/cloduleAsBaseClass2.ts b/tests/cases/fourslash/cloduleAsBaseClass2.ts index d81c4a8c11bba..bb09370443edb 100644 --- a/tests/cases/fourslash/cloduleAsBaseClass2.ts +++ b/tests/cases/fourslash/cloduleAsBaseClass2.ts @@ -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(); diff --git a/tests/cases/fourslash/cloduleTypeOf1.ts b/tests/cases/fourslash/cloduleTypeOf1.ts index 189a0664ef338..6ef1e9ed816fb 100644 --- a/tests/cases/fourslash/cloduleTypeOf1.ts +++ b/tests/cases/fourslash/cloduleTypeOf1.ts @@ -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"); -goTo.marker('4'); -verify.completionListContains('x'); +verify.completions({ at: "4", includes: "x" }); edit.insert('x;'); verify.quickInfoAt("5", "(local var) r2: number"); diff --git a/tests/cases/fourslash/commentsEnums.ts b/tests/cases/fourslash/commentsEnums.ts index bf0bc087372c1..504c804febb96 100644 --- a/tests/cases/fourslash/commentsEnums.ts +++ b/tests/cases/fourslash/commentsEnums.ts @@ -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'"); \ No newline at end of file diff --git a/tests/cases/fourslash/commentsImportDeclaration.ts b/tests/cases/fourslash/commentsImportDeclaration.ts index cda983a9e5a87..cce59ac5f4b1a 100644 --- a/tests/cases/fourslash/commentsImportDeclaration.ts +++ b/tests/cases/fourslash/commentsImportDeclaration.ts @@ -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" }, + ], +}); diff --git a/tests/cases/fourslash/commentsVariables.ts b/tests/cases/fourslash/commentsVariables.ts index bf7e13ee51c81..3a3b2a28adc11 100644 --- a/tests/cases/fourslash/commentsVariables.ts +++ b/tests/cases/fourslash/commentsVariables.ts @@ -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"], diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts index 24a323bc6e52f..19053881d37f0 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts @@ -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(); -} \ No newline at end of file +verify.completions({ at: test.markerNames(), are: [], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts index 7b81c4da106d9..9cb8827872c9d 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts @@ -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, + }, +) diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts index ed202d68ec1d0..1d39c1daf598f 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts @@ -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, +}); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index b95fd96f38043..e3451bb372f7c 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -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); -} \ No newline at end of file +verify.completions({ + at: test.markerNames(), + are: ["fake-module3", "fake-module2", "fake-module"], + isNewIdentifierLocation: true, +}); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts index c8c9a18ff85c1..ad19a2b3714cf 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts @@ -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, +}); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts index 57ba6e440cf9d..2783ca9cca83e 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts @@ -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, +}); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts index 9a0b34ab7fbac..24557535699d2 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts @@ -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, +}); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts index 8703c608462dc..b6660a7974c91 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts @@ -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 }); diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts index 915cebdf6e7e2..84e2ab85e2304 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -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); -} \ No newline at end of file +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, + }); diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index b9750de9c1794..dbaba4ae0ffcb 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -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); -} \ No newline at end of file +verify.completions({ + at: test.markerNames(), + are: ["module1", "module2", "more", "module0"], + isNewIdentifierLocation: true, +}); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction01.ts b/tests/cases/fourslash/completionListInUnclosedFunction01.ts index d87be2247ea61..e4dab0bb92a7f 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction01.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction01.ts @@ -4,9 +4,4 @@ //// /*1*/ //// -goTo.marker("1"); - -verify.completionListContains("foo"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListContains("z"); \ No newline at end of file +verify.completions({ at: "1", includes: ["foo", "x", "y", "z"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction02.ts b/tests/cases/fourslash/completionListInUnclosedFunction02.ts index 329c96090b7d7..9b9409bf90a71 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction02.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction02.ts @@ -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 \ No newline at end of file +// 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"]}) diff --git a/tests/cases/fourslash/completionListInUnclosedFunction03.ts b/tests/cases/fourslash/completionListInUnclosedFunction03.ts index 2d990a3a8d211..165b98a21ec60 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction03.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction03.ts @@ -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 \ No newline at end of file +// 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"]}) diff --git a/tests/cases/fourslash/completionListInUnclosedFunction04.ts b/tests/cases/fourslash/completionListInUnclosedFunction04.ts index f1839e07b4379..cfc880c060b1d 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction04.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction04.ts @@ -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 \ No newline at end of file +// 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"]}) diff --git a/tests/cases/fourslash/completionListInUnclosedFunction05.ts b/tests/cases/fourslash/completionListInUnclosedFunction05.ts index 388c76cbe3c16..b7c3a99a395c1 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction05.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction05.ts @@ -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 \ No newline at end of file +// 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"]}) diff --git a/tests/cases/fourslash/completionListInUnclosedFunction06.ts b/tests/cases/fourslash/completionListInUnclosedFunction06.ts index a82ac3d6805b8..a588048cbbcaf 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction06.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction06.ts @@ -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 \ No newline at end of file +// 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"]}) diff --git a/tests/cases/fourslash/completionListInUnclosedFunction07.ts b/tests/cases/fourslash/completionListInUnclosedFunction07.ts index 5583bdbd4e25c..1a100d82a2c98 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction07.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction07.ts @@ -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 \ No newline at end of file +// 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"]}) diff --git a/tests/cases/fourslash/completionListInUnclosedFunction08.ts b/tests/cases/fourslash/completionListInUnclosedFunction08.ts index 2fe88347ace39..668063e9246bc 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction08.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction08.ts @@ -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 \ No newline at end of file +// 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 }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction09.ts b/tests/cases/fourslash/completionListInUnclosedFunction09.ts index 6193e1e9694f2..24d34cc0e2a20 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction09.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction09.ts @@ -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 \ No newline at end of file +// 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 }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction10.ts b/tests/cases/fourslash/completionListInUnclosedFunction10.ts index 2bef433312bfe..3123d4f2ce0a9 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction10.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction10.ts @@ -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"); \ No newline at end of file +verify.completions({ at: "1", includes: "MyType" }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction11.ts b/tests/cases/fourslash/completionListInUnclosedFunction11.ts index 2bef433312bfe..3123d4f2ce0a9 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction11.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction11.ts @@ -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"); \ No newline at end of file +verify.completions({ at: "1", includes: "MyType" }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction12.ts b/tests/cases/fourslash/completionListInUnclosedFunction12.ts index 5d5f002b8b31d..b1f65c72b1b86 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction12.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction12.ts @@ -8,6 +8,4 @@ //// var v = (p: /*1*/ ////} -goTo.marker("1"); - -verify.completionListContains("MyType"); \ No newline at end of file +verify.completions({ at: "1", includes: "MyType" }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction13.ts b/tests/cases/fourslash/completionListInUnclosedFunction13.ts index cb5c07fd0fb4c..5ffb0a7f28f50 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction13.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction13.ts @@ -9,6 +9,4 @@ //// } ////} -goTo.marker("1"); - -verify.completionListContains("MyType"); \ No newline at end of file +verify.completions({ at: "1", includes: "MyType" }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction14.ts b/tests/cases/fourslash/completionListInUnclosedFunction14.ts index 1a4c9072457f1..4d905e8b2be00 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction14.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction14.ts @@ -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"); \ No newline at end of file +verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction15.ts b/tests/cases/fourslash/completionListInUnclosedFunction15.ts index 5f349c8e2a331..84679bca3b3d3 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction15.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction15.ts @@ -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"); \ No newline at end of file +verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction16.ts b/tests/cases/fourslash/completionListInUnclosedFunction16.ts index bb8c42cf6aca2..bce5a2224ac3b 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction16.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction16.ts @@ -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"); \ No newline at end of file +verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction17.ts b/tests/cases/fourslash/completionListInUnclosedFunction17.ts index 5a639e3031802..6c383405434ef 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction17.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction17.ts @@ -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"); \ No newline at end of file +verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction18.ts b/tests/cases/fourslash/completionListInUnclosedFunction18.ts index 70ff5caf67a6e..a8769c5848b04 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction18.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction18.ts @@ -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"); \ No newline at end of file +verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedFunction19.ts b/tests/cases/fourslash/completionListInUnclosedFunction19.ts index 8c6030b44db76..b24d9706c36e6 100644 --- a/tests/cases/fourslash/completionListInUnclosedFunction19.ts +++ b/tests/cases/fourslash/completionListInUnclosedFunction19.ts @@ -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"); \ No newline at end of file +verify.completions({ at: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature02.ts b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature02.ts index 5d4fa07082fe4..fbec33e8dce7e 100644 --- a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature02.ts +++ b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature02.ts @@ -7,12 +7,8 @@ //// ////declare function foo(obj: I): { 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. +}) diff --git a/tests/cases/fourslash/completionListPrimitives.ts b/tests/cases/fourslash/completionListPrimitives.ts index 54c518108ded2..7be481f853e6f 100644 --- a/tests/cases/fourslash/completionListPrimitives.ts +++ b/tests/cases/fourslash/completionListPrimitives.ts @@ -1,12 +1,5 @@ /// -/////**/ +//// -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"] }) diff --git a/tests/cases/fourslash/completionListProtectedMembers.ts b/tests/cases/fourslash/completionListProtectedMembers.ts index 20cb990405dff..b83ea4145605a 100644 --- a/tests/cases/fourslash/completionListProtectedMembers.ts +++ b/tests/cases/fourslash/completionListProtectedMembers.ts @@ -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 }, +); diff --git a/tests/cases/fourslash/completionListStaticProtectedMembers.ts b/tests/cases/fourslash/completionListStaticProtectedMembers.ts index ae79387fbe798..261d6ffab1617 100644 --- a/tests/cases/fourslash/completionListStaticProtectedMembers.ts +++ b/tests/cases/fourslash/completionListStaticProtectedMembers.ts @@ -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'); \ No newline at end of file +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"], + }, +); diff --git a/tests/cases/fourslash/completionListSuperMembers.ts b/tests/cases/fourslash/completionListSuperMembers.ts index ae6195601a372..fa625a551b29b 100644 --- a/tests/cases/fourslash/completionListSuperMembers.ts +++ b/tests/cases/fourslash/completionListSuperMembers.ts @@ -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"); \ No newline at end of file +verify.completions({ + at: "", + includes: "publicInstanceMethod", + excludes: [ + "publicProperty", + // No statics + "publicStaticProperty", + "publicStaticMethod", + // No privates + "privateProperty", + "privateInstanceMethod", + ] +}); diff --git a/tests/cases/fourslash/completionListWithAmbientDeclaration.ts b/tests/cases/fourslash/completionListWithAmbientDeclaration.ts index 5839608b099be..4bee0ead05b5b 100644 --- a/tests/cases/fourslash/completionListWithAmbientDeclaration.ts +++ b/tests/cases/fourslash/completionListWithAmbientDeclaration.ts @@ -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"] }, +); diff --git a/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses.ts b/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses.ts index 26c9ca3b0965a..9bf2827e39255 100644 --- a/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses.ts +++ b/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses.ts @@ -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(); \ No newline at end of file +verify.noErrors(); diff --git a/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses2.ts b/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses2.ts index 73aae2e359665..5adade8c2a70b 100644 --- a/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses2.ts +++ b/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses2.ts @@ -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(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionsImport_compilerOptionsModule.ts b/tests/cases/fourslash/completionsImport_compilerOptionsModule.ts index be568bb4212cf..1e40bb1a3c687 100644 --- a/tests/cases/fourslash/completionsImport_compilerOptionsModule.ts +++ b/tests/cases/fourslash/completionsImport_compilerOptionsModule.ts @@ -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 }, +}); diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts index bf8f209f86651..ae1991491028c 100644 --- a/tests/cases/fourslash/completionsImport_default_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -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", diff --git a/tests/cases/fourslash/completionsImport_matching.ts b/tests/cases/fourslash/completionsImport_matching.ts index 444831bd9c788..24debd00c8542 100644 --- a/tests/cases/fourslash/completionsImport_matching.ts +++ b/tests/cases/fourslash/completionsImport_matching.ts @@ -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 }, +}) diff --git a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts index 5eaecd7b5571d..662c03c7c0637 100644 --- a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts @@ -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", diff --git a/tests/cases/fourslash/completionsImport_notFromUnrelatedNodeModules.ts b/tests/cases/fourslash/completionsImport_notFromUnrelatedNodeModules.ts index 72fdd16dc191f..63f4612a89951 100644 --- a/tests/cases/fourslash/completionsImport_notFromUnrelatedNodeModules.ts +++ b/tests/cases/fourslash/completionsImport_notFromUnrelatedNodeModules.ts @@ -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 } }); diff --git a/tests/cases/fourslash/completionsImport_ofAlias.ts b/tests/cases/fourslash/completionsImport_ofAlias.ts index 903f724722e79..3f1fbf756f3e7 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias.ts @@ -19,13 +19,13 @@ // @Filename: /b.ts ////fo/**/ -goTo.marker(""); -const options = { includeExternalModuleExports: true, sourceDisplay: "./a" }; // TODO: https://github.com/Microsoft/TypeScript/issues/14003 -//TODO: verify that there's only one! -verify.completionListContains({ name: "foo", source: "/a" }, "(alias) const foo: 0\nimport 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\nimport foo", kind: "alias", hasAction: true }, + excludes: [{ name: "foo", source: "/a_reexport" }, { name: "foo", source: "/a_reexport_2" }], + preferences: { includeCompletionsForModuleExports: true }, +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts index bc66d48587771..9b432dcaa9174 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts @@ -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", diff --git a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts index 622f21a2fc77f..0747e7177cdc8 100644 --- a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts +++ b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts @@ -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 }, +}) diff --git a/tests/cases/fourslash/completionsPaths_kinds.ts b/tests/cases/fourslash/completionsPaths_kinds.ts index 152c7d1bf5a5d..2f8de6760af14 100644 --- a/tests/cases/fourslash/completionsPaths_kinds.ts +++ b/tests/cases/fourslash/completionsPaths_kinds.ts @@ -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 +}); diff --git a/tests/cases/fourslash/completionsTriggerCharacter.ts b/tests/cases/fourslash/completionsTriggerCharacter.ts index 06e2a123c52be..0d7d9532216f8 100644 --- a/tests/cases/fourslash/completionsTriggerCharacter.ts +++ b/tests/cases/fourslash/completionsTriggerCharacter.ts @@ -19,21 +19,19 @@ ////const ctr = >; ////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;\ -var r3 = _.forEach(c4, (x) => { return x.foo() });\ -"); +edit.insert(`class A { + foo() { } +} +var c4: Collection; +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(); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 42dee74bb03e3..50e36b7ca6655 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -201,7 +201,16 @@ declare namespace FourSlashInterface { class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; caretAtMarker(markerName?: string): void; - completionsAt(markerName: string | ReadonlyArray, completions: ReadonlyArray, options?: CompletionsAtOptions): void; + completions(...options: { + readonly at?: Many, + readonly isNewIdentifierLocation?: boolean; + readonly are?: Many; + readonly includes?: Many; + readonly excludes?: Many; + readonly preferences?: UserPreferences; + readonly triggerCharacter?: string; + }[]): void; + completionsAt(markerName: Many, completions: ReadonlyArray, 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): 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, endMarkerNames: Many): void; + goToDefinition(startMarkerNames: Many, endMarkerNames: Many, range: Range): void; /** Performs `goToDefinition` for each pair. */ - goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void; + goToDefinition(startsAndEnds: [Many, Many][]): void; /** Performs `goToDefinition` on each key and value. */ - goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; + goToDefinition(startsAndEnds: { [startMarkerName: string]: Many }): 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 }): void; + goToType(startMarkerNames: Many, endMarkerNames: Many): 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 | Many, 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, 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 | ReadonlyArray; } declare function verifyOperationIsCancelled(f: any): void; declare var test: FourSlashInterface.test_; diff --git a/tests/cases/fourslash/functionTypes.ts b/tests/cases/fourslash/functionTypes.ts index fdcb924af985b..6ddba777ae0a2 100644 --- a/tests/cases/fourslash/functionTypes.ts +++ b/tests/cases/fourslash/functionTypes.ts @@ -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" ]); diff --git a/tests/cases/fourslash/getJavaScriptCompletions12.ts b/tests/cases/fourslash/getJavaScriptCompletions12.ts index 99b1482885440..b916428e61061 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions12.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions12.ts @@ -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"); \ No newline at end of file +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" } }, +); diff --git a/tests/cases/fourslash/getJavaScriptCompletions13.ts b/tests/cases/fourslash/getJavaScriptCompletions13.ts index 438c73e304c04..0fc308eb2d060 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions13.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions13.ts @@ -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"); \ No newline at end of file +verify.completions( + { at: "1", includes: ["file2Identifier1", "file2Identifier2", "file1Identifier"], excludes: "FooProp" }, + { at: "2", includes: ["file2Identifier1", "file2Identifier2"], excludes: ["file1Identifier", "FooProp"] }, +) diff --git a/tests/cases/fourslash/javaScriptClass1.ts b/tests/cases/fourslash/javaScriptClass1.ts index 28d139405c7ee..d55db67113e97 100644 --- a/tests/cases/fourslash/javaScriptClass1.ts +++ b/tests/cases/fourslash/javaScriptClass1.ts @@ -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 }); \ No newline at end of file +verify.completions({ includes: "toString" }); diff --git a/tests/cases/fourslash/javaScriptModules12.ts b/tests/cases/fourslash/javaScriptModules12.ts index 5ed2431cf9277..d6b6ae627036e 100644 --- a/tests/cases/fourslash/javaScriptModules12.ts +++ b/tests/cases/fourslash/javaScriptModules12.ts @@ -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"] }, +); diff --git a/tests/cases/fourslash/javaScriptPrototype2.ts b/tests/cases/fourslash/javaScriptPrototype2.ts index ab6afff3d2ce7..79169e47b0c8b 100644 --- a/tests/cases/fourslash/javaScriptPrototype2.ts +++ b/tests/cases/fourslash/javaScriptPrototype2.ts @@ -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" })) }); diff --git a/tests/cases/fourslash/memberCompletionOnTypeParameters.ts b/tests/cases/fourslash/memberCompletionOnTypeParameters.ts index cc3fc92a31aab..0a6f9afa8fed0 100644 --- a/tests/cases/fourslash/memberCompletionOnTypeParameters.ts +++ b/tests/cases/fourslash/memberCompletionOnTypeParameters.ts @@ -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"] }, +); diff --git a/tests/cases/fourslash/memberListInsideObjectLiterals.ts b/tests/cases/fourslash/memberListInsideObjectLiterals.ts index 875fb2c7fc991..a91300cbf5f82 100644 --- a/tests/cases/fourslash/memberListInsideObjectLiterals.ts +++ b/tests/cases/fourslash/memberListInsideObjectLiterals.ts @@ -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"); \ No newline at end of file +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 +); diff --git a/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSTrue.ts b/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSTrue.ts index e8fe415824b6e..ad873e9d509d9 100644 --- a/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSTrue.ts +++ b/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSTrue.ts @@ -10,26 +10,18 @@ //// /// ; //// var x4 = ; - -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"] }, +); diff --git a/tests/cases/fourslash/tsxCompletion8.ts b/tests/cases/fourslash/tsxCompletion8.ts index 59ad8385b9d12..5f92ea40fb39d 100644 --- a/tests/cases/fourslash/tsxCompletion8.ts +++ b/tests/cases/fourslash/tsxCompletion8.ts @@ -9,11 +9,4 @@ //// } //// var x =
; - -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"] }); diff --git a/tests/cases/fourslash/tsxCompletionNonTagLessThan.ts b/tests/cases/fourslash/tsxCompletionNonTagLessThan.ts index be71543843776..27e58992f5b9f 100644 --- a/tests/cases/fourslash/tsxCompletionNonTagLessThan.ts +++ b/tests/cases/fourslash/tsxCompletionNonTagLessThan.ts @@ -5,6 +5,7 @@ ////[].map Hello world //// -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"] }); diff --git a/tests/cases/fourslash/tsxCompletionOnClosingTagWithoutJSX2.ts b/tests/cases/fourslash/tsxCompletionOnClosingTagWithoutJSX2.ts index 30f40e5a41d45..66298261160e1 100644 --- a/tests/cases/fourslash/tsxCompletionOnClosingTagWithoutJSX2.ts +++ b/tests/cases/fourslash/tsxCompletionOnClosingTagWithoutJSX2.ts @@ -5,10 +5,4 @@ ////

Hello world //// -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"] });