From 62f16bee557f2cb604a4399c67dea623fc455afe Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 17:36:50 -0700 Subject: [PATCH] add tests --- .../cases/fourslash/indentationInComments.ts | 32 ++++++++++++++++ .../isInMultiLineCommentInTemplateLiteral.ts | 27 +++++++++++++ .../isInMultiLineCommentOnlyTrivia.ts | 38 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 tests/cases/fourslash/indentationInComments.ts create mode 100644 tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts create mode 100644 tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts diff --git a/tests/cases/fourslash/indentationInComments.ts b/tests/cases/fourslash/indentationInComments.ts new file mode 100644 index 00000000000..d54ec9daacb --- /dev/null +++ b/tests/cases/fourslash/indentationInComments.ts @@ -0,0 +1,32 @@ +/// + +//// // /*0_0*/ +//// /* /*0_1*/ +//// some text /*0_2*/ +//// some text /*1_0*/ +//// * some text /*0_3*/ +//// /*0_4*/ +//// */ +//// function foo() { +//// // /*4_0*/ +//// /** /*4_1*/ +//// * /*4_2*/ +//// * /*4_3*/ +//// /*7_0*/ +//// */ +//// /* /*4_4*/ */ +//// } + +for (let i = 0; i < 5; ++i) { + goTo.marker(`0_${i}`); + verify.indentationIs(0); + + goTo.marker(`4_${i}`); + verify.indentationIs(4); +} + +goTo.marker(`1_0`); +verify.indentationIs(1); + +goTo.marker(`7_0`); +verify.indentationIs(7); diff --git a/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts b/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts new file mode 100644 index 00000000000..ca6f11499da --- /dev/null +++ b/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts @@ -0,0 +1,27 @@ +/// + +// @Filename: file.jsx +//// ` +//// // /*0*/ +//// /* /*1*/ */ +//// /** +//// * /*2*/ +//// */ +//// foo() +//// // /*3*/ +//// /* /*4*/ */ +//// /** +//// * /*5*/ +//// */ +//// ` +//// ` +//// // /*6*/ +//// /* /*7*/ */ +//// /** +//// * /*8*/ +//// */ + +for (let i = 0; i < 9; ++i) { + goTo.marker(i.toString()); + verify.not.isInCommentAtPosition(/*onlyMultiLine*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts b/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts new file mode 100644 index 00000000000..e279af47699 --- /dev/null +++ b/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts @@ -0,0 +1,38 @@ +/// + +//// /* x */ +//// /** +//// * @param this doesn't make sense here. +//// */ +//// // x + +const firstCommentStart = 0; +const firstCommentEnd = 7; +goTo.position(firstCommentStart); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); + +goTo.position(firstCommentStart + 1); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +goTo.position(firstCommentEnd - 1); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); + +goTo.position(firstCommentEnd); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); + +const multilineJsDocStart = firstCommentEnd + 1; +const multilineJsDocEnd = multilineJsDocStart + 49; + +goTo.position(multilineJsDocStart); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +goTo.position(multilineJsDocStart + 1); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +goTo.position(multilineJsDocEnd - 1); +verify.isInCommentAtPosition(/*onlyMultiLine*/ true); +goTo.position(multilineJsDocEnd); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); + +const singleLineCommentStart = multilineJsDocEnd + 1; + +goTo.position(singleLineCommentStart + 1); +verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true); +verify.isInCommentAtPosition(/*onlyMultiLine*/ false); \ No newline at end of file