Skip to content

Commit 35c1d44

Browse files
authored
Add a few more is-superselector() specs (#1457)
1 parent 838ed5c commit 35c1d44

File tree

3 files changed

+195
-0
lines changed

3 files changed

+195
-0
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<===> super/parent/input.scss
2+
a {b: is-superselector("&", "c")}
3+
4+
<===> super/parent/error
5+
Error: $super: Parent selectors aren't allowed here.
6+
,
7+
1 | &
8+
| ^
9+
'
10+
- 1:1 root stylesheet
11+
,
12+
1 | a {b: is-superselector("&", "c")}
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
'
15+
input.scss 1:7 root stylesheet
16+
17+
<===> super/parent/error-libsass
18+
Error: Parent selectors aren't allowed here.
19+
on line 1:24 of input.scss, in function `is-superselector`
20+
from line 1:7 of input.scss
21+
>> a {b: is-superselector("&", "c")}
22+
23+
-----------------------^
24+
25+
<===>
26+
================================================================================
27+
<===> super/invalid/input.scss
28+
a {b: is-superselector("[c", "d")}
29+
30+
<===> super/invalid/error
31+
Error: $super: expected more input.
32+
,
33+
1 | [c
34+
| ^
35+
'
36+
- 1:3 root stylesheet
37+
,
38+
1 | a {b: is-superselector("[c", "d")}
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
40+
'
41+
input.scss 1:7 root stylesheet
42+
43+
<===> super/invalid/error-libsass
44+
Error: invalid operator in attribute selector for c
45+
on line 1:25 of input.scss, in function `is-superselector`
46+
from line 1:7 of input.scss
47+
>> a {b: is-superselector("[c", "d")}
48+
49+
------------------------^
50+
51+
<===>
52+
================================================================================
53+
<===> super/type/options.yml
54+
---
55+
:todo:
56+
- sass/libsass#2964
57+
58+
<===> super/type/input.scss
59+
a {b: is-superselector(1, "c")}
60+
61+
<===> super/type/error
62+
Error: $super: 1 is not a valid selector: it must be a string,
63+
a list of strings, or a list of lists of strings.
64+
,
65+
1 | a {b: is-superselector(1, "c")}
66+
| ^^^^^^^^^^^^^^^^^^^^^^^^
67+
'
68+
input.scss 1:7 root stylesheet
69+
70+
<===>
71+
================================================================================
72+
<===> sub/parent/input.scss
73+
a {b: is-superselector("c", "&")}
74+
75+
<===> sub/parent/error
76+
Error: $sub: Parent selectors aren't allowed here.
77+
,
78+
1 | &
79+
| ^
80+
'
81+
- 1:1 root stylesheet
82+
,
83+
1 | a {b: is-superselector("c", "&")}
84+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
85+
'
86+
input.scss 1:7 root stylesheet
87+
88+
<===> sub/parent/error-libsass
89+
Error: Parent selectors aren't allowed here.
90+
on line 1:29 of input.scss, in function `is-superselector`
91+
from line 1:7 of input.scss
92+
>> a {b: is-superselector("c", "&")}
93+
94+
----------------------------^
95+
96+
<===>
97+
================================================================================
98+
<===> sub/invalid/input.scss
99+
a {b: is-superselector("c", "[d")}
100+
101+
<===> sub/invalid/error
102+
Error: $sub: expected more input.
103+
,
104+
1 | [d
105+
| ^
106+
'
107+
- 1:3 root stylesheet
108+
,
109+
1 | a {b: is-superselector("c", "[d")}
110+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
111+
'
112+
input.scss 1:7 root stylesheet
113+
114+
<===> sub/invalid/error-libsass
115+
Error: invalid operator in attribute selector for d
116+
on line 1:30 of input.scss, in function `is-superselector`
117+
from line 1:7 of input.scss
118+
>> a {b: is-superselector("c", "[d")}
119+
120+
-----------------------------^
121+
122+
<===>
123+
================================================================================
124+
<===> sub/type/options.yml
125+
---
126+
:todo:
127+
- sass/libsass#2964
128+
129+
<===> sub/type/input.scss
130+
a {b: is-superselector("c", 1)}
131+
132+
<===> sub/type/error
133+
Error: $sub: 1 is not a valid selector: it must be a string,
134+
a list of strings, or a list of lists of strings.
135+
,
136+
1 | a {b: is-superselector("c", 1)}
137+
| ^^^^^^^^^^^^^^^^^^^^^^^^
138+
'
139+
input.scss 1:7 root stylesheet
140+
141+
<===>
142+
================================================================================
143+
<===> too_many_args/input.scss
144+
a {b: is-superselector("c", "d", "e")}
145+
146+
<===> too_many_args/error
147+
Error: Only 2 arguments allowed, but 3 were passed.
148+
,
149+
1 | a {b: is-superselector("c", "d", "e")}
150+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
151+
'
152+
input.scss 1:7 root stylesheet
153+
154+
<===> too_many_args/error-libsass
155+
Error: wrong number of arguments (3 for 2) for `is-superselector'
156+
on line 1:7 of input.scss
157+
>> a {b: is-superselector("c", "d", "e")}
158+
159+
------^
160+
161+
<===>
162+
================================================================================
163+
<===> too_few_args/input.scss
164+
a {b: is-superselector("c")}
165+
166+
<===> too_few_args/error
167+
Error: Missing argument $sub.
168+
,
169+
1 | a {b: is-superselector("c")}
170+
| ^^^^^^^^^^^^^^^^^^^^^
171+
'
172+
input.scss 1:7 root stylesheet
173+
174+
<===> too_few_args/error-libsass
175+
Error: Function is-superselector is missing argument $sub.
176+
on line 1 of input.scss
177+
>> a {b: is-superselector("c")}
178+
179+
------^
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<===> input.scss
2+
// The full set of possible input formats is tested with `selector-parse()`;
3+
// this spec just verifies one example for `is-superselector()`.
4+
a {b: is-superselector((c, d e), (c, d e))}
5+
6+
<===> output.css
7+
a {
8+
b: true;
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<===> input.scss
2+
a {b: is-superselector($super: "c", $sub: "c.d")}
3+
4+
<===> output.css
5+
a {
6+
b: true;
7+
}

0 commit comments

Comments
 (0)