mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Added tests for getOccs on return keywords.
This commit is contained in:
parent
fbb10cd6b3
commit
7e5802192e
33
tests/cases/fourslash/getOccurrencesReturn.ts
Normal file
33
tests/cases/fourslash/getOccurrencesReturn.ts
Normal file
@ -0,0 +1,33 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////function f(a: number) {
|
||||
//// if (a > 0) {
|
||||
//// [|ret/**/urn|] (function () {
|
||||
//// return;
|
||||
//// return;
|
||||
//// return;
|
||||
////
|
||||
//// if (false) {
|
||||
//// return true;
|
||||
//// }
|
||||
//// })() || true;
|
||||
//// }
|
||||
////
|
||||
//// var unusued = [1, 2, 3, 4].map(x => { return 4 })
|
||||
////
|
||||
//// [|return|];
|
||||
//// [|return|] true;
|
||||
////}
|
||||
|
||||
test.ranges().forEach(r => {
|
||||
goTo.position(r.start);
|
||||
|
||||
test.ranges().forEach(range => {
|
||||
verify.occurrencesAtPositionContains(range, false);
|
||||
});
|
||||
});
|
||||
|
||||
goTo.marker();
|
||||
test.ranges().forEach(range => {
|
||||
verify.occurrencesAtPositionContains(range, false);
|
||||
});
|
||||
33
tests/cases/fourslash/getOccurrencesReturn2.ts
Normal file
33
tests/cases/fourslash/getOccurrencesReturn2.ts
Normal file
@ -0,0 +1,33 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////function f(a: number) {
|
||||
//// if (a > 0) {
|
||||
//// return (function () {
|
||||
//// [|return|];
|
||||
//// [|ret/**/urn|];
|
||||
//// [|return|];
|
||||
////
|
||||
//// while (false) {
|
||||
//// [|return|] true;
|
||||
//// }
|
||||
//// })() || true;
|
||||
//// }
|
||||
////
|
||||
//// var unusued = [1, 2, 3, 4].map(x => { return 4 })
|
||||
////
|
||||
//// return;
|
||||
//// return true;
|
||||
////}
|
||||
|
||||
test.ranges().forEach(r => {
|
||||
goTo.position(r.start);
|
||||
|
||||
test.ranges().forEach(range => {
|
||||
verify.occurrencesAtPositionContains(range, false);
|
||||
});
|
||||
});
|
||||
|
||||
goTo.marker();
|
||||
test.ranges().forEach(range => {
|
||||
verify.occurrencesAtPositionContains(range, false);
|
||||
});
|
||||
28
tests/cases/fourslash/getOccurrencesReturn3.ts
Normal file
28
tests/cases/fourslash/getOccurrencesReturn3.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////function f(a: number) {
|
||||
//// if (a > 0) {
|
||||
//// return (function () {
|
||||
//// return;
|
||||
//// return;
|
||||
//// return;
|
||||
////
|
||||
//// if (false) {
|
||||
//// return true;
|
||||
//// }
|
||||
//// })() || true;
|
||||
//// }
|
||||
////
|
||||
//// var unusued = [1, 2, 3, 4].map(x => { [|return|] 4 })
|
||||
////
|
||||
//// return;
|
||||
//// return true;
|
||||
////}
|
||||
|
||||
test.ranges().forEach(r => {
|
||||
goTo.position(r.start);
|
||||
|
||||
test.ranges().forEach(range => {
|
||||
verify.occurrencesAtPositionContains(range, false);
|
||||
});
|
||||
});
|
||||
54
tests/cases/fourslash/getOccurrencesReturnBroken.ts
Normal file
54
tests/cases/fourslash/getOccurrencesReturnBroken.ts
Normal file
@ -0,0 +1,54 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////ret/*1*/urn;
|
||||
////retu/*2*/rn;
|
||||
////function f(a: number) {
|
||||
//// if (a > 0) {
|
||||
//// return (function () {
|
||||
//// () => [|return|];
|
||||
//// [|return|];
|
||||
//// [|return|];
|
||||
////
|
||||
//// if (false) {
|
||||
//// [|return|] true;
|
||||
//// }
|
||||
//// })() || true;
|
||||
//// }
|
||||
////
|
||||
//// var unusued = [1, 2, 3, 4].map(x => { return 4 })
|
||||
////
|
||||
//// return;
|
||||
//// return true;
|
||||
////}
|
||||
////
|
||||
////class A {
|
||||
//// ret/*3*/urn;
|
||||
//// r/*4*/eturn 8675309;
|
||||
////}
|
||||
|
||||
// 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);
|
||||
});
|
||||
});
|
||||
|
||||
for (var i = 1; i <= test.markers().length; i++) {
|
||||
goTo.marker("" + i);
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 4:
|
||||
verify.occurrencesAtPositionCount(0);
|
||||
break;
|
||||
case 3:
|
||||
verify.occurrencesAtPositionCount(1); // 'return' is an instance member
|
||||
break;
|
||||
}
|
||||
});
|
||||
25
tests/cases/fourslash/getOccurrencesReturnNegatives.ts
Normal file
25
tests/cases/fourslash/getOccurrencesReturnNegatives.ts
Normal file
@ -0,0 +1,25 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////function f(a: number) {
|
||||
//// if (a > 0) {
|
||||
//// return (function () {
|
||||
//// return/*1*/;
|
||||
//// return/*2*/;
|
||||
//// return/*3*/;
|
||||
////
|
||||
//// if (false) {
|
||||
//// return/*4*/ true;
|
||||
//// }
|
||||
//// })() || true;
|
||||
//// }
|
||||
////
|
||||
//// var unusued = [1, 2, 3, 4].map(x => { return/*5*/ 4 })
|
||||
////
|
||||
//// return/*6*/;
|
||||
//// return/*7*/ true;
|
||||
////}
|
||||
|
||||
test.markers().forEach(m => {
|
||||
goTo.position(m.position, m.fileName)
|
||||
verify.occurrencesAtPositionCount(0);
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user