Added tests for getOccs on return keywords.

This commit is contained in:
Daniel Rosenwasser 2014-08-29 16:11:02 -07:00
parent fbb10cd6b3
commit 7e5802192e
5 changed files with 173 additions and 0 deletions

View 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);
});

View 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);
});

View 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);
});
});

View 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;
}
});

View 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);
});