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
public goToMarker(name = "") {
const marker = this.getMarkerByName(name);
public goToMarker(name: string | Marker = "") {
const marker = typeof name === "string" ? this.getMarkerByName(name) : name;
if (this.activeFile.fileName !== marker.fileName) {
this.openFile(marker.fileName);
}
@ -382,10 +382,37 @@ namespace FourSlash {
if (marker.position === -1 || marker.position > content.length) {
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);
}
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) {
this.currentCaretPosition = pos;
}
@ -1668,7 +1695,7 @@ namespace FourSlash {
this.goToPosition(len);
}
private goToRangeStart({fileName, start}: Range) {
public goToRangeStart({fileName, start}: Range) {
this.openFile(fileName);
this.goToPosition(start);
}
@ -2365,6 +2392,21 @@ namespace FourSlash {
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() {
this.rangesByText().forEach(ranges => this.verifyRangesAreDocumentHighlights(ranges));
}
@ -3078,10 +3120,22 @@ namespace FourSlashInterface {
// Moves the caret to the specified marker,
// or the anonymous marker ('/**/') if no name
// is given
public marker(name?: string) {
public marker(name?: string | FourSlash.Marker) {
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() {
this.state.goToBOF();
}
@ -3432,6 +3486,14 @@ namespace FourSlashInterface {
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[]) {
this.state.verifyRangesAreDocumentHighlights(ranges);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@
//// var y : any = "", x = (a/*var5*/
////class C{}
////var y = new C(
////var y = new C(
//// class C{}
//// var y = new C(0, /*var7*/
@ -26,9 +26,4 @@
////var y = 10; y=/*var12*/
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListAllowsNewIdentifier();
});
goTo.eachMarker(() => verify.completionListAllowsNewIdentifier());

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,12 +3,9 @@
// @Filename: justAComment.ts
//// // We want to check off-by-one errors in assessing the end of the comment, so we check twice,
//// // first with a trailing space and then without.
//// // /*0*/
//// // /*0*/
//// // /*1*/
//// // We also want to check EOF handling at the end of a comment
//// // /*2*/
test.markers().forEach((marker) => {
goTo.position(marker.position);
verify.noDocCommentTemplate();
});
goTo.eachMarker(() => verify.noDocCommentTemplate());

View file

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

View file

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

View file

@ -117,7 +117,10 @@ declare namespace FourSlashInterface {
markerByName(s: string): Marker;
}
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;
eof(): void;
implementation(): void;
@ -191,6 +194,8 @@ declare namespace FourSlashInterface {
* `start` should be included in `references`.
*/
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.
* If `ranges` is omitted, this is `test.ranges()`.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -46,7 +46,7 @@
//// default:
//// [|continue|];
//// }
////
////
//// // these cross function boundaries
//// break label1;
//// continue label1;
@ -63,17 +63,10 @@
////
////label7: while (true) continue label5;
test.ranges().forEach(r => {
goTo.position(r.start);
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
verify.rangesAreOccurrences(false);
goTo.marker();
verify.occurrencesAtPositionCount(test.ranges().length);
test.ranges().forEach(range => {
for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false);
});
}

View file

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

View file

@ -46,7 +46,7 @@
//// default:
//// continue;
//// }
////
////
//// // these cross function boundaries
//// br/*5*/eak label1;
//// co/*6*/ntinue label1;
@ -63,8 +63,4 @@
////
////label7: while (true) co/*10*/ntinue label5;
test.markers().forEach(m => {
goTo.position(m.position);
verify.occurrencesAtPositionCount(0);
});
goTo.eachMarker(() => verify.occurrencesAtPositionCount(0));

View file

@ -46,7 +46,7 @@
//// default:
//// continue;
//// }
////
////
//// // these cross function boundaries
//// br/*5*/eak label1;
//// co/*6*/ntinue label1;
@ -63,8 +63,4 @@
////
////label7: while (true) co/*10*/ntinue label5;
test.markers().forEach(m => {
goTo.position(m.position);
verify.occurrencesAtPositionCount(0);
});
goTo.eachMarker(() => verify.occurrencesAtPositionCount(0));

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -26,17 +26,11 @@
//// r/*4*/eturn 8675309;
////}
// Note: For this test, these 'return's get highlighted as a result of a parse recovery
// Note: For this test, these 'return's get highlighted as a result of a parse recovery
// 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,
// a change to this test is very much welcome.
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
verify.rangesAreOccurrences(false);
for (var i = 1; i <= test.markers().length; i++) {
goTo.marker("" + i);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -27,7 +27,7 @@
////
//// public method3() {
//// var x = () => [|super|].superMethod();
////
////
//// // Bad but still gets highlighted
//// function f() {
//// [|super|].superMethod();
@ -50,15 +50,9 @@
//// static super = 20;
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
verify.rangesAreOccurrences(false);
goTo.marker();
test.ranges().forEach(range => {
for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false);
});
}

View file

@ -27,7 +27,7 @@
////
//// public method3() {
//// var x = () => super.superMethod();
////
////
//// // Bad but still gets highlighted
//// function f() {
//// super.superMethod();
@ -50,15 +50,9 @@
//// static super = 20;
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
verify.rangesAreOccurrences(false);
goTo.marker();
test.ranges().forEach(range => {
for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false);
});
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -89,7 +89,7 @@
//// }
////
//// public static staticB = [|this|].staticMethod1;
////
////
//// public static staticMethod1() {
//// [|this|];
//// [|this|];
@ -140,15 +140,9 @@
//// }
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
verify.rangesAreOccurrences(false);
goTo.marker();
test.ranges().forEach(range => {
for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false);
});
}

View file

@ -89,7 +89,7 @@
//// }
////
//// public static staticB = this.staticMethod1;
////
////
//// public static staticMethod1() {
//// this;
//// this;
@ -140,8 +140,4 @@
//// }
////}
test.markers().forEach(m => {
goTo.position(m.position, m.fileName)
verify.occurrencesAtPositionCount(0);
});
goTo.eachMarker(() => verify.occurrencesAtPositionCount(0));

View file

@ -3,7 +3,7 @@
////function f(a: number) {
//// try {
//// throw "Hello";
////
////
//// try {
//// throw 10;
//// }
@ -42,17 +42,9 @@
//// [|throw|] false;
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});
verify.rangesAreOccurrences(false);
goTo.marker();
test.ranges().forEach(range => {
for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false);
});
}

View file

@ -3,7 +3,7 @@
////function f(a: number) {
//// try {
//// throw "Hello";
////
////
//// try {
//// [|t/**/hrow|] 10;
//// }
@ -42,17 +42,9 @@
//// throw false;
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});
verify.rangesAreOccurrences(false);
goTo.marker();
test.ranges().forEach(range => {
for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false);
});
}

View file

@ -3,7 +3,7 @@
////function f(a: number) {
//// try {
//// [|throw|] "Hello";
////
////
//// try {
//// throw 10;
//// }
@ -42,17 +42,9 @@
//// throw false;
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});
verify.rangesAreOccurrences(false);
goTo.marker();
test.ranges().forEach(range => {
for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false);
});
}

View file

@ -3,7 +3,7 @@
////function f(a: number) {
//// try {
//// throw "Hello";
////
////
//// try {
//// throw 10;
//// }
@ -42,17 +42,9 @@
//// throw false;
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
verify.occurrencesAtPositionCount(test.ranges().length);
});
verify.rangesAreOccurrences(false);
goTo.marker();
test.ranges().forEach(range => {
for (const range of test.ranges()) {
verify.occurrencesAtPositionContains(range, false);
});
}

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