mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Add todo comment tests.
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
3
tests/cases/fourslash/todoComments1.ts
Normal file
3
tests/cases/fourslash/todoComments1.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
//// // [|TODO|]
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
6
tests/cases/fourslash/todoComments10.ts
Normal file
6
tests/cases/fourslash/todoComments10.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
//// /*
|
||||
//// [|todo 1|]
|
||||
//// [|hack 2|]
|
||||
//// */
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO", "HACK"]);
|
||||
6
tests/cases/fourslash/todoComments11.ts
Normal file
6
tests/cases/fourslash/todoComments11.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
//// /*
|
||||
//// [|TODO(jason) 1|]
|
||||
//// [|HACK 2|]
|
||||
//// */
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]);
|
||||
6
tests/cases/fourslash/todoComments12.ts
Normal file
6
tests/cases/fourslash/todoComments12.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
//// /*
|
||||
//// [|TODO(jason) 1|]
|
||||
//// [|HACK 2|]
|
||||
//// */
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["HACK", "TODO(jason)"]);
|
||||
4
tests/cases/fourslash/todoComments13.ts
Normal file
4
tests/cases/fourslash/todoComments13.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
//// TODO
|
||||
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
3
tests/cases/fourslash/todoComments14.ts
Normal file
3
tests/cases/fourslash/todoComments14.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
//// BAR // [|TODO|]
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
3
tests/cases/fourslash/todoComments15.ts
Normal file
3
tests/cases/fourslash/todoComments15.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
//// "// HACK 1";
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]);
|
||||
3
tests/cases/fourslash/todoComments16.ts
Normal file
3
tests/cases/fourslash/todoComments16.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
//// //// [|HACK 1|]
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]);
|
||||
3
tests/cases/fourslash/todoComments17.ts
Normal file
3
tests/cases/fourslash/todoComments17.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
//// /**** [|HACK 1 |]*/ a
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]);
|
||||
3
tests/cases/fourslash/todoComments2.ts
Normal file
3
tests/cases/fourslash/todoComments2.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
//// // not TODO
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
3
tests/cases/fourslash/todoComments3.ts
Normal file
3
tests/cases/fourslash/todoComments3.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
//// // [|TODO with stuff|]
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
3
tests/cases/fourslash/todoComments4.ts
Normal file
3
tests/cases/fourslash/todoComments4.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
//// // TODOnomatch
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
6
tests/cases/fourslash/todoComments5.ts
Normal file
6
tests/cases/fourslash/todoComments5.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
//// /*
|
||||
//// [|TODO 1|]
|
||||
//// [|TODO 2|]
|
||||
//// */
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
6
tests/cases/fourslash/todoComments6.ts
Normal file
6
tests/cases/fourslash/todoComments6.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
//// /*
|
||||
//// * [|TODO 1|]
|
||||
//// * [|TODO 2|]
|
||||
//// */
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
6
tests/cases/fourslash/todoComments7.ts
Normal file
6
tests/cases/fourslash/todoComments7.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
//// /*
|
||||
//// [|TODO 1|]
|
||||
//// [|HACK 2|]
|
||||
//// */
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO", "HACK"]);
|
||||
6
tests/cases/fourslash/todoComments8.ts
Normal file
6
tests/cases/fourslash/todoComments8.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
//// /*
|
||||
//// [|HACK 1|]
|
||||
//// [|TODO 2|]
|
||||
//// */
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO", "HACK"]);
|
||||
6
tests/cases/fourslash/todoComments9.ts
Normal file
6
tests/cases/fourslash/todoComments9.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
//// /*
|
||||
//// [|TODO HACK|]
|
||||
//// [|HACK TODO|]
|
||||
//// */
|
||||
debugger;
|
||||
verify.todoCommentsInCurrentFile(["TODO", "HACK"]);
|
||||
Reference in New Issue
Block a user