From a36f8e42bdf23974ae9118b1798f2071bb0f8312 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Mon, 11 Oct 2021 20:08:23 +0300 Subject: [PATCH] test(css/parser): Add tests for comments (#2364) --- css/parser/tests/fixture/comment/input.css | 24 ++ css/parser/tests/fixture/comment/output.json | 352 ++++++++++++++++++ .../tests/fixture/comment/span.rust-debug | 334 +++++++++++++++++ 3 files changed, 710 insertions(+) create mode 100644 css/parser/tests/fixture/comment/input.css create mode 100644 css/parser/tests/fixture/comment/output.json create mode 100644 css/parser/tests/fixture/comment/span.rust-debug diff --git a/css/parser/tests/fixture/comment/input.css b/css/parser/tests/fixture/comment/input.css new file mode 100644 index 000000000000..b208f0f43102 --- /dev/null +++ b/css/parser/tests/fixture/comment/input.css @@ -0,0 +1,24 @@ +/* comment */a/* comment */ +{ +/* comment */color/* comment */:/* comment */red/* comment */; +} + +/* a { color: black } */ +/**/ +/* */ +div { + /* inside */ + color: black; + /* between */ + background: red; + /* end */ +} +/* b */ + +a { + color: black; + /* c */ +} + +@media/* comment */screen/* comment */{} +@media /* comment */ screen /* comment */ {} diff --git a/css/parser/tests/fixture/comment/output.json b/css/parser/tests/fixture/comment/output.json new file mode 100644 index 000000000000..6fd15c38bdd2 --- /dev/null +++ b/css/parser/tests/fixture/comment/output.json @@ -0,0 +1,352 @@ +{ + "type": "Stylesheet", + "span": { + "start": 13, + "end": 360, + "ctxt": 0 + }, + "rules": [ + { + "type": "StyleRule", + "span": { + "start": 13, + "end": 94, + "ctxt": 0 + }, + "selectors": [ + { + "type": "ComplexSelector", + "span": { + "start": 13, + "end": 14, + "ctxt": 0 + }, + "selectors": [ + { + "type": "CompoundSelector", + "span": { + "start": 13, + "end": 14, + "ctxt": 0 + }, + "hasNestPrefix": false, + "combinator": null, + "typeSelector": { + "type": "NamespacedName", + "span": { + "start": 13, + "end": 14, + "ctxt": 0 + }, + "prefix": null, + "name": { + "type": "Text", + "span": { + "start": 13, + "end": 14, + "ctxt": 0 + }, + "value": "a", + "raw": "a" + } + }, + "subclassSelectors": [] + } + ] + } + ], + "block": { + "type": "DeclBlock", + "span": { + "start": 28, + "end": 94, + "ctxt": 0 + }, + "items": [ + { + "type": "Property", + "span": { + "start": 43, + "end": 78, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 43, + "end": 48, + "ctxt": 0 + }, + "value": "color", + "raw": "color" + }, + "values": [ + { + "type": "Text", + "span": { + "start": 75, + "end": 78, + "ctxt": 0 + }, + "value": "red", + "raw": "red" + } + ], + "important": null + } + ] + } + }, + { + "type": "StyleRule", + "span": { + "start": 132, + "end": 227, + "ctxt": 0 + }, + "selectors": [ + { + "type": "ComplexSelector", + "span": { + "start": 132, + "end": 135, + "ctxt": 0 + }, + "selectors": [ + { + "type": "CompoundSelector", + "span": { + "start": 132, + "end": 135, + "ctxt": 0 + }, + "hasNestPrefix": false, + "combinator": null, + "typeSelector": { + "type": "NamespacedName", + "span": { + "start": 132, + "end": 135, + "ctxt": 0 + }, + "prefix": null, + "name": { + "type": "Text", + "span": { + "start": 132, + "end": 135, + "ctxt": 0 + }, + "value": "div", + "raw": "div" + } + }, + "subclassSelectors": [] + } + ] + } + ], + "block": { + "type": "DeclBlock", + "span": { + "start": 136, + "end": 227, + "ctxt": 0 + }, + "items": [ + { + "type": "Property", + "span": { + "start": 159, + "end": 171, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 159, + "end": 164, + "ctxt": 0 + }, + "value": "color", + "raw": "color" + }, + "values": [ + { + "type": "Text", + "span": { + "start": 166, + "end": 171, + "ctxt": 0 + }, + "value": "black", + "raw": "black" + } + ], + "important": null + }, + { + "type": "Property", + "span": { + "start": 195, + "end": 210, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 195, + "end": 205, + "ctxt": 0 + }, + "value": "background", + "raw": "background" + }, + "values": [ + { + "type": "Text", + "span": { + "start": 207, + "end": 210, + "ctxt": 0 + }, + "value": "red", + "raw": "red" + } + ], + "important": null + } + ] + } + }, + { + "type": "StyleRule", + "span": { + "start": 237, + "end": 272, + "ctxt": 0 + }, + "selectors": [ + { + "type": "ComplexSelector", + "span": { + "start": 237, + "end": 238, + "ctxt": 0 + }, + "selectors": [ + { + "type": "CompoundSelector", + "span": { + "start": 237, + "end": 238, + "ctxt": 0 + }, + "hasNestPrefix": false, + "combinator": null, + "typeSelector": { + "type": "NamespacedName", + "span": { + "start": 237, + "end": 238, + "ctxt": 0 + }, + "prefix": null, + "name": { + "type": "Text", + "span": { + "start": 237, + "end": 238, + "ctxt": 0 + }, + "value": "a", + "raw": "a" + } + }, + "subclassSelectors": [] + } + ] + } + ], + "block": { + "type": "DeclBlock", + "span": { + "start": 239, + "end": 272, + "ctxt": 0 + }, + "items": [ + { + "type": "Property", + "span": { + "start": 245, + "end": 257, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 245, + "end": 250, + "ctxt": 0 + }, + "value": "color", + "raw": "color" + }, + "values": [ + { + "type": "Text", + "span": { + "start": 252, + "end": 257, + "ctxt": 0 + }, + "value": "black", + "raw": "black" + } + ], + "important": null + } + ] + } + }, + { + "type": "MediaRule", + "span": { + "start": 274, + "end": 314, + "ctxt": 0 + }, + "query": { + "type": "Text", + "span": { + "start": 293, + "end": 299, + "ctxt": 0 + }, + "value": "screen", + "raw": "screen" + }, + "rules": [] + }, + { + "type": "MediaRule", + "span": { + "start": 315, + "end": 359, + "ctxt": 0 + }, + "query": { + "type": "Text", + "span": { + "start": 336, + "end": 342, + "ctxt": 0 + }, + "value": "screen", + "raw": "screen" + }, + "rules": [] + } + ] +} diff --git a/css/parser/tests/fixture/comment/span.rust-debug b/css/parser/tests/fixture/comment/span.rust-debug new file mode 100644 index 000000000000..ca2e7b34f0dc --- /dev/null +++ b/css/parser/tests/fixture/comment/span.rust-debug @@ -0,0 +1,334 @@ +error: Stylesheet + --> $DIR/tests/fixture/comment/input.css:1:14 + | +1 | /* comment */a/* comment */ + | ______________^ +2 | | { +3 | | /* comment */color/* comment */:/* comment */red/* comment */; +4 | | } +... | +23 | | @media/* comment */screen/* comment */{} +24 | | @media /* comment */ screen /* comment */ {} + | |_____________________________________________^ + +error: Rule + --> $DIR/tests/fixture/comment/input.css:1:14 + | +1 | /* comment */a/* comment */ + | ______________^ +2 | | { +3 | | /* comment */color/* comment */:/* comment */red/* comment */; +4 | | } + | |_^ + +error: StyleRule + --> $DIR/tests/fixture/comment/input.css:1:14 + | +1 | /* comment */a/* comment */ + | ______________^ +2 | | { +3 | | /* comment */color/* comment */:/* comment */red/* comment */; +4 | | } + | |_^ + +error: ComplexSelector + --> $DIR/tests/fixture/comment/input.css:1:14 + | +1 | /* comment */a/* comment */ + | ^ + +error: CompoundSelector + --> $DIR/tests/fixture/comment/input.css:1:14 + | +1 | /* comment */a/* comment */ + | ^ + +error: NamespacedName + --> $DIR/tests/fixture/comment/input.css:1:14 + | +1 | /* comment */a/* comment */ + | ^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:1:14 + | +1 | /* comment */a/* comment */ + | ^ + +error: DeclBlock + --> $DIR/tests/fixture/comment/input.css:2:1 + | +2 | / { +3 | | /* comment */color/* comment */:/* comment */red/* comment */; +4 | | } + | |_^ + +error: Property + --> $DIR/tests/fixture/comment/input.css:3:14 + | +3 | /* comment */color/* comment */:/* comment */red/* comment */; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:3:14 + | +3 | /* comment */color/* comment */:/* comment */red/* comment */; + | ^^^^^ + +error: Value + --> $DIR/tests/fixture/comment/input.css:3:46 + | +3 | /* comment */color/* comment */:/* comment */red/* comment */; + | ^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:3:46 + | +3 | /* comment */color/* comment */:/* comment */red/* comment */; + | ^^^ + +error: Rule + --> $DIR/tests/fixture/comment/input.css:9:1 + | +9 | / div { +10 | | /* inside */ +11 | | color: black; +12 | | /* between */ +13 | | background: red; +14 | | /* end */ +15 | | } + | |_^ + +error: StyleRule + --> $DIR/tests/fixture/comment/input.css:9:1 + | +9 | / div { +10 | | /* inside */ +11 | | color: black; +12 | | /* between */ +13 | | background: red; +14 | | /* end */ +15 | | } + | |_^ + +error: ComplexSelector + --> $DIR/tests/fixture/comment/input.css:9:1 + | +9 | div { + | ^^^ + +error: CompoundSelector + --> $DIR/tests/fixture/comment/input.css:9:1 + | +9 | div { + | ^^^ + +error: NamespacedName + --> $DIR/tests/fixture/comment/input.css:9:1 + | +9 | div { + | ^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:9:1 + | +9 | div { + | ^^^ + +error: DeclBlock + --> $DIR/tests/fixture/comment/input.css:9:5 + | +9 | div { + | _____^ +10 | | /* inside */ +11 | | color: black; +12 | | /* between */ +13 | | background: red; +14 | | /* end */ +15 | | } + | |_^ + +error: Property + --> $DIR/tests/fixture/comment/input.css:11:5 + | +11 | color: black; + | ^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:11:5 + | +11 | color: black; + | ^^^^^ + +error: Value + --> $DIR/tests/fixture/comment/input.css:11:12 + | +11 | color: black; + | ^^^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:11:12 + | +11 | color: black; + | ^^^^^ + +error: Property + --> $DIR/tests/fixture/comment/input.css:13:5 + | +13 | background: red; + | ^^^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:13:5 + | +13 | background: red; + | ^^^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/comment/input.css:13:17 + | +13 | background: red; + | ^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:13:17 + | +13 | background: red; + | ^^^ + +error: Rule + --> $DIR/tests/fixture/comment/input.css:18:1 + | +18 | / a { +19 | | color: black; +20 | | /* c */ +21 | | } + | |_^ + +error: StyleRule + --> $DIR/tests/fixture/comment/input.css:18:1 + | +18 | / a { +19 | | color: black; +20 | | /* c */ +21 | | } + | |_^ + +error: ComplexSelector + --> $DIR/tests/fixture/comment/input.css:18:1 + | +18 | a { + | ^ + +error: CompoundSelector + --> $DIR/tests/fixture/comment/input.css:18:1 + | +18 | a { + | ^ + +error: NamespacedName + --> $DIR/tests/fixture/comment/input.css:18:1 + | +18 | a { + | ^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:18:1 + | +18 | a { + | ^ + +error: DeclBlock + --> $DIR/tests/fixture/comment/input.css:18:3 + | +18 | a { + | ___^ +19 | | color: black; +20 | | /* c */ +21 | | } + | |_^ + +error: Property + --> $DIR/tests/fixture/comment/input.css:19:5 + | +19 | color: black; + | ^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:19:5 + | +19 | color: black; + | ^^^^^ + +error: Value + --> $DIR/tests/fixture/comment/input.css:19:12 + | +19 | color: black; + | ^^^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:19:12 + | +19 | color: black; + | ^^^^^ + +error: Rule + --> $DIR/tests/fixture/comment/input.css:23:1 + | +23 | @media/* comment */screen/* comment */{} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: AtRule + --> $DIR/tests/fixture/comment/input.css:23:1 + | +23 | @media/* comment */screen/* comment */{} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: MediaRule + --> $DIR/tests/fixture/comment/input.css:23:1 + | +23 | @media/* comment */screen/* comment */{} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: MediaQuery + --> $DIR/tests/fixture/comment/input.css:23:20 + | +23 | @media/* comment */screen/* comment */{} + | ^^^^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:23:20 + | +23 | @media/* comment */screen/* comment */{} + | ^^^^^^ + +error: Rule + --> $DIR/tests/fixture/comment/input.css:24:1 + | +24 | @media /* comment */ screen /* comment */ {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: AtRule + --> $DIR/tests/fixture/comment/input.css:24:1 + | +24 | @media /* comment */ screen /* comment */ {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: MediaRule + --> $DIR/tests/fixture/comment/input.css:24:1 + | +24 | @media /* comment */ screen /* comment */ {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: MediaQuery + --> $DIR/tests/fixture/comment/input.css:24:22 + | +24 | @media /* comment */ screen /* comment */ {} + | ^^^^^^ + +error: Text + --> $DIR/tests/fixture/comment/input.css:24:22 + | +24 | @media /* comment */ screen /* comment */ {} + | ^^^^^^ +