test(css/parser): Add malformed hex color tests (#3762)

This commit is contained in:
Pig Fang 2022-02-27 15:16:35 +08:00 committed by GitHub
parent 752edf80bc
commit 9f90882b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 307 additions and 11 deletions

View File

@ -10,4 +10,8 @@ a {
color: #0000; color: #0000;
color: #ffff; color: #ffff;
color: #FFFF; color: #FFFF;
color: #1;
color: #FF;
color: #123456789;
color: #xyz;
} }

View File

@ -2,7 +2,7 @@
"type": "Stylesheet", "type": "Stylesheet",
"span": { "span": {
"start": 0, "start": 0,
"end": 193, "end": 256,
"ctxt": 0 "ctxt": 0
}, },
"rules": [ "rules": [
@ -10,7 +10,7 @@
"type": "QualifiedRule", "type": "QualifiedRule",
"span": { "span": {
"start": 0, "start": 0,
"end": 192, "end": 255,
"ctxt": 0 "ctxt": 0
}, },
"prelude": { "prelude": {
@ -74,7 +74,7 @@
"type": "SimpleBlock", "type": "SimpleBlock",
"span": { "span": {
"start": 2, "start": 2,
"end": 192, "end": 255,
"ctxt": 0 "ctxt": 0
}, },
"name": "{", "name": "{",
@ -419,6 +419,130 @@
} }
], ],
"important": null "important": null
},
{
"type": "Declaration",
"span": {
"start": 193,
"end": 202,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 193,
"end": 198,
"ctxt": 0
},
"value": "color",
"raw": "color"
},
"value": [
{
"type": "HexColor",
"span": {
"start": 200,
"end": 202,
"ctxt": 0
},
"value": "1",
"raw": "1"
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 206,
"end": 216,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 206,
"end": 211,
"ctxt": 0
},
"value": "color",
"raw": "color"
},
"value": [
{
"type": "HexColor",
"span": {
"start": 213,
"end": 216,
"ctxt": 0
},
"value": "FF",
"raw": "FF"
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 220,
"end": 237,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 220,
"end": 225,
"ctxt": 0
},
"value": "color",
"raw": "color"
},
"value": [
{
"type": "HexColor",
"span": {
"start": 227,
"end": 237,
"ctxt": 0
},
"value": "123456789",
"raw": "123456789"
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 241,
"end": 252,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 241,
"end": 246,
"ctxt": 0
},
"value": "color",
"raw": "color"
},
"value": [
{
"type": "HexColor",
"span": {
"start": 248,
"end": 252,
"ctxt": 0
},
"value": "xyz",
"raw": "xyz"
}
],
"important": null
} }
] ]
} }

View File

@ -6,8 +6,8 @@ error: Stylesheet
3 | | color: #ffffff; 3 | | color: #ffffff;
4 | | color: #FFFFFF; 4 | | color: #FFFFFF;
... | ... |
12 | | color: #FFFF; 16 | | color: #xyz;
13 | | } 17 | | }
| |__^ | |__^
error: Rule error: Rule
@ -18,8 +18,8 @@ error: Rule
3 | | color: #ffffff; 3 | | color: #ffffff;
4 | | color: #FFFFFF; 4 | | color: #FFFFFF;
... | ... |
12 | | color: #FFFF; 16 | | color: #xyz;
13 | | } 17 | | }
| |_^ | |_^
error: QualifiedRule error: QualifiedRule
@ -30,8 +30,8 @@ error: QualifiedRule
3 | | color: #ffffff; 3 | | color: #ffffff;
4 | | color: #FFFFFF; 4 | | color: #FFFFFF;
... | ... |
12 | | color: #FFFF; 16 | | color: #xyz;
13 | | } 17 | | }
| |_^ | |_^
error: SelectorList error: SelectorList
@ -85,8 +85,8 @@ error: SimpleBlock
3 | | color: #ffffff; 3 | | color: #ffffff;
4 | | color: #FFFFFF; 4 | | color: #FFFFFF;
... | ... |
12 | | color: #FFFF; 16 | | color: #xyz;
13 | | } 17 | | }
| |_^ | |_^
error: StyleBlock error: StyleBlock
@ -551,3 +551,171 @@ error: HexColor
12 | color: #FFFF; 12 | color: #FFFF;
| ^^^^^ | ^^^^^
error: StyleBlock
--> $DIR/tests/fixture/hex-colors/input.css:13:3
|
13 | color: #1;
| ^^^^^^^^^
error: Declaration
--> $DIR/tests/fixture/hex-colors/input.css:13:3
|
13 | color: #1;
| ^^^^^^^^^
error: DeclarationName
--> $DIR/tests/fixture/hex-colors/input.css:13:3
|
13 | color: #1;
| ^^^^^
error: Ident
--> $DIR/tests/fixture/hex-colors/input.css:13:3
|
13 | color: #1;
| ^^^^^
error: Value
--> $DIR/tests/fixture/hex-colors/input.css:13:10
|
13 | color: #1;
| ^^
error: Color
--> $DIR/tests/fixture/hex-colors/input.css:13:10
|
13 | color: #1;
| ^^
error: HexColor
--> $DIR/tests/fixture/hex-colors/input.css:13:10
|
13 | color: #1;
| ^^
error: StyleBlock
--> $DIR/tests/fixture/hex-colors/input.css:14:3
|
14 | color: #FF;
| ^^^^^^^^^^
error: Declaration
--> $DIR/tests/fixture/hex-colors/input.css:14:3
|
14 | color: #FF;
| ^^^^^^^^^^
error: DeclarationName
--> $DIR/tests/fixture/hex-colors/input.css:14:3
|
14 | color: #FF;
| ^^^^^
error: Ident
--> $DIR/tests/fixture/hex-colors/input.css:14:3
|
14 | color: #FF;
| ^^^^^
error: Value
--> $DIR/tests/fixture/hex-colors/input.css:14:10
|
14 | color: #FF;
| ^^^
error: Color
--> $DIR/tests/fixture/hex-colors/input.css:14:10
|
14 | color: #FF;
| ^^^
error: HexColor
--> $DIR/tests/fixture/hex-colors/input.css:14:10
|
14 | color: #FF;
| ^^^
error: StyleBlock
--> $DIR/tests/fixture/hex-colors/input.css:15:3
|
15 | color: #123456789;
| ^^^^^^^^^^^^^^^^^
error: Declaration
--> $DIR/tests/fixture/hex-colors/input.css:15:3
|
15 | color: #123456789;
| ^^^^^^^^^^^^^^^^^
error: DeclarationName
--> $DIR/tests/fixture/hex-colors/input.css:15:3
|
15 | color: #123456789;
| ^^^^^
error: Ident
--> $DIR/tests/fixture/hex-colors/input.css:15:3
|
15 | color: #123456789;
| ^^^^^
error: Value
--> $DIR/tests/fixture/hex-colors/input.css:15:10
|
15 | color: #123456789;
| ^^^^^^^^^^
error: Color
--> $DIR/tests/fixture/hex-colors/input.css:15:10
|
15 | color: #123456789;
| ^^^^^^^^^^
error: HexColor
--> $DIR/tests/fixture/hex-colors/input.css:15:10
|
15 | color: #123456789;
| ^^^^^^^^^^
error: StyleBlock
--> $DIR/tests/fixture/hex-colors/input.css:16:3
|
16 | color: #xyz;
| ^^^^^^^^^^^
error: Declaration
--> $DIR/tests/fixture/hex-colors/input.css:16:3
|
16 | color: #xyz;
| ^^^^^^^^^^^
error: DeclarationName
--> $DIR/tests/fixture/hex-colors/input.css:16:3
|
16 | color: #xyz;
| ^^^^^
error: Ident
--> $DIR/tests/fixture/hex-colors/input.css:16:3
|
16 | color: #xyz;
| ^^^^^
error: Value
--> $DIR/tests/fixture/hex-colors/input.css:16:10
|
16 | color: #xyz;
| ^^^^
error: Color
--> $DIR/tests/fixture/hex-colors/input.css:16:10
|
16 | color: #xyz;
| ^^^^
error: HexColor
--> $DIR/tests/fixture/hex-colors/input.css:16:10
|
16 | color: #xyz;
| ^^^^