Skip to content

Commit 778f262

Browse files
committed
Merge JSON data for color tests.
2 parents b021271 + 86f81ae commit 778f262

File tree

6 files changed

+5182
-22
lines changed

6 files changed

+5182
-22
lines changed

css-parsing-tests/README.rst

Lines changed: 139 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
Importing into another repository with git-subtree_
2-
===================================================
1+
CSS parsing tests
2+
#################
33

4-
.. _git-subtree: https://github.com/apenwarr/git-subtree
4+
This repository contains implementation-independent test for CSS parsers,
5+
based on the 2013 draft of the `CSS Syntax Level 3`_ specification.
6+
7+
.. _CSS Syntax Level 3: http://dev.w3.org/csswg/css-syntax-3/
8+
9+
The upstream repository for these tests is at
10+
https://github.com/SimonSapin/css-parsing-tests
11+
12+
13+
Importing
14+
=========
15+
16+
The recommended way to use these tests in an implementation
17+
is to import them with git-subtree_.
18+
19+
.. _git-subtree: https://github.com/git/git/tree/master/contrib/subtree
520

621
To import the first time to a ``./css-parsing-tests`` sub-directory,
722
run this from the top-level of a git repository::
@@ -13,6 +28,81 @@ Later, to merge changes made in the upstream repository, run::
1328
git subtree pull -P css-parsing-tests https://github.com/SimonSapin/css-parsing-tests.git master
1429

1530

31+
Test files
32+
==========
33+
34+
CSS Syntax specification describes a number of "functions".
35+
Each ``.json`` file in this repository corresponds to such a function.
36+
The files are encoded as UTF-8
37+
and each contain a JSON array with an even number of items,
38+
where each pair of items is one function input
39+
associated with the expected result.
40+
41+
``component_value_list.json``
42+
Tests `Parse a list of component values
43+
<http://dev.w3.org/csswg/css-syntax-3/#parse-a-list-of-component-values>`_.
44+
The Unicode input is represented by a JSON string,
45+
the output as an array of `component values`_ as described below.
46+
47+
``component_value_list.json``
48+
Tests `Parse a component value
49+
<http://dev.w3.org/csswg/css-syntax-3/#parse-a-component-value>`_.
50+
The Unicode input is represented by a JSON string,
51+
the output as a `component value`_.
52+
53+
``declaration_list.json``
54+
Tests `Parse a list of declarations
55+
<http://dev.w3.org/csswg/css-syntax-3/#parse-a-list-of-declarations>`_.
56+
The Unicode input is represented by a JSON string,
57+
the output as an array of declarations_ and at-rules_.
58+
59+
``one_declaration.json``
60+
Tests `Parse a declaration
61+
<http://dev.w3.org/csswg/css-syntax-3/#parse-a-declaration>`_.
62+
The Unicode input is represented by a JSON string,
63+
the output as a declaration_.
64+
65+
``one_rule.json``
66+
Tests `Parse a rule
67+
<http://dev.w3.org/csswg/css-syntax-3/#parse-a-rule>`_.
68+
The Unicode input is represented by a JSON string,
69+
the output as a `qualified rule`_ or at-rule_.
70+
71+
``rule_list.json``
72+
Tests `Parse a list of rules
73+
<http://dev.w3.org/csswg/css-syntax-3/#parse-a-list-of-rules>`_.
74+
The Unicode input is represented by a JSON string,
75+
the output as a list of `qualified rules`_ or at-rules_.
76+
77+
``stylesheet.json``
78+
Tests `Parse a stylesheet
79+
<http://dev.w3.org/csswg/css-syntax-3/#parse-a-stylesheet>`_.
80+
The Unicode input is represented by a JSON string,
81+
the output as a list of `qualified rules`_ or at-rules_.
82+
83+
``color3.json``
84+
Tests the ``<color>`` syntax `defined in CSS Color Level 3
85+
<http://www.w3.org/TR/css3-color/#colorunits>`_.
86+
The Unicode input is represented by a JSON string,
87+
the output as one of:
88+
89+
* null if the input is not a valid color in CSS syntax
90+
* The string "currentColor" for the currentColor keyword
91+
* An array of length 4 for every other values:
92+
four (floating point) numbers for the Red, Green, Blue and Alpha channel.
93+
Each value is between 0 and 1.
94+
95+
``color3_hsl.json``
96+
Same as ``color3.json``.
97+
This file is generated the ``make_color3_hsl.py`` Python script.
98+
99+
``color3_keywords.json``
100+
Same as ``color3.json``,
101+
except that the values for the Red, Green and Blue channel
102+
are between 0 and 255.
103+
This file is generated the ``make_color3_keywords.py`` Python script.
104+
105+
16106
Result representation
17107
=====================
18108

@@ -25,6 +115,38 @@ they are represented as ``["at-keyword", "import"]`` and ``["ident", "@import"]`
25115
respectively.
26116

27117

118+
Rules and declarations
119+
----------------------
120+
121+
.. _at-rule:
122+
.. _at-rules:
123+
.. _qualified rule:
124+
.. _qualified rules:
125+
.. _declaration:
126+
.. _declarations:
127+
128+
129+
At-rule
130+
An array of length 4: the string ``"at-rule"``,
131+
the name (value of the at-keyword) as a string,
132+
the prelude as a nested array of `component values`_,
133+
and the optional block as a nested array of component value, or null.
134+
135+
Qualified rule
136+
An array of length 3: the string ``"qualified rule"``,
137+
the prelude as a nested array of `component values`_,
138+
and the block as a nested array of component value.
139+
140+
141+
Declaration
142+
An array of length 4: the string ``"declaration"``, the name as a string,
143+
the value as a nested array of `component values`_,
144+
and a the important flag as a boolean.
145+
146+
147+
.. _component value:
148+
.. _component values:
149+
28150
Component values
29151
----------------
30152

@@ -108,37 +230,32 @@ Component values
108230

109231
{} block
110232
An array of length N+1: the string ``"{}"``
111-
followed by the N component values of the block’s value.
233+
followed by the N `component values`_ of the block’s content.
112234

113235
[] block
114236
An array of length N+1: the string ``"[]"``
115-
followed by the N component values of the block’s value.
237+
followed by the N `component values`_ of the block’s content.
116238

117239
() block
118240
An array of length N+1: the string ``"()"``
119-
followed by the N component values of the block’s value.
241+
followed by the N `component values`_ of the block’s content.
120242

121243
Function
122244
An array of length N+2: the string ``"function"``
123245
and the name of the function as a string
124-
followed by the N component values of the function’s value.
246+
followed by the N `component values`_ of the function’s arguments.
125247

248+
<bad-string>
249+
The array of two strings ``["error", "bad-string"]``.
126250

127-
Other nodes
128-
-----------
251+
<bad-url>
252+
The array of two strings ``["error", "bad-url"]``.
129253

130-
Declaration
131-
An array of length 4: the string ``"declaration"``, the name as a string,
132-
the value as a nested array of component values,
133-
and a the important flag as a boolean.
254+
Unmatched <}>
255+
The array of two strings ``["error", "}"]``.
134256

135-
At-rule
136-
An array of length 4: the string ``"at-rule"``,
137-
the name (value of the at-keyword) as a string,
138-
the prelude as a nested array of component values,
139-
and the optional block as a nested array of component value, or null.
257+
Unmatched <]>
258+
The array of two strings ``["error", "]"]``.
140259

141-
Qualified rule
142-
An array of length 3: the string ``"qualified rule"``,
143-
the prelude as a nested array of component values,
144-
and the block as a nested array of component value.
260+
Unmatched <)>
261+
The array of two strings ``["error", ")"]``.

css-parsing-tests/color3.json

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
[
2+
"", null,
3+
" /* hey */\n", null,
4+
"4", null,
5+
"top", null,
6+
"/**/transparent", [0, 0, 0, 0],
7+
"transparent", [0, 0, 0, 0],
8+
" transparent\n", [0, 0, 0, 0],
9+
"TransParent", [0, 0, 0, 0],
10+
"currentColor", "currentColor",
11+
"CURRENTcolor", "currentColor",
12+
"current-Color", null,
13+
14+
"black", [0, 0, 0, 1],
15+
"white", [1, 1, 1, 1],
16+
"fuchsia", [1, 0, 1, 1],
17+
"cyan", [0, 1, 1, 1],
18+
"CyAn", [0, 1, 1, 1],
19+
20+
"#", null,
21+
"#f", null,
22+
"#ff", null,
23+
"#fff", [1, 1, 1, 1],
24+
"#ffg", null,
25+
"#ffff", null,
26+
"#fffff", null,
27+
"#ffffff", [1, 1, 1, 1],
28+
"#fffffg", null,
29+
"#fffffff", null,
30+
"#ffffffff", null,
31+
"#fffffffff", null,
32+
33+
"#FFCc99", [1, 0.8, 0.6, 1],
34+
"#369", [0.2, 0.4, 0.6, 1],
35+
36+
"rgb(00, 51, 102)", [0, 0.2, 0.4, 1],
37+
"r\\gb(00, 51, 102)", [0, 0.2, 0.4, 1],
38+
"r\\67 b(00, 51, 102)", [0, 0.2, 0.4, 1],
39+
"RGB(153, 204, 255)", [0.6, 0.8, 1, 1],
40+
"rgB(0, 0, 0)", [0, 0, 0, 1],
41+
"rgB(0, 51, 255)", [0, 0.2, 1, 1],
42+
"rgb(0,51,255)", [0, 0.2, 1, 1],
43+
"rgb(0\t, 51 ,255)", [0, 0.2, 1, 1],
44+
"rgb(/* R */0, /* G */51, /* B */255)", [0, 0.2, 1, 1],
45+
"rgb(-51, 306, 0)", [-0.2, 1.2, 0, 1],
46+
47+
"rgb(42%, 3%, 50%)", [0.42, 0.03, 0.5, 1],
48+
"RGB(100%, 100%, 100%)", [1, 1, 1, 1],
49+
"rgB(0%, 0%, 0%)", [0, 0, 0, 1],
50+
"rgB(10%, 20%, 30%)", [0.1, 0.2, 0.3, 1],
51+
"rgb(10%,20%,30%)", [0.1, 0.2, 0.3, 1],
52+
"rgb(10%\t, 20% ,30%)", [0.1, 0.2, 0.3, 1],
53+
"rgb(/* R */ 10%, /* G */ 20%, /* B */ 30%)", [0.1, 0.2, 0.3, 1],
54+
"rgb(-12%, 110%, 1400%)", [-0.12, 1.1, 14, 1],
55+
56+
"rgb(10%, 50%, 0)", null,
57+
"rgb(255, 50%, 0%)", null,
58+
"rgb(0, 0 0)", null,
59+
"rgb(0, 0, 0deg)", null,
60+
"rgb(0, 0, light)", null,
61+
"rgb()", null,
62+
"rgb(0)", null,
63+
"rgb(0, 0)", null,
64+
"rgb(0, 0, 0, 0)", null,
65+
"rgb(0%)", null,
66+
"rgb(0%, 0%)", null,
67+
"rgb(0%, 0%, 0%, 0%)", null,
68+
"rgb(0%, 0%, 0%, 0)", null,
69+
70+
"rgba(0, 0, 0, 0)", [0, 0, 0, 0],
71+
"rgba(204, 0, 102, 0.3)", [0.8, 0, 0.4, 0.3],
72+
"RGBA(255, 255, 255, 0)", [1, 1, 1, 0],
73+
"rgBA(0, 51, 255, 1)", [0, 0.2, 1, 1],
74+
"rgba(0, 51, 255, 1.1)", [0, 0.2, 1, 1],
75+
"rgba(0, 51, 255, 37)", [0, 0.2, 1, 1],
76+
"rgba(0, 51, 255, 0.42)", [0, 0.2, 1, 0.42],
77+
"rgba(0, 51, 255, 0)", [0, 0.2, 1, 0],
78+
"rgba(0, 51, 255, -0.1)", [0, 0.2, 1, 0],
79+
"rgba(0, 51, 255, -139)", [0, 0.2, 1, 0],
80+
81+
"rgba(42%, 3%, 50%, 0.3)", [0.42, 0.03, 0.5, 0.3],
82+
"RGBA(100%, 100%, 100%, 0)", [1, 1, 1, 0],
83+
"rgBA(0%, 20%, 100%, 1)", [0, 0.2, 1, 1],
84+
"rgba(0%, 20%, 100%, 1.1)", [0, 0.2, 1, 1],
85+
"rgba(0%, 20%, 100%, 37)", [0, 0.2, 1, 1],
86+
"rgba(0%, 20%, 100%, 0.42)", [0, 0.2, 1, 0.42],
87+
"rgba(0%, 20%, 100%, 0)", [0, 0.2, 1, 0],
88+
"rgba(0%, 20%, 100%, -0.1)", [0, 0.2, 1, 0],
89+
"rgba(0%, 20%, 100%, -139)", [0, 0.2, 1, 0],
90+
91+
"rgba(255, 255, 255, 0%)", null,
92+
"rgba(10%, 50%, 0, 1)", null,
93+
"rgba(255, 50%, 0%, 1)", null,
94+
"rgba(0, 0, 0 0)", null,
95+
"rgba(0, 0, 0, 0deg)", null,
96+
"rgba(0, 0, 0, light)", null,
97+
"rgba()", null,
98+
"rgba(0)", null,
99+
"rgba(0, 0, 0)", null,
100+
"rgba(0, 0, 0, 0, 0)", null,
101+
"rgba(0%)", null,
102+
"rgba(0%, 0%)", null,
103+
"rgba(0%, 0%, 0%)", null,
104+
"rgba(0%, 0%, 0%, 0%)", null,
105+
"rgba(0%, 0%, 0%, 0%, 0%)", null,
106+
107+
"HSL(0, 0%, 0%)", [0, 0, 0, 1],
108+
"hsL(0, 100%, 50%)", [1, 0, 0, 1],
109+
"hsl(60, 100%, 37.5%)", [0.75, 0.75, 0, 1],
110+
"hsl(780, 100%, 37.5%)", [0.75, 0.75, 0, 1],
111+
"hsl(-300, 100%, 37.5%)", [0.75, 0.75, 0, 1],
112+
"hsl(300, 50%, 50%)", [0.75, 0.25, 0.75, 1],
113+
114+
"hsl(10, 50%, 0)", null,
115+
"hsl(50%, 50%, 0%)", null,
116+
"hsl(0, 0% 0%)", null,
117+
"hsl(30deg, 100%, 100%)", null,
118+
"hsl(0, 0%, light)", null,
119+
"hsl()", null,
120+
"hsl(0)", null,
121+
"hsl(0, 0%)", null,
122+
"hsl(0, 0%, 0%, 0%)", null,
123+
124+
"HSLA(-300, 100%, 37.5%, 1)", [0.75, 0.75, 0, 1],
125+
"hsLA(-300, 100%, 37.5%, 12)", [0.75, 0.75, 0, 1],
126+
"hsla(-300, 100%, 37.5%, 0.2)", [0.75, 0.75, 0, 0.2],
127+
"hsla(-300, 100%, 37.5%, 0)", [0.75, 0.75, 0, 0],
128+
"hsla(-300, 100%, 37.5%, -3)", [0.75, 0.75, 0, 0],
129+
130+
"hsla(10, 50%, 0, 1)", null,
131+
"hsla(50%, 50%, 0%, 1)", null,
132+
"hsla(0, 0% 0%, 1)", null,
133+
"hsla(30deg, 100%, 100%, 1)", null,
134+
"hsla(0, 0%, light, 1)", null,
135+
"hsla()", null,
136+
"hsla(0)", null,
137+
"hsla(0, 0%)", null,
138+
"hsla(0, 0%, 0%, 50%)", null,
139+
"hsla(0, 0%, 0%, 1, 0%)", null,
140+
141+
"cmyk(0, 0, 0, 0)", null
142+
]

0 commit comments

Comments
 (0)