Skip to content

Commit 9b3c520

Browse files
committed
[Function Name] Add tests
1 parent d80afef commit 9b3c520

File tree

1 file changed

+183
-41
lines changed

1 file changed

+183
-41
lines changed

spec/directives/function/name.hrx

Lines changed: 183 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ b {
2121
<===>
2222
================================================================================
2323
<===> vendor_like_underscore/README.md
24-
Function names like `-moz-calc()` aren't allowed, but they are with underscores.
24+
Function names like `-moz-element()` aren't allowed, but they are with underscores.
2525

2626
<===>
2727
================================================================================
2828
<===> vendor_like_underscore/start/input.scss
29-
@function _moz-calc() {@return 1}
30-
b {c: _moz-calc()}
29+
@function _moz-element() {@return 1}
30+
b {c: _moz-element()}
3131

3232
<===> vendor_like_underscore/start/output.css
3333
b {
@@ -37,8 +37,8 @@ b {
3737
<===>
3838
================================================================================
3939
<===> vendor_like_underscore/middle/input.scss
40-
@function -moz_calc() {@return 1}
41-
b {c: -moz_calc()}
40+
@function -moz_element() {@return 1}
41+
b {c: -moz_element()}
4242

4343
<===> vendor_like_underscore/middle/output.css
4444
b {
@@ -47,36 +47,191 @@ b {
4747

4848
<===>
4949
================================================================================
50-
<===> error/special/calc/input.scss
50+
<===> special/README.md
51+
These used to be errors, but the syntax has since been relaxed to allow them.
52+
See the [function-name proposal] for details.
53+
54+
[function-name proposal]: https://github.com/sass/sass/tree/main/accepted/function-name.md
55+
56+
<===>
57+
================================================================================
58+
<===> special/calc/input.scss
5159
@function calc() {@return 1}
60+
a {b: calc()}
61+
62+
<===> special/calc/output.css
63+
a {
64+
b: 1;
65+
}
66+
67+
<===>
68+
================================================================================
69+
<===> special/clamp/input.scss
70+
@function clamp() {@return 1}
71+
a {b: clamp()}
72+
73+
<===> special/clamp/output.css
74+
a {
75+
b: 1;
76+
}
77+
78+
<===>
79+
================================================================================
80+
<===> special/expression/uppercase/input.scss
81+
@function EXPRESSION() {@return 1}
82+
a {
83+
b: EXPRESSION();
84+
}
85+
86+
<===>
87+
================================================================================
88+
<===> special/expression/prefix/input.scss
89+
@function -a-expression() {@return 1}
90+
b {
91+
c: -a-expression();
92+
}
93+
94+
<===>
95+
================================================================================
96+
<===> special/url/uppercase/input.scss
97+
@function URL() {@return 1}
98+
a {
99+
b: URL();
100+
}
101+
102+
<===>
103+
================================================================================
104+
<===> special/url/prefix/input.scss
105+
@function -a-url() {@return 1}
106+
b {
107+
c: -a-url();
108+
}
109+
110+
<===>
111+
================================================================================
112+
<===> special/and/uppercase/input.scss
113+
@function AND() {@return 1}
114+
a {b: AND()}
115+
116+
<===> special/and/uppercase/output.scss
117+
a {
118+
b: 1;
119+
}
120+
121+
<===>
122+
================================================================================
123+
<===> special/and/prefix/input.scss
124+
@function -a-and() {@return 1}
125+
b {c: -a-and()}
126+
127+
<===> special/and/prefix/output.scss
128+
b {
129+
c: 1;
130+
}
131+
132+
<===>
133+
================================================================================
134+
<===> special/or/uppercase/input.scss
135+
@function OR() {@return 1}
136+
a {b: OR()}
137+
138+
<===> special/or/uppercase/output.scss
139+
a {
140+
b: 1;
141+
}
142+
143+
<===>
144+
================================================================================
145+
<===> special/or/prefix/input.scss
146+
@function -a-or() {@return 1}
147+
b {c: -a-or()}
52148

53-
<===> error/special/calc/error
149+
<===> special/or/prefix/output.scss
150+
b {
151+
c: 1;
152+
}
153+
154+
<===>
155+
================================================================================
156+
<===> special/not/uppercase/input.scss
157+
@function NOT() {@return 1}
158+
a {b: NOT()}
159+
160+
<===> special/not/uppercase/output.scss
161+
a {
162+
b: 1;
163+
}
164+
165+
<===>
166+
================================================================================
167+
<===> special/not/prefix/input.scss
168+
@function -a-not() {@return 1}
169+
b {c: -a-not()}
170+
171+
<===> special/not/prefix/output.scss
172+
b {
173+
c: 1;
174+
}
175+
176+
<===>
177+
================================================================================
178+
<===> special/type/prefix/input.scss
179+
@function -a-type() {@return 1}
180+
b {c: -a-type()}
181+
182+
<===> special/type/prefix/output.css
183+
b {
184+
c: 1;
185+
}
186+
187+
<===>
188+
================================================================================
189+
<===> special/element/no_prefix/uppercase/input.scss
190+
@function ELEMENT() {@return 1}
191+
a {
192+
b: ELEMENT();
193+
}
194+
195+
<===>
196+
================================================================================
197+
<===> special/element/prefix/uppercase/input.scss
198+
@function -A-ELEMENT() {@return 1}
199+
a {
200+
b: -A-ELEMENT();
201+
}
202+
203+
<===>
204+
================================================================================
205+
<===> error/special/element/no_prefix/lowercase/input.scss
206+
@function element() {@return 1}
207+
208+
<===> error/special/element/no_prefix/lowercase/error
54209
Error: Invalid function name.
55210
,
56-
1 | @function calc() {@return 1}
57-
| ^^^^^^^^^^^^^^^^
211+
1 | @function element() {@return 1}
212+
| ^^^^^^^^^^^^^^^^^^^
58213
'
59214
input.scss 1:1 root stylesheet
60215

61216
<===>
62217
================================================================================
63-
<===> error/special/element/input.scss
64-
@function element() {@return 1}
218+
<===> error/special/element/prefix/lowercase/input.scss
219+
@function -a-element() {@return 1}
65220

66-
<===> error/special/element/error
221+
<===> error/special/element/prefix/lowercase/error
67222
Error: Invalid function name.
68223
,
69-
1 | @function element() {@return 1}
70-
| ^^^^^^^^^^^^^^^^^^^
224+
1 | @function -a-element() {@return 1}
225+
| ^^^^^^^^^^^^^^^^^^^^^^
71226
'
72227
input.scss 1:1 root stylesheet
73228

74229
<===>
75230
================================================================================
76-
<===> error/special/expression/input.scss
231+
<===> error/special/expression/no_prefix/lowercase/input.scss
77232
@function expression() {@return 1}
78233

79-
<===> error/special/expression/error
234+
<===> error/special/expression/no_prefix/lowercase/error
80235
Error: Invalid function name.
81236
,
82237
1 | @function expression() {@return 1}
@@ -86,10 +241,10 @@ Error: Invalid function name.
86241

87242
<===>
88243
================================================================================
89-
<===> error/special/url/input.scss
244+
<===> error/special/url/no_prefix/lowercase/input.scss
90245
@function url() {@return 1}
91246

92-
<===> error/special/url/error
247+
<===> error/special/url/no_prefix/lowercase/error
93248
Error: Invalid function name.
94249
,
95250
1 | @function url() {@return 1}
@@ -99,10 +254,10 @@ Error: Invalid function name.
99254

100255
<===>
101256
================================================================================
102-
<===> error/special/and/input.scss
257+
<===> error/special/and/lowercase/input.scss
103258
@function and() {@return 1}
104259

105-
<===> error/special/and/error
260+
<===> error/special/and/lowercase/error
106261
Error: Invalid function name.
107262
,
108263
1 | @function and() {@return 1}
@@ -112,10 +267,10 @@ Error: Invalid function name.
112267

113268
<===>
114269
================================================================================
115-
<===> error/special/or/input.scss
270+
<===> error/special/or/lowercase/input.scss
116271
@function or() {@return 1}
117272

118-
<===> error/special/or/error
273+
<===> error/special/or/lowercase/error
119274
Error: Invalid function name.
120275
,
121276
1 | @function or() {@return 1}
@@ -125,10 +280,10 @@ Error: Invalid function name.
125280

126281
<===>
127282
================================================================================
128-
<===> error/special/not/input.scss
283+
<===> error/special/not/lowercase/input.scss
129284
@function not() {@return 1}
130285

131-
<===> error/special/not/error
286+
<===> error/special/not/lowercase/error
132287
Error: Invalid function name.
133288
,
134289
1 | @function not() {@return 1}
@@ -138,24 +293,11 @@ Error: Invalid function name.
138293

139294
<===>
140295
================================================================================
141-
<===> error/special/clamp/input.scss
142-
@function clamp() {@return 1}
143-
144-
<===> error/special/clamp/error
145-
Error: Invalid function name.
146-
,
147-
1 | @function clamp() {@return 1}
148-
| ^^^^^^^^^^^^^^^^^
149-
'
150-
input.scss 1:1 root stylesheet
151-
152-
<===>
153-
================================================================================
154-
<===> error/special/type/lowercase/input.scss
296+
<===> error/special/type/no_prefix/lowercase/input.scss
155297
@function type() {@return 1}
156298
a {b: type()}
157299

158-
<===> error/special/type/lowercase/error
300+
<===> error/special/type/no_prefix/lowercase/error
159301
Error: This name is reserved for the plain-CSS function.
160302
,
161303
1 | @function type() {@return 1}
@@ -165,11 +307,11 @@ Error: This name is reserved for the plain-CSS function.
165307

166308
<===>
167309
================================================================================
168-
<===> error/special/type/uppercase/input.scss
310+
<===> error/special/type/no_prefix/uppercase/input.scss
169311
@function TYPE() {@return 1}
170312
a {b: TYPE()}
171313

172-
<===> error/special/type/uppercase/error
314+
<===> error/special/type/no_prefix/uppercase/error
173315
Error: This name is reserved for the plain-CSS function.
174316
,
175317
1 | @function TYPE() {@return 1}

0 commit comments

Comments
 (0)