test(css/parser): Add tests for refactoring (#6262)

This commit is contained in:
Alexander Akait 2022-10-27 01:58:59 +03:00 committed by GitHub
parent 3fdc8071e1
commit 4c293f965b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 7489 additions and 8 deletions

View File

@ -141,3 +141,11 @@
background: red;
}
}
@supports (func("example": 1)) {
* { background: red; }
}
@supports (--var) {
* { background: red; }
}

View File

@ -2,7 +2,7 @@
"type": "Stylesheet",
"span": {
"start": 1,
"end": 3104,
"end": 3217,
"ctxt": 0
},
"rules": [
@ -8935,6 +8935,408 @@
}
]
}
},
{
"type": "AtRule",
"span": {
"start": 3105,
"end": 3166,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 3106,
"end": 3114,
"ctxt": 0
},
"value": "supports",
"raw": "supports"
},
"prelude": {
"type": "SupportsCondition",
"span": {
"start": 3115,
"end": 3135,
"ctxt": 0
},
"conditions": [
{
"type": "SupportsCondition",
"span": {
"start": 3116,
"end": 3134,
"ctxt": 0
},
"conditions": [
{
"type": "Function",
"span": {
"start": 3116,
"end": 3134,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 3116,
"end": 3120,
"ctxt": 0
},
"value": "func",
"raw": "func"
},
"value": [
{
"type": "PreservedToken",
"span": {
"start": 3121,
"end": 3130,
"ctxt": 0
},
"token": {
"String": {
"value": "example",
"raw": "\"example\""
}
}
},
{
"type": "PreservedToken",
"span": {
"start": 3130,
"end": 3131,
"ctxt": 0
},
"token": "Colon"
},
{
"type": "PreservedToken",
"span": {
"start": 3131,
"end": 3132,
"ctxt": 0
},
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"type": "PreservedToken",
"span": {
"start": 3132,
"end": 3133,
"ctxt": 0
},
"token": {
"Number": {
"value": 1.0,
"raw": "1",
"type": "integer"
}
}
}
]
}
]
}
]
},
"block": {
"type": "SimpleBlock",
"span": {
"start": 3136,
"end": 3166,
"ctxt": 0
},
"name": {
"type": "PreservedToken",
"span": {
"start": 3136,
"end": 3137,
"ctxt": 0
},
"token": "LBrace"
},
"value": [
{
"type": "QualifiedRule",
"span": {
"start": 3142,
"end": 3164,
"ctxt": 0
},
"prelude": {
"type": "SelectorList",
"span": {
"start": 3142,
"end": 3143,
"ctxt": 0
},
"children": [
{
"type": "ComplexSelector",
"span": {
"start": 3142,
"end": 3143,
"ctxt": 0
},
"children": [
{
"type": "CompoundSelector",
"span": {
"start": 3142,
"end": 3143,
"ctxt": 0
},
"nestingSelector": null,
"typeSelector": {
"type": "UniversalSelector",
"span": {
"start": 3142,
"end": 3143,
"ctxt": 0
},
"prefix": null
},
"subclassSelectors": []
}
]
}
]
},
"block": {
"type": "SimpleBlock",
"span": {
"start": 3144,
"end": 3164,
"ctxt": 0
},
"name": {
"type": "PreservedToken",
"span": {
"start": 3144,
"end": 3145,
"ctxt": 0
},
"token": "LBrace"
},
"value": [
{
"type": "Declaration",
"span": {
"start": 3146,
"end": 3161,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 3146,
"end": 3156,
"ctxt": 0
},
"value": "background",
"raw": "background"
},
"value": [
{
"type": "Ident",
"span": {
"start": 3158,
"end": 3161,
"ctxt": 0
},
"value": "red",
"raw": "red"
}
],
"important": null
}
]
}
}
]
}
},
{
"type": "AtRule",
"span": {
"start": 3168,
"end": 3216,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 3169,
"end": 3177,
"ctxt": 0
},
"value": "supports",
"raw": "supports"
},
"prelude": {
"type": "SupportsCondition",
"span": {
"start": 3178,
"end": 3185,
"ctxt": 0
},
"conditions": [
{
"type": "SimpleBlock",
"span": {
"start": 3178,
"end": 3185,
"ctxt": 0
},
"name": {
"type": "PreservedToken",
"span": {
"start": 3178,
"end": 3179,
"ctxt": 0
},
"token": "LParen"
},
"value": [
{
"type": "PreservedToken",
"span": {
"start": 3179,
"end": 3184,
"ctxt": 0
},
"token": {
"Ident": {
"value": "--var",
"raw": "--var"
}
}
}
]
}
]
},
"block": {
"type": "SimpleBlock",
"span": {
"start": 3186,
"end": 3216,
"ctxt": 0
},
"name": {
"type": "PreservedToken",
"span": {
"start": 3186,
"end": 3187,
"ctxt": 0
},
"token": "LBrace"
},
"value": [
{
"type": "QualifiedRule",
"span": {
"start": 3192,
"end": 3214,
"ctxt": 0
},
"prelude": {
"type": "SelectorList",
"span": {
"start": 3192,
"end": 3193,
"ctxt": 0
},
"children": [
{
"type": "ComplexSelector",
"span": {
"start": 3192,
"end": 3193,
"ctxt": 0
},
"children": [
{
"type": "CompoundSelector",
"span": {
"start": 3192,
"end": 3193,
"ctxt": 0
},
"nestingSelector": null,
"typeSelector": {
"type": "UniversalSelector",
"span": {
"start": 3192,
"end": 3193,
"ctxt": 0
},
"prefix": null
},
"subclassSelectors": []
}
]
}
]
},
"block": {
"type": "SimpleBlock",
"span": {
"start": 3194,
"end": 3214,
"ctxt": 0
},
"name": {
"type": "PreservedToken",
"span": {
"start": 3194,
"end": 3195,
"ctxt": 0
},
"token": "LBrace"
},
"value": [
{
"type": "Declaration",
"span": {
"start": 3196,
"end": 3211,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 3196,
"end": 3206,
"ctxt": 0
},
"value": "background",
"raw": "background"
},
"value": [
{
"type": "Ident",
"span": {
"start": 3208,
"end": 3211,
"ctxt": 0
},
"value": "red",
"raw": "red"
}
],
"important": null
}
]
}
}
]
}
}
]
}

View File

@ -143,7 +143,15 @@
140 | | div {
141 | | background: red;
142 | | }
143 | `-> }
143 | | }
144 | |
145 | | @supports (func("example": 1)) {
146 | | * { background: red; }
147 | | }
148 | |
149 | | @supports (--var) {
150 | | * { background: red; }
151 | `-> }
`----
x Rule
@ -9802,3 +9810,411 @@
141 | background: red;
: ^^^
`----
x Rule
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | ,-> @supports (func("example": 1)) {
146 | | * { background: red; }
147 | `-> }
`----
x AtRule
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | ,-> @supports (func("example": 1)) {
146 | | * { background: red; }
147 | `-> }
`----
x AtRuleName
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^
`----
x SupportsCondition
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^^^^^^^^^^^^^
`----
x SupportsConditionType
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^^^^^^^^^^^
`----
x SupportsInParens
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^^^^^^^^^^^
`----
x SupportsCondition
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^^^^^^^^^^^
`----
x Function
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^^^^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^^
`----
x String { value: Atom('example' type=inline), raw: Atom('"example"' type=dynamic) }
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^^^^^^^^^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^
`----
x Colon
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^
`----
x WhiteSpace { value: Atom(' ' type=inline) }
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^
`----
x Number { value: 1.0, raw: Atom('1' type=inline), type_flag: Integer }
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^
`----
x SimpleBlock
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | ,-> @supports (func("example": 1)) {
146 | | * { background: red; }
147 | `-> }
`----
x LBrace
,-[$DIR/tests/fixture/at-rule/supports/input.css:145:1]
145 | @supports (func("example": 1)) {
: ^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^^^^^^^^^^^^^
`----
x Rule
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^^^^^^^^^^^^^
`----
x QualifiedRule
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^^^^^^^^^^^^^
`----
x SelectorList
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^
`----
x ComplexSelector
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^
`----
x CompoundSelector
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^
`----
x TypeSelector
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^
`----
x UniversalSelector
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^
`----
x SimpleBlock
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^^^^^^^^^^^
`----
x LBrace
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^^^^^^
`----
x StyleBlock
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^^^^^^
`----
x Declaration
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^^^^^^
`----
x DeclarationName
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^^^^^^^^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/supports/input.css:146:5]
146 | * { background: red; }
: ^^^
`----
x Rule
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | ,-> @supports (--var) {
150 | | * { background: red; }
151 | `-> }
`----
x AtRule
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | ,-> @supports (--var) {
150 | | * { background: red; }
151 | `-> }
`----
x AtRuleName
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^^^^^^^^
`----
x SupportsCondition
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^^^^^^^
`----
x SupportsConditionType
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^^^^^^^
`----
x SupportsInParens
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^^^^^^^
`----
x SimpleBlock
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^^^^^^^
`----
x LParen
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^^^^^
`----
x Ident { value: Atom('--var' type=inline), raw: Atom('--var' type=inline) }
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^^^^^
`----
x SimpleBlock
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | ,-> @supports (--var) {
150 | | * { background: red; }
151 | `-> }
`----
x LBrace
,-[$DIR/tests/fixture/at-rule/supports/input.css:149:1]
149 | @supports (--var) {
: ^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^^^^^^^^^^^^^
`----
x Rule
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^^^^^^^^^^^^^
`----
x QualifiedRule
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^^^^^^^^^^^^^
`----
x SelectorList
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^
`----
x ComplexSelector
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^
`----
x CompoundSelector
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^
`----
x TypeSelector
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^
`----
x UniversalSelector
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^
`----
x SimpleBlock
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^^^^^^^^^^^
`----
x LBrace
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^^^^^^
`----
x StyleBlock
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^^^^^^
`----
x Declaration
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^^^^^^
`----
x DeclarationName
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^^^^^^^^
`----
x ComponentValue
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/supports/input.css:150:5]
150 | * { background: red; }
: ^^^
`----

View File

@ -1,3 +1,29 @@
table {
color: \red;
}
a {
background: url("a).png");
background: url(a;a);
background: url(a/*);
background: \;a;
}
:not([foo=")"]) { }
:not(div/*)*/) { }
:not(:nth-child(2n of [foo=")"])) { }
[foo=\"] { }
[foo=\{] { }
[foo=\(] { }
[foo=yes\:\(it\'s\ work\)] { }
\@noat { }
h1\\{
color: \\;
}
[attr="\;"] { }
.prop {
\62 olor: red
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
@supports (--element(".minwidth", { "minWidth": 300 })) {
[--self] {
background: greenyellow;
}
}
@supports ({"example": 1}) {
* { background: red; }
}
@supports (("example": 1)) {
* { background: red; }
}
@supports ([]) {
* { background: red; }
}
@supports ([color: red]) {
* { background: red; }
}
@supports ([[[[[{ --func(color: { red }) }]]]]]) {
* { background: red; }
}

View File

@ -0,0 +1,30 @@
x Expected ident token at first position in <general-enclosed>
,-[$DIR/tests/recovery/at-rule/supports/non-standard-prelude/input.css:7:1]
7 | @supports ({"example": 1}) {
: ^^^^^^^^^^^^^^^^
`----
x Expected ident token at first position in <general-enclosed>
,-[$DIR/tests/recovery/at-rule/supports/non-standard-prelude/input.css:11:1]
11 | @supports (("example": 1)) {
: ^^^^^^^^^^^^^^^^
`----
x Expected ident token at first position in <general-enclosed>
,-[$DIR/tests/recovery/at-rule/supports/non-standard-prelude/input.css:15:1]
15 | @supports ([]) {
: ^^^^
`----
x Expected ident token at first position in <general-enclosed>
,-[$DIR/tests/recovery/at-rule/supports/non-standard-prelude/input.css:19:1]
19 | @supports ([color: red]) {
: ^^^^^^^^^^^^^^
`----
x Expected ident token at first position in <general-enclosed>
,-[$DIR/tests/recovery/at-rule/supports/non-standard-prelude/input.css:23:1]
23 | @supports ([[[[[{ --func(color: { red }) }]]]]]) {
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----