From b2c4ca0a7ed81e73784383c6c3160f110b35e747 Mon Sep 17 00:00:00 2001 From: 3w36zj6 <52315048+3w36zj6@users.noreply.github.com> Date: Wed, 3 Apr 2024 03:10:46 +0900 Subject: [PATCH] test: Add comment syntax test --- .../mdxFlowExpressionComment/input.mdx | 7 + .../mdxFlowExpressionComment/output.json | 65 ++++++++ .../mdxTextExpressionComment/input.mdx | 3 + .../mdxTextExpressionComment/output.json | 147 ++++++++++++++++++ 4 files changed, 222 insertions(+) create mode 100644 test/fixtures/mdxFlowExpressionComment/input.mdx create mode 100644 test/fixtures/mdxFlowExpressionComment/output.json create mode 100644 test/fixtures/mdxTextExpressionComment/input.mdx create mode 100644 test/fixtures/mdxTextExpressionComment/output.json diff --git a/test/fixtures/mdxFlowExpressionComment/input.mdx b/test/fixtures/mdxFlowExpressionComment/input.mdx new file mode 100644 index 0000000..8eedced --- /dev/null +++ b/test/fixtures/mdxFlowExpressionComment/input.mdx @@ -0,0 +1,7 @@ +{/* comment */} + +{ /* comment */ } + +{ +/* comment */ +} diff --git a/test/fixtures/mdxFlowExpressionComment/output.json b/test/fixtures/mdxFlowExpressionComment/output.json new file mode 100644 index 0000000..612e9c7 --- /dev/null +++ b/test/fixtures/mdxFlowExpressionComment/output.json @@ -0,0 +1,65 @@ +{ + "type": "Document", + "children": [ + { + "type": "Comment", + "value": " comment ", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [0, 15], + "raw": "{/* comment */}" + }, + { + "type": "CodeBlock", + "value": " /* comment */ ", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [17, 34], + "raw": "{ /* comment */ }" + }, + { + "type": "CodeBlock", + "value": "\n/* comment */\n", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [36, 53], + "raw": "{\n/* comment */\n}" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "range": [0, 54], + "raw": "{/* comment */}\n\n{ /* comment */ }\n\n{\n/* comment */\n}\n" +} diff --git a/test/fixtures/mdxTextExpressionComment/input.mdx b/test/fixtures/mdxTextExpressionComment/input.mdx new file mode 100644 index 0000000..41ccaa7 --- /dev/null +++ b/test/fixtures/mdxTextExpressionComment/input.mdx @@ -0,0 +1,3 @@ +a {/*comment*/} b + +a { /*comment*/ } b diff --git a/test/fixtures/mdxTextExpressionComment/output.json b/test/fixtures/mdxTextExpressionComment/output.json new file mode 100644 index 0000000..898eb47 --- /dev/null +++ b/test/fixtures/mdxTextExpressionComment/output.json @@ -0,0 +1,147 @@ +{ + "type": "Document", + "children": [ + { + "type": "Paragraph", + "children": [ + { + "type": "Str", + "value": "a ", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [0, 2], + "raw": "a " + }, + { + "type": "Comment", + "value": "comment", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [2, 15], + "raw": "{/*comment*/}" + }, + { + "type": "Str", + "value": " b", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [15, 17], + "raw": " b" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [0, 17], + "raw": "a {/*comment*/} b" + }, + { + "type": "Paragraph", + "children": [ + { + "type": "Str", + "value": "a ", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "range": [19, 21], + "raw": "a " + }, + { + "type": "Code", + "value": " /*comment*/ ", + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [21, 36], + "raw": "{ /*comment*/ }" + }, + { + "type": "Str", + "value": " b", + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [36, 38], + "raw": " b" + } + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [19, 38], + "raw": "a { /*comment*/ } b" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [0, 39], + "raw": "a {/*comment*/} b\n\na { /*comment*/ } b\n" +}