mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Add tests
This commit is contained in:
parent
5544fc0d85
commit
6dfe29ec31
@ -0,0 +1,30 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// interface C extends D {
|
||||
//// /*0*/prop0: string;
|
||||
//// /*1*/prop1: number;
|
||||
//// }
|
||||
////
|
||||
//// interface D extends C {
|
||||
//// /*2*/prop0: string;
|
||||
//// /*3*/prop1: number;
|
||||
//// }
|
||||
////
|
||||
//// var d: D;
|
||||
//// d./*4*/prop1;
|
||||
|
||||
goTo.marker("0");
|
||||
verify.documentHighlightsAtPositionCount(2, ["file1.ts"]);
|
||||
|
||||
goTo.marker("1");
|
||||
verify.documentHighlightsAtPositionCount(3, ["file1.ts"]);
|
||||
|
||||
goTo.marker("2");
|
||||
verify.documentHighlightsAtPositionCount(2, ["file1.ts"]);
|
||||
|
||||
goTo.marker("3");
|
||||
verify.documentHighlightsAtPositionCount(3, ["file1.ts"]);
|
||||
|
||||
goTo.marker("4");
|
||||
verify.documentHighlightsAtPositionCount(3, ["file1.ts"]);
|
||||
@ -0,0 +1,30 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// class C extends D {
|
||||
//// /*0*/prop0: string;
|
||||
//// /*1*/prop1: string;
|
||||
//// }
|
||||
////
|
||||
//// class D extends C {
|
||||
//// /*2*/prop0: string;
|
||||
//// /*3*/prop1: string;
|
||||
//// }
|
||||
////
|
||||
//// var d: D;
|
||||
//// d./*4*/prop1;
|
||||
|
||||
goTo.marker("0");
|
||||
verify.documentHighlightsAtPositionCount(1, ["file1.ts"]);
|
||||
|
||||
goTo.marker("1");
|
||||
verify.documentHighlightsAtPositionCount(1, ["file1.ts"]);
|
||||
|
||||
goTo.marker("2");
|
||||
verify.documentHighlightsAtPositionCount(1, ["file1.ts"]);
|
||||
|
||||
goTo.marker("3");
|
||||
verify.documentHighlightsAtPositionCount(2, ["file1.ts"]);
|
||||
|
||||
goTo.marker("4");
|
||||
verify.documentHighlightsAtPositionCount(2, ["file1.ts"]);
|
||||
30
tests/cases/fourslash/findAllRefsInheritedProperties4.ts
Normal file
30
tests/cases/fourslash/findAllRefsInheritedProperties4.ts
Normal file
@ -0,0 +1,30 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface C extends D {
|
||||
//// [|prop0|]: string; // r0
|
||||
//// [|prop1|]: number; // r1
|
||||
//// }
|
||||
////
|
||||
//// interface D extends C {
|
||||
//// [|prop0|]: string; // r2
|
||||
//// }
|
||||
////
|
||||
//// var d: D;
|
||||
//// d.[|prop0|]; // r3
|
||||
//// d.[|prop1|]; // r4
|
||||
|
||||
function verifyReferences(query: FourSlashInterface.Range, references: FourSlashInterface.Range[]) {
|
||||
goTo.position(query.start);
|
||||
for (const ref of references) {
|
||||
verify.referencesAtPositionContains(ref);
|
||||
}
|
||||
}
|
||||
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
const [r0, r1, r2, r3, r4] = ranges;
|
||||
verifyReferences(r0, [r0, r2, r3]);
|
||||
verifyReferences(r1, [r1]);
|
||||
verifyReferences(r2, [r0, r2, r3]);
|
||||
verifyReferences(r3, [r0, r2, r3]);
|
||||
verifyReferences(r4, []);
|
||||
30
tests/cases/fourslash/findAllRefsInheritedProperties5.ts
Normal file
30
tests/cases/fourslash/findAllRefsInheritedProperties5.ts
Normal file
@ -0,0 +1,30 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class C extends D {
|
||||
//// [|prop0|]: string; // r0
|
||||
//// [|prop1|]: number; // r1
|
||||
//// }
|
||||
////
|
||||
//// class D extends C {
|
||||
//// [|prop0|]: string; // r2
|
||||
//// }
|
||||
////
|
||||
//// var d: D;
|
||||
//// d.[|prop0|]; // r3
|
||||
//// d.[|prop1|]; // r4
|
||||
|
||||
function verifyReferences(query: FourSlashInterface.Range, references: FourSlashInterface.Range[]) {
|
||||
goTo.position(query.start);
|
||||
for (const ref of references) {
|
||||
verify.referencesAtPositionContains(ref);
|
||||
}
|
||||
}
|
||||
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
const [r0, r1, r2, r3, r4] = ranges;
|
||||
verifyReferences(r0, [r0]);
|
||||
verifyReferences(r1, [r1]);
|
||||
verifyReferences(r2, [r2, r3]);
|
||||
verifyReferences(r3, [r2, r3]);
|
||||
verifyReferences(r4, []);
|
||||
27
tests/cases/fourslash/referencesForInheritedProperties8.ts
Normal file
27
tests/cases/fourslash/referencesForInheritedProperties8.ts
Normal file
@ -0,0 +1,27 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface C extends D {
|
||||
//// /*0*/propD: number;
|
||||
//// }
|
||||
//// interface D extends C {
|
||||
//// /*1*/propD: string;
|
||||
//// /*3*/propC: number;
|
||||
//// }
|
||||
//// var d: D;
|
||||
//// d./*2*/propD;
|
||||
//// d./*4*/propC;
|
||||
|
||||
goTo.marker("0");
|
||||
verify.referencesCountIs(3);
|
||||
|
||||
goTo.marker("1");
|
||||
verify.referencesCountIs(3);
|
||||
|
||||
goTo.marker("2");
|
||||
verify.referencesCountIs(3);
|
||||
|
||||
goTo.marker("3");
|
||||
verify.referencesCountIs(2);
|
||||
|
||||
goTo.marker("4");
|
||||
verify.referencesCountIs(2);
|
||||
21
tests/cases/fourslash/referencesForInheritedProperties9.ts
Normal file
21
tests/cases/fourslash/referencesForInheritedProperties9.ts
Normal file
@ -0,0 +1,21 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class D extends C {
|
||||
//// /*0*/prop1: string;
|
||||
//// }
|
||||
////
|
||||
//// class C extends D {
|
||||
//// /*1*/prop1: string;
|
||||
//// }
|
||||
////
|
||||
//// var c: C;
|
||||
//// c./*2*/prop1;
|
||||
|
||||
goTo.marker("0");
|
||||
verify.referencesCountIs(1);
|
||||
|
||||
goTo.marker("1");
|
||||
verify.referencesCountIs(2)
|
||||
|
||||
goTo.marker("2");
|
||||
verify.referencesCountIs(2)
|
||||
@ -7,9 +7,9 @@
|
||||
//// var v: class1;
|
||||
//// v.[|propName|];
|
||||
|
||||
let ranges = test.ranges();
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (let range of ranges) {
|
||||
for (const range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
17
tests/cases/fourslash/renameInheritedProperties5.ts
Normal file
17
tests/cases/fourslash/renameInheritedProperties5.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface C extends D {
|
||||
//// propC: number;
|
||||
//// }
|
||||
//// interface D extends C {
|
||||
//// [|propD|]: string;
|
||||
//// }
|
||||
//// var d: D;
|
||||
//// d.[|propD|];
|
||||
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (const range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
17
tests/cases/fourslash/renameInheritedProperties6.ts
Normal file
17
tests/cases/fourslash/renameInheritedProperties6.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface C extends D {
|
||||
//// propD: number;
|
||||
//// }
|
||||
//// interface D extends C {
|
||||
//// [|propC|]: number;
|
||||
//// }
|
||||
//// var d: D;
|
||||
//// d.[|propC|];
|
||||
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (const range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
19
tests/cases/fourslash/renameInheritedProperties7.ts
Normal file
19
tests/cases/fourslash/renameInheritedProperties7.ts
Normal file
@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class C extends D {
|
||||
//// [|prop1|]: string;
|
||||
//// }
|
||||
////
|
||||
//// class D extends C {
|
||||
//// prop1: string;
|
||||
//// }
|
||||
////
|
||||
//// var c: C;
|
||||
//// c.[|prop1|];
|
||||
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (const range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
19
tests/cases/fourslash/renameInheritedProperties8.ts
Normal file
19
tests/cases/fourslash/renameInheritedProperties8.ts
Normal file
@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class C implements D {
|
||||
//// [|prop1|]: string;
|
||||
//// }
|
||||
////
|
||||
//// interface D extends C {
|
||||
//// [|prop1|]: string;
|
||||
//// }
|
||||
////
|
||||
//// var c: C;
|
||||
//// c.[|prop1|];
|
||||
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (const range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user