Skip to content

Commit a21477d

Browse files
Used dynamically computed indexes in verifies
1 parent 99bb366 commit a21477d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/testRunner/unittests/incrementalParser.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -922,14 +922,14 @@ module m3 { }\
922922
}
923923

924924
function verifyChangeToBlah(atIndex: number, singleIgnore?: true) {
925-
const index = getIndexOfTsIgnoreComment(atIndex) + "// ".length;
925+
const index = getIndexOfTsIgnoreComment(atIndex) + tsIgnoreComment.indexOf("@");
926926
const oldText = ScriptSnapshot.fromString(textWithIgnoreCommentFrom(textWithIgnoreComment, singleIgnore));
927927
const newTextAndChange = withChange(oldText, index, 1, "blah ");
928928
verifyCommentDirectives(oldText, newTextAndChange);
929929
}
930930

931931
function verifyChangeBackToDirective(atIndex: number, singleIgnore?: true) {
932-
const index = getIndexOfTsIgnoreComment(atIndex) + "// ".length;
932+
const index = getIndexOfTsIgnoreComment(atIndex) + tsIgnoreComment.indexOf("@");
933933
const source = textWithIgnoreCommentFrom(textWithIgnoreComment.slice(0, index) + "blah " + textWithIgnoreComment.slice(index + 1), singleIgnore);
934934
const oldText = ScriptSnapshot.fromString(source);
935935
const newTextAndChange = withChange(oldText, index, "blah ".length, "@");
@@ -938,15 +938,15 @@ module m3 { }\
938938

939939
function verifyDeletingBlah(atIndex: number, singleIgnore?: true) {
940940
const tsIgnoreIndex = getIndexOfTsIgnoreComment(atIndex);
941-
const index = tsIgnoreIndex + "// ".length;
941+
const index = tsIgnoreIndex + tsIgnoreComment.indexOf("@");
942942
const source = textWithIgnoreCommentFrom(textWithIgnoreComment.slice(0, index) + "blah " + textWithIgnoreComment.slice(index + 1), singleIgnore);
943943
const oldText = ScriptSnapshot.fromString(source);
944944
const newTextAndChange = withDelete(oldText, tsIgnoreIndex, tsIgnoreComment.length + "blah".length);
945945
verifyCommentDirectives(oldText, newTextAndChange);
946946
}
947947

948948
function verifyChangeDirectiveType(atIndex: number, singleIgnore?: true) {
949-
const index = getIndexOfTsIgnoreComment(atIndex) + "// @ts-".length;
949+
const index = getIndexOfTsIgnoreComment(atIndex) + tsIgnoreComment.indexOf("ignore");
950950
const oldText = ScriptSnapshot.fromString(textWithIgnoreCommentFrom(textWithIgnoreComment, singleIgnore));
951951
const newTextAndChange = withChange(oldText, index, "ignore".length, "expect-error");
952952
verifyCommentDirectives(oldText, newTextAndChange);
@@ -956,21 +956,21 @@ module m3 { }\
956956
const source = `const x = 10;
957957
function foo1() {
958958
const x1 = 10;
959-
// @ts-ignore
959+
${tsIgnoreComment}
960960
let y0: string = x;
961961
let y1: string = x;
962962
return y1;
963963
}
964964
function foo2() {
965965
const x2 = 10;
966-
// @ts-ignore
966+
${tsIgnoreComment}
967967
let y0: string = x;
968968
let y2: string = x;
969969
return y2;
970970
}
971971
function foo3() {
972972
const x3 = 10;
973-
// @ts-ignore
973+
${tsIgnoreComment}
974974
let y0: string = x;
975975
let y3: string = x;
976976
return y3;

0 commit comments

Comments
 (0)