From 2e8ce46a41a31f247bcd50e3bd04b1ed5b8f89c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 9 Sep 2024 16:19:08 +0200 Subject: [PATCH] Add tests for JSDoc `@pattern` with `@` in it --- src/testRunner/unittests/jsDocParsing.ts | 6 ++++ ...parsesCorrectly.@pattern with @ in it.json | 30 +++++++++++++++++++ .../cases/fourslash/quickInfoJsDocPattern1.ts | 13 ++++++++ 3 files changed, 49 insertions(+) create mode 100644 tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.@pattern with @ in it.json create mode 100644 tests/cases/fourslash/quickInfoJsDocPattern1.ts diff --git a/src/testRunner/unittests/jsDocParsing.ts b/src/testRunner/unittests/jsDocParsing.ts index 546bffaa777e1..98aea4020d382 100644 --- a/src/testRunner/unittests/jsDocParsing.ts +++ b/src/testRunner/unittests/jsDocParsing.ts @@ -508,6 +508,12 @@ oh.no "@@ does not start a new tag", `/** * @param this is (@@fine@@and) is one comment + */`, + ); + parsesCorrectly( + "@pattern with @ in it", + `/** + * @pattern ^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$ */`, ); }); diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.@pattern with @ in it.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.@pattern with @ in it.json new file mode 100644 index 0000000000000..2e6fe380ee388 --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.@pattern with @ in it.json @@ -0,0 +1,30 @@ +{ + "kind": "JSDoc", + "pos": 0, + "end": 68, + "flags": "JSDoc", + "modifierFlagsCache": 0, + "transformFlags": 0, + "tags": { + "0": { + "kind": "JSDocTag", + "pos": 7, + "end": 66, + "modifierFlagsCache": 0, + "transformFlags": 0, + "tagName": { + "kind": "Identifier", + "pos": 8, + "end": 15, + "transformFlags": 0, + "escapedText": "pattern" + }, + "comment": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$" + }, + "length": 1, + "pos": 7, + "end": 66, + "hasTrailingComma": false, + "transformFlags": 0 + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoJsDocPattern1.ts b/tests/cases/fourslash/quickInfoJsDocPattern1.ts new file mode 100644 index 0000000000000..cdbdc3708da6d --- /dev/null +++ b/tests/cases/fourslash/quickInfoJsDocPattern1.ts @@ -0,0 +1,13 @@ +/// + +//// class Test { +//// /** +//// * @pattern ^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$ +//// */ +//// public emailPattern/*1*/: string; +//// } + +verify.quickInfoAt("1", "(property) Test.emailPattern: string", undefined, [{ + name: "pattern", + text: "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\\\.[a-zA-Z0-9-.]+$" +}]);