diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 26f86a02c38..4e597118e46 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1410,6 +1410,25 @@ module FourSlash { } } + public verifyTodoComments(descriptors: string[], spans: TextSpan[]) { + var actual = this.languageService.getTodoComments(this.activeFile.fileName, + descriptors.map(d => new ts.TodoCommentDescriptor(d, 0))); + + if (actual.length !== spans.length) { + throw new Error('verifyTodoComments failed - expected total spans to be ' + spans.length + ', but was ' + actual.length); + } + + for (var i = 0; i < spans.length; i++) { + var expectedSpan = spans[i]; + var actualComment = actual[i]; + var actualCommentSpan = new TypeScript.TextSpan(actualComment.position, actualComment.message.length); + + if (expectedSpan.start !== actualCommentSpan.start() || expectedSpan.end !== actualCommentSpan.end()) { + throw new Error('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualCommentSpan.start() + ',' + actualCommentSpan.end() + ')'); + } + } + } + public verifyMatchingBracePosition(bracePosition: number, expectedMatchPosition: number) { this.taoInvalidReason = 'verifyMatchingBracePosition NYI'; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 62d071e885e..ccef2d30b10 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -315,6 +315,10 @@ module FourSlashInterface { FourSlash.currentTestState.verifyTodoComments(descriptors, test.ranges()); } + public todoCommentsInCurrentFile(descriptors: string[]) { + FourSlash.currentTestState.verifyTodoComments(descriptors, test.ranges()); + } + public matchingBracePositionInCurrentFile(bracePosition: number, expectedMatchPosition: number) { FourSlash.currentTestState.verifyMatchingBracePosition(bracePosition, expectedMatchPosition); } diff --git a/tests/cases/fourslash/todoComments1.ts b/tests/cases/fourslash/todoComments1.ts new file mode 100644 index 00000000000..900b4694c6b --- /dev/null +++ b/tests/cases/fourslash/todoComments1.ts @@ -0,0 +1,3 @@ +//// // [|TODO|] +debugger; +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments10.ts b/tests/cases/fourslash/todoComments10.ts new file mode 100644 index 00000000000..26ee7a40141 --- /dev/null +++ b/tests/cases/fourslash/todoComments10.ts @@ -0,0 +1,6 @@ +//// /* +//// [|todo 1|] +//// [|hack 2|] +//// */ +debugger; +verify.todoCommentsInCurrentFile(["TODO", "HACK"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments11.ts b/tests/cases/fourslash/todoComments11.ts new file mode 100644 index 00000000000..976368315d4 --- /dev/null +++ b/tests/cases/fourslash/todoComments11.ts @@ -0,0 +1,6 @@ +//// /* +//// [|TODO(jason) 1|] +//// [|HACK 2|] +//// */ +debugger; +verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments12.ts b/tests/cases/fourslash/todoComments12.ts new file mode 100644 index 00000000000..d9cd3dea4db --- /dev/null +++ b/tests/cases/fourslash/todoComments12.ts @@ -0,0 +1,6 @@ +//// /* +//// [|TODO(jason) 1|] +//// [|HACK 2|] +//// */ +debugger; +verify.todoCommentsInCurrentFile(["HACK", "TODO(jason)"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments13.ts b/tests/cases/fourslash/todoComments13.ts new file mode 100644 index 00000000000..93147b30e47 --- /dev/null +++ b/tests/cases/fourslash/todoComments13.ts @@ -0,0 +1,4 @@ +//// TODO + +debugger; +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments14.ts b/tests/cases/fourslash/todoComments14.ts new file mode 100644 index 00000000000..46f8f48fe30 --- /dev/null +++ b/tests/cases/fourslash/todoComments14.ts @@ -0,0 +1,3 @@ +//// BAR // [|TODO|] +debugger; +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments15.ts b/tests/cases/fourslash/todoComments15.ts new file mode 100644 index 00000000000..22cee54d0fc --- /dev/null +++ b/tests/cases/fourslash/todoComments15.ts @@ -0,0 +1,3 @@ +//// "// HACK 1"; +debugger; +verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments16.ts b/tests/cases/fourslash/todoComments16.ts new file mode 100644 index 00000000000..bbdeac0c5e8 --- /dev/null +++ b/tests/cases/fourslash/todoComments16.ts @@ -0,0 +1,3 @@ +//// //// [|HACK 1|] +debugger; +verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments17.ts b/tests/cases/fourslash/todoComments17.ts new file mode 100644 index 00000000000..52316941602 --- /dev/null +++ b/tests/cases/fourslash/todoComments17.ts @@ -0,0 +1,3 @@ +//// /**** [|HACK 1 |]*/ a +debugger; +verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments2.ts b/tests/cases/fourslash/todoComments2.ts new file mode 100644 index 00000000000..b58b0fda7a7 --- /dev/null +++ b/tests/cases/fourslash/todoComments2.ts @@ -0,0 +1,3 @@ +//// // not TODO +debugger; +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments3.ts b/tests/cases/fourslash/todoComments3.ts new file mode 100644 index 00000000000..62eb02642e9 --- /dev/null +++ b/tests/cases/fourslash/todoComments3.ts @@ -0,0 +1,3 @@ +//// // [|TODO with stuff|] +debugger; +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments4.ts b/tests/cases/fourslash/todoComments4.ts new file mode 100644 index 00000000000..c9ec94785f8 --- /dev/null +++ b/tests/cases/fourslash/todoComments4.ts @@ -0,0 +1,3 @@ +//// // TODOnomatch +debugger; +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments5.ts b/tests/cases/fourslash/todoComments5.ts new file mode 100644 index 00000000000..157ac162a8c --- /dev/null +++ b/tests/cases/fourslash/todoComments5.ts @@ -0,0 +1,6 @@ +//// /* +//// [|TODO 1|] +//// [|TODO 2|] +//// */ +debugger; +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments6.ts b/tests/cases/fourslash/todoComments6.ts new file mode 100644 index 00000000000..0d2692511cb --- /dev/null +++ b/tests/cases/fourslash/todoComments6.ts @@ -0,0 +1,6 @@ +//// /* +//// * [|TODO 1|] +//// * [|TODO 2|] +//// */ +debugger; +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments7.ts b/tests/cases/fourslash/todoComments7.ts new file mode 100644 index 00000000000..ffb5bcf6603 --- /dev/null +++ b/tests/cases/fourslash/todoComments7.ts @@ -0,0 +1,6 @@ +//// /* +//// [|TODO 1|] +//// [|HACK 2|] +//// */ +debugger; +verify.todoCommentsInCurrentFile(["TODO", "HACK"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments8.ts b/tests/cases/fourslash/todoComments8.ts new file mode 100644 index 00000000000..5d53b7b57c2 --- /dev/null +++ b/tests/cases/fourslash/todoComments8.ts @@ -0,0 +1,6 @@ +//// /* +//// [|HACK 1|] +//// [|TODO 2|] +//// */ +debugger; +verify.todoCommentsInCurrentFile(["TODO", "HACK"]); \ No newline at end of file diff --git a/tests/cases/fourslash/todoComments9.ts b/tests/cases/fourslash/todoComments9.ts new file mode 100644 index 00000000000..36cba71cecf --- /dev/null +++ b/tests/cases/fourslash/todoComments9.ts @@ -0,0 +1,6 @@ +//// /* +//// [|TODO HACK|] +//// [|HACK TODO|] +//// */ +debugger; +verify.todoCommentsInCurrentFile(["TODO", "HACK"]); \ No newline at end of file