Merge pull request #13568 from Microsoft/fourslash

Simplify fourslash tests by adding some helpers
This commit is contained in:
Andy 2017-01-18 15:23:45 -08:00 committed by GitHub
commit 2c48e26f19
195 changed files with 482 additions and 1301 deletions

View file

@ -372,8 +372,8 @@ namespace FourSlash {
} }
// Entry points from fourslash.ts // Entry points from fourslash.ts
public goToMarker(name = "") { public goToMarker(name: string | Marker = "") {
const marker = this.getMarkerByName(name); const marker = typeof name === "string" ? this.getMarkerByName(name) : name;
if (this.activeFile.fileName !== marker.fileName) { if (this.activeFile.fileName !== marker.fileName) {
this.openFile(marker.fileName); this.openFile(marker.fileName);
} }
@ -382,10 +382,37 @@ namespace FourSlash {
if (marker.position === -1 || marker.position > content.length) { if (marker.position === -1 || marker.position > content.length) {
throw new Error(`Marker "${name}" has been invalidated by unrecoverable edits to the file.`); throw new Error(`Marker "${name}" has been invalidated by unrecoverable edits to the file.`);
} }
this.lastKnownMarker = name; const mName = typeof name === "string" ? name : this.markerName(marker);
this.lastKnownMarker = mName;
this.goToPosition(marker.position); this.goToPosition(marker.position);
} }
public goToEachMarker(action: () => void) {
const markers = this.getMarkers();
assert(markers.length);
for (const marker of markers) {
this.goToMarker(marker);
action();
}
}
public goToEachRange(action: () => void) {
const ranges = this.getRanges();
assert(ranges.length);
for (const range of ranges) {
this.goToRangeStart(range);
action();
}
}
private markerName(m: Marker): string {
return ts.forEachEntry(this.testData.markerPositions, (marker, name) => {
if (marker === m) {
return name;
}
})!;
}
public goToPosition(pos: number) { public goToPosition(pos: number) {
this.currentCaretPosition = pos; this.currentCaretPosition = pos;
} }
@ -1668,7 +1695,7 @@ namespace FourSlash {
this.goToPosition(len); this.goToPosition(len);
} }
private goToRangeStart({fileName, start}: Range) { public goToRangeStart({fileName, start}: Range) {
this.openFile(fileName); this.openFile(fileName);
this.goToPosition(start); this.goToPosition(start);
} }
@ -2365,6 +2392,21 @@ namespace FourSlash {
return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch); return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch);
} }
public verifyRangesAreOccurrences(isWriteAccess?: boolean) {
const ranges = this.getRanges();
for (const r of ranges) {
this.goToRangeStart(r);
this.verifyOccurrencesAtPositionListCount(ranges.length);
for (const range of ranges) {
this.verifyOccurrencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess);
}
}
}
public verifyRangesAreRenameLocations(findInStrings: boolean, findInComments: boolean) {
this.goToEachRange(() => this.verifyRenameLocations(findInStrings, findInComments));
}
public verifyRangesWithSameTextAreDocumentHighlights() { public verifyRangesWithSameTextAreDocumentHighlights() {
this.rangesByText().forEach(ranges => this.verifyRangesAreDocumentHighlights(ranges)); this.rangesByText().forEach(ranges => this.verifyRangesAreDocumentHighlights(ranges));
} }
@ -3078,10 +3120,22 @@ namespace FourSlashInterface {
// Moves the caret to the specified marker, // Moves the caret to the specified marker,
// or the anonymous marker ('/**/') if no name // or the anonymous marker ('/**/') if no name
// is given // is given
public marker(name?: string) { public marker(name?: string | FourSlash.Marker) {
this.state.goToMarker(name); this.state.goToMarker(name);
} }
public eachMarker(action: () => void) {
this.state.goToEachMarker(action);
}
public rangeStart(range: FourSlash.Range) {
this.state.goToRangeStart(range);
}
public eachRange(action: () => void) {
this.state.goToEachRange(action);
}
public bof() { public bof() {
this.state.goToBOF(); this.state.goToBOF();
} }
@ -3432,6 +3486,14 @@ namespace FourSlashInterface {
this.state.verifyOccurrencesAtPositionListCount(expectedCount); this.state.verifyOccurrencesAtPositionListCount(expectedCount);
} }
public rangesAreOccurrences(isWriteAccess?: boolean) {
this.state.verifyRangesAreOccurrences(isWriteAccess);
}
public rangesAreRenameLocations(findInStrings = false, findInComments = false) {
this.state.verifyRangesAreRenameLocations(findInStrings, findInComments);
}
public rangesAreDocumentHighlights(ranges?: FourSlash.Range[]) { public rangesAreDocumentHighlights(ranges?: FourSlash.Range[]) {
this.state.verifyRangesAreDocumentHighlights(ranges); this.state.verifyRangesAreDocumentHighlights(ranges);
} }

View file

@ -11,8 +11,4 @@
////function A</*genericName5*/ ////function A</*genericName5*/
goTo.eachMarker(() => verify.completionListIsEmpty());
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -6,8 +6,4 @@
//// try {} catch(a/*catchVariable2*/ //// try {} catch(a/*catchVariable2*/
goTo.eachMarker(() => verify.completionListIsEmpty());
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -6,7 +6,4 @@
////class a/*className2*/ ////class a/*className2*/
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -16,7 +16,4 @@
//// function func2({ a, b/*parameter2*/ //// function func2({ a, b/*parameter2*/
test.markers().forEach(m => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -4,8 +4,4 @@
////enum a { /*enumValueName1*/ ////enum a { /*enumValueName1*/
goTo.eachMarker(() => verify.completionListIsEmpty());
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -3,7 +3,4 @@
////var aa = 1; ////var aa = 1;
////enum a { foo, /*enumValueName3*/ ////enum a { foo, /*enumValueName3*/
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -8,7 +8,4 @@
////var x = 0; enum /*enumName4*/ ////var x = 0; enum /*enumName4*/
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -6,8 +6,4 @@
////function a/*functionName2*/ ////function a/*functionName2*/
goTo.eachMarker(() => verify.completionListIsEmpty());
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -4,7 +4,4 @@
////interface a { /*interfaceValue1*/ ////interface a { /*interfaceValue1*/
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -4,7 +4,4 @@
////interface a { f/*interfaceValue2*/ ////interface a { f/*interfaceValue2*/
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -4,7 +4,4 @@
////interface a { f; /*interfaceValue3*/ ////interface a { f; /*interfaceValue3*/
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -6,8 +6,4 @@
////interface a/*interfaceName2*/ ////interface a/*interfaceName2*/
goTo.eachMarker(() => verify.completionListIsEmpty());
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -22,8 +22,4 @@
////class bar10{ constructor(...a/*constructorParamter6*/ ////class bar10{ constructor(...a/*constructorParamter6*/
goTo.eachMarker(() => verify.completionListIsEmpty());
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -30,8 +30,7 @@
//// private a/*property7*/ //// private a/*property7*/
////} ////}
test.markers().forEach((m) => { goTo.eachMarker(() => {
goTo.position(m.position, m.fileName);
verify.not.completionListIsEmpty(); verify.not.completionListIsEmpty();
verify.completionListAllowsNewIdentifier(); verify.completionListAllowsNewIdentifier();
}); });

View file

@ -11,7 +11,4 @@
////var a2, a/*varName4*/ ////var a2, a/*varName4*/
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -25,7 +25,4 @@
////foo; ////foo;
////var v10 = /reg/*inRegExp1*/ex/; ////var v10 = /reg/*inRegExp1*/ex/;
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -26,9 +26,4 @@
////var y = 10; y=/*var12*/ ////var y = 10; y=/*var12*/
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListAllowsNewIdentifier());
goTo.position(m.position, m.fileName);
verify.completionListAllowsNewIdentifier();
});

View file

@ -14,9 +14,7 @@
////class bar7{ constructor(private a, /*constructorParamter6*/ ////class bar7{ constructor(private a, /*constructorParamter6*/
goTo.eachMarker(() => {
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.not.completionListIsEmpty(); verify.not.completionListIsEmpty();
verify.completionListAllowsNewIdentifier(); verify.completionListAllowsNewIdentifier();
}); });

View file

@ -10,7 +10,4 @@
//// public static a/*property2*/ //// public static a/*property2*/
////} ////}
test.markers().forEach((m) => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});

View file

@ -14,7 +14,4 @@
//// [x/*5*/yz: number]: boolean; //// [x/*5*/yz: number]: boolean;
//// [/*6*/ //// [/*6*/
for (let marker of test.markers()) { goTo.eachMarker(() => verify.completionListAllowsNewIdentifier());
goTo.position(marker.position);
verify.completionListAllowsNewIdentifier();
}

View file

@ -13,7 +13,4 @@
////type T = { ////type T = {
//// [xyz: /*5*/ //// [xyz: /*5*/
for (let marker of test.markers()) { goTo.eachMarker(() => verify.not.completionListAllowsNewIdentifier());
goTo.position(marker.position);
verify.not.completionListAllowsNewIdentifier();
}

View file

@ -20,9 +20,7 @@
////funcE({ /*E*/ }); ////funcE({ /*E*/ });
////funcF({ /*F*/ }); ////funcF({ /*F*/ });
goTo.eachMarker(() => {
for (const marker of test.markers()) {
goTo.position(marker.position);
verify.completionListContains("hello"); verify.completionListContains("hello");
verify.completionListContains("world"); verify.completionListContains("world");
} });

View file

@ -3,8 +3,4 @@
////"/*1*/ /*2*/\/*3*/ ////"/*1*/ /*2*/\/*3*/
//// /*4*/ \\/*5*/ //// /*4*/ \\/*5*/
test.markers().forEach(marker => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(marker.position);
verify.completionListIsEmpty()
});

View file

@ -4,8 +4,4 @@
//// /*4*/ \\\/*5*/ //// /*4*/ \\\/*5*/
//// /*6*/ //// /*6*/
test.markers().forEach(marker => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(marker.position);
verify.completionListIsEmpty()
});

View file

@ -4,8 +4,4 @@
//// ////
/////*6*/`asdasd${/*7*/ 2 + 1.1 /*8*/} 12312 { /////*6*/`asdasd${/*7*/ 2 + 1.1 /*8*/} 12312 {
test.markers().forEach(marker => { goTo.eachMarker(() => verify.completionListItemsCountIsGreaterThan(0));
goTo.position(marker.position);
verify.completionListItemsCountIsGreaterThan(0)
});

View file

@ -4,8 +4,4 @@
//// ////
////`asdasd$/*7*/{ 2 + 1.1 }/*8*/ 12312 /*9*/{/*10*/ ////`asdasd$/*7*/{ 2 + 1.1 }/*8*/ 12312 /*9*/{/*10*/
test.markers().forEach(marker => { goTo.eachMarker(() => verify.completionListIsEmpty());
goTo.position(marker.position);
verify.completionListIsEmpty()
});

View file

@ -2,8 +2,7 @@
////function F(pref: (a/*1*/ ////function F(pref: (a/*1*/
test.markers().forEach((m) => { goTo.eachMarker(() => {
goTo.position(m.position, m.fileName);
verify.not.completionListIsEmpty(); verify.not.completionListIsEmpty();
verify.completionListAllowsNewIdentifier(); verify.completionListAllowsNewIdentifier();
}); });

View file

@ -4,8 +4,7 @@
////var y : (s:string, list/*2*/ ////var y : (s:string, list/*2*/
test.markers().forEach((m) => { goTo.eachMarker(() => {
goTo.position(m.position, m.fileName);
verify.not.completionListIsEmpty(); verify.not.completionListIsEmpty();
verify.completionListAllowsNewIdentifier(); verify.completionListAllowsNewIdentifier();
}); });

View file

@ -8,7 +8,4 @@
//// // We also want to check EOF handling at the end of a comment //// // We also want to check EOF handling at the end of a comment
//// // /*2*/ //// // /*2*/
test.markers().forEach((marker) => { goTo.eachMarker(() => verify.noDocCommentTemplate());
goTo.position(marker.position);
verify.noDocCommentTemplate();
});

View file

@ -3,7 +3,4 @@
// @Filename: functionDecl.ts // @Filename: functionDecl.ts
////f/*0*/unction /*1*/foo/*2*/(/*3*/) /*4*/{ /*5*/} ////f/*0*/unction /*1*/foo/*2*/(/*3*/) /*4*/{ /*5*/}
test.markers().forEach((marker) => { goTo.eachMarker(() => verify.noDocCommentTemplate());
goTo.position(marker.position);
verify.noDocCommentTemplate();
});

View file

@ -3,7 +3,4 @@
// @Filename: regex.ts // @Filename: regex.ts
////var regex = /*0*///*1*/asdf/*2*/ /*3*///*4*/; ////var regex = /*0*///*1*/asdf/*2*/ /*3*///*4*/;
test.markers().forEach((marker) => { goTo.eachMarker(() => verify.noDocCommentTemplate());
goTo.position(marker.position);
verify.noDocCommentTemplate();
});

View file

@ -117,7 +117,10 @@ declare namespace FourSlashInterface {
markerByName(s: string): Marker; markerByName(s: string): Marker;
} }
class goTo { class goTo {
marker(name?: string): void; marker(name?: string | Marker): void;
eachMarker(action: () => void): void;
rangeStart(range: Range): void;
eachRange(action: () => void): void;
bof(): void; bof(): void;
eof(): void; eof(): void;
implementation(): void; implementation(): void;
@ -191,6 +194,8 @@ declare namespace FourSlashInterface {
* `start` should be included in `references`. * `start` should be included in `references`.
*/ */
referencesOf(start: Range, references: Range[]): void; referencesOf(start: Range, references: Range[]): void;
rangesAreOccurrences(isWriteAccess?: boolean): void;
rangesAreRenameLocations(findInStrings?: boolean, findInComments?: boolean): void;
/** /**
* Performs `referencesOf` for every range on the whole set. * Performs `referencesOf` for every range on the whole set.
* If `ranges` is omitted, this is `test.ranges()`. * If `ranges` is omitted, this is `test.ranges()`.

View file

@ -12,13 +12,4 @@
//// abstract bar(): void; //// abstract bar(): void;
////} ////}
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
verify.occurrencesAtPositionCount(ranges.length);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View file

@ -11,16 +11,7 @@
//// abstract bar(): void; //// abstract bar(): void;
////} ////}
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
verify.occurrencesAtPositionCount(ranges.length);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}
goTo.marker("1"); goTo.marker("1");
verify.occurrencesAtPositionCount(0); verify.occurrencesAtPositionCount(0);

View file

@ -13,11 +13,4 @@
//// } //// }
////} ////}
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View file

@ -17,11 +17,4 @@
//// public test2() {} //// public test2() {}
////} ////}
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View file

@ -17,11 +17,4 @@
//// public test2() {} //// public test2() {}
////} ////}
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View file

@ -1,7 +1,7 @@
/// <reference path='fourslash.ts' /> /// <reference path='fourslash.ts' />
////let A = class Foo { ////let A = class Foo {
//// public static foo; //// public [|static|] foo;
//// [|static|] a; //// [|static|] a;
//// constructor(public y: string, private x: string) { //// constructor(public y: string, private x: string) {
//// } //// }
@ -19,11 +19,4 @@
//// public static test2() {} //// public static test2() {}
////} ////}
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View file

@ -46,11 +46,4 @@
//// } //// }
////} ////}
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View file

@ -44,11 +44,4 @@
//// } //// }
////} ////}
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View file

@ -10,7 +10,4 @@
////declare [|const|] enum E { ////declare [|const|] enum E {
////} ////}
test.ranges().forEach(range => { goTo.eachRange(() => verify.occurrencesAtPositionCount(0));
goTo.position(range.start);
verify.occurrencesAtPositionCount(0);
});

View file

@ -10,7 +10,4 @@
////export [|const|] enum E { ////export [|const|] enum E {
////} ////}
test.ranges().forEach(range => { goTo.eachRange(() => verify.occurrencesAtPositionCount(0));
goTo.position(range.start);
verify.occurrencesAtPositionCount(0);
});

View file

@ -18,15 +18,9 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -18,15 +18,9 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -53,11 +53,4 @@
//// [|declare|] function foo(): string; //// [|declare|] function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -61,11 +61,4 @@
////[|declare|] module dm { } ////[|declare|] module dm { }
////export class EC { } ////export class EC { }
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -53,11 +53,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -61,11 +61,4 @@
////declare module dm { } ////declare module dm { }
////[|export|] class EC { } ////[|export|] class EC { }
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -22,15 +22,9 @@
////} ////}
////[|else|] { } ////[|else|] { }
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -22,11 +22,4 @@
////} ////}
////else { } ////else { }
verify.rangesAreOccurrences(false);
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -22,11 +22,4 @@
////} ////}
////else { } ////else { }
verify.rangesAreOccurrences(false);
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -12,13 +12,7 @@
// It would be nice if in the future, // It would be nice if in the future,
// We could include that last 'else'. // We could include that last 'else'.
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
verify.occurrencesAtPositionCount(2); verify.occurrencesAtPositionCount(2);

View file

@ -18,10 +18,8 @@
////[|{| "isWriteAccess": true |}x|] += 1; ////[|{| "isWriteAccess": true |}x|] += 1;
////[|{| "isWriteAccess": true |}x|] <<= 1; ////[|{| "isWriteAccess": true |}x|] <<= 1;
goTo.rangeStart(test.ranges()[0]);
var firstRange = test.ranges()[0]; for (const range of test.ranges()) {
goTo.position(firstRange.start, firstRange.fileName);
test.ranges().forEach((range) => {
verify.occurrencesAtPositionContains(range, range.marker.data.isWriteAccess); verify.occurrencesAtPositionContains(range, range.marker.data.isWriteAccess);
}); }

View file

@ -63,17 +63,10 @@
//// ////
////label7: while (true) continue label5; ////label7: while (true) continue label5;
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
verify.occurrencesAtPositionCount(test.ranges().length); verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -63,17 +63,10 @@
//// ////
////label7: while (true) continue label5; ////label7: while (true) continue label5;
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
verify.occurrencesAtPositionCount(test.ranges().length); verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -63,16 +63,9 @@
//// ////
////label7: while (true) continue label5; ////label7: while (true) continue label5;
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -63,17 +63,10 @@
//// ////
////label7: while (true) continue label5; ////label7: while (true) continue label5;
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
verify.occurrencesAtPositionCount(test.ranges().length); verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -63,17 +63,10 @@
//// ////
////label7: while (true) continue label5; ////label7: while (true) continue label5;
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
verify.occurrencesAtPositionCount(test.ranges().length); verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -63,8 +63,4 @@
//// ////
////label7: while (true) co/*10*/ntinue label5; ////label7: while (true) co/*10*/ntinue label5;
test.markers().forEach(m => { goTo.eachMarker(() => verify.occurrencesAtPositionCount(0));
goTo.position(m.position);
verify.occurrencesAtPositionCount(0);
});

View file

@ -63,8 +63,4 @@
//// ////
////label7: while (true) co/*10*/ntinue label5; ////label7: while (true) co/*10*/ntinue label5;
test.markers().forEach(m => { goTo.eachMarker(() => verify.occurrencesAtPositionCount(0));
goTo.position(m.position);
verify.occurrencesAtPositionCount(0);
});

View file

@ -34,8 +34,4 @@
////[|public|] [|static|] [|protected|] [|private|] f; ////[|public|] [|static|] [|protected|] [|private|] f;
////[|protected|] [|static|] [|public|] g; ////[|protected|] [|static|] [|public|] g;
goTo.eachRange(() => verify.occurrencesAtPositionCount(0));
test.ranges().forEach(r => {
goTo.position(r.start);
verify.occurrencesAtPositionCount(0);
});

View file

@ -5,12 +5,4 @@
//// return 0; //// return 0;
////}) ////})
verify.rangesAreOccurrences();
test.ranges().forEach(r => {
goTo.position(r.start);
verify.occurrencesAtPositionCount(2);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range);
});
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -15,11 +15,5 @@
////} ////}
//// ////
////(new C()).[|abc|]; ////(new C()).[|abc|];
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => { verify.rangesAreOccurrences();
verify.occurrencesAtPositionContains(range);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -19,15 +19,9 @@
//// [|return|] true; //// [|return|] true;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -19,15 +19,9 @@
//// return true; //// return true;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -19,10 +19,4 @@
//// return true; //// return true;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -30,13 +30,7 @@
// where if an arrow function starts with a statement, we try to parse a body // where if an arrow function starts with a statement, we try to parse a body
// as if it was missing curly braces. If the behavior changes in the future, // as if it was missing curly braces. If the behavior changes in the future,
// a change to this test is very much welcome. // a change to this test is very much welcome.
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
for (var i = 1; i <= test.markers().length; i++) { for (var i = 1; i <= test.markers().length; i++) {
goTo.marker("" + i); goTo.marker("" + i);

View file

@ -23,12 +23,4 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});

View file

@ -23,12 +23,4 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});

View file

@ -23,12 +23,4 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});

View file

@ -54,11 +54,4 @@
//// declare function foo(): string; //// declare function foo(): string;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -3,11 +3,4 @@
////function foo(a: "[|option 1|]") { } ////function foo(a: "[|option 1|]") { }
////foo("[|option 1|]"); ////foo("[|option 1|]");
const ranges = test.ranges(); verify.rangesAreOccurrences(false);
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View file

@ -3,8 +3,4 @@
////var x = "[|string|]"; ////var x = "[|string|]";
////function f(a = "[|initial value|]") { } ////function f(a = "[|initial value|]") { }
const ranges = test.ranges(); goTo.eachRange(() => verify.occurrencesAtPositionCount(1));
for (let r of ranges) {
goTo.position(r.start);
verify.occurrencesAtPositionCount(1);
}

View file

@ -50,15 +50,9 @@
//// static super = 20; //// static super = 20;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -50,15 +50,9 @@
//// static super = 20; //// static super = 20;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -14,7 +14,7 @@
////} ////}
function checkRange(r: FourSlashInterface.Range, expectedOccurences: FourSlashInterface.Range[]): void { function checkRange(r: FourSlashInterface.Range, expectedOccurences: FourSlashInterface.Range[]): void {
goTo.position(r.start); goTo.rangeStart(r);
if (expectedOccurences.length) { if (expectedOccurences.length) {
for (const expected of expectedOccurences) { for (const expected of expectedOccurences) {
verify.occurrencesAtPositionContains(expected); verify.occurrencesAtPositionContains(expected);

View file

@ -20,8 +20,4 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { goTo.eachRange(() => verify.occurrencesAtPositionCount(0));
goTo.position(r.start);
verify.occurrencesAtPositionCount(0);
});

View file

@ -18,12 +18,4 @@
//// [|case|] 16: //// [|case|] 16:
////} ////}
verify.rangesAreOccurrences(false);
test.ranges().forEach(r => {
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -18,12 +18,4 @@
//// case 16: //// case 16:
////} ////}
verify.rangesAreOccurrences(false);
test.ranges().forEach(r => {
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -16,11 +16,4 @@
//// [|break|]; //// [|break|];
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});

View file

@ -10,16 +10,5 @@
//// contin/*2*/ue foo; //// contin/*2*/ue foo;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start); goTo.eachMarker(() => verify.occurrencesAtPositionCount(0));
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
test.markers().forEach(m => {
goTo.position(m.position);
verify.occurrencesAtPositionCount(0);
});

View file

@ -140,15 +140,9 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -140,15 +140,9 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -140,15 +140,9 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -140,15 +140,9 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -140,15 +140,9 @@
//// } //// }
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -140,8 +140,4 @@
//// } //// }
////} ////}
goTo.eachMarker(() => verify.occurrencesAtPositionCount(0));
test.markers().forEach(m => {
goTo.position(m.position, m.fileName)
verify.occurrencesAtPositionCount(0);
});

View file

@ -42,17 +42,9 @@
//// [|throw|] false; //// [|throw|] false;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -42,17 +42,9 @@
//// throw false; //// throw false;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -42,17 +42,9 @@
//// throw false; //// throw false;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

View file

@ -42,17 +42,9 @@
//// throw false; //// throw false;
////} ////}
test.ranges().forEach(r => { verify.rangesAreOccurrences(false);
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});
goTo.marker(); goTo.marker();
test.ranges().forEach(range => { for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false); verify.occurrencesAtPositionContains(range, false);
}); }

Some files were not shown because too many files have changed in this diff Show more