Skip to content

Commit 40aa2b3

Browse files
authored
Update tests for strict function unit deprecations (#1830)
See #1813 See sass/sass#3374
1 parent df67c75 commit 40aa2b3

File tree

14 files changed

+390
-58
lines changed

14 files changed

+390
-58
lines changed

spec/core_functions/color/adjust_color/error/bounds.hrx

+18-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ a {b: adjust-color(red, $saturation: 200px)}
243243
<===> saturation/unit/error
244244
DEPRECATION WARNING: $saturation: Passing a number without unit % (200px) is deprecated.
245245

246-
To preserve current behavior: $saturation / 1px * 1%
246+
To preserve current behavior: calc($saturation / 1px * 1%)
247+
248+
More info: https://sass-lang.com/d/function-units
247249

248250
,
249251
3 | a {b: adjust-color(red, $saturation: 200px)}
@@ -318,7 +320,9 @@ a {b: adjust-color(red, $lightness: 200px)}
318320
<===> lightness/unit/error
319321
DEPRECATION WARNING: $lightness: Passing a number without unit % (200px) is deprecated.
320322

321-
To preserve current behavior: $lightness / 1px * 1%
323+
To preserve current behavior: calc($lightness / 1px * 1%)
324+
325+
More info: https://sass-lang.com/d/function-units
322326

323327
,
324328
3 | a {b: adjust-color(red, $lightness: 200px)}
@@ -391,6 +395,18 @@ Error: argument `$alpha` of `adjust-color($color, $red: false, $green: false, $b
391395
a {b: adjust-color(red, $alpha: 50%)}
392396

393397
<===> alpha/unit/error
398+
DEPRECATION WARNING: $alpha: Passing a number with unit % is deprecated.
399+
400+
To preserve current behavior: calc($alpha / 1%)
401+
402+
More info: https://sass-lang.com/d/function-units
403+
404+
,
405+
3 | a {b: adjust-color(red, $alpha: 50%)}
406+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
407+
'
408+
input.scss 3:7 root stylesheet
409+
394410
Error: $alpha: Expected 50% to be within -1 and 1.
395411
,
396412
3 | a {b: adjust-color(red, $alpha: 50%)}

spec/core_functions/color/adjust_color/units.hrx

+68-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ a {
3636
<===> hue/unknown/warning
3737
DEPRECATION WARNING: $hue: Passing a unit other than deg (60in) is deprecated.
3838

39-
To preserve current behavior: $hue / 1in
39+
To preserve current behavior: calc($hue / 1in)
4040

4141
See https://sass-lang.com/d/color-units
4242

@@ -62,7 +62,7 @@ DEPRECATION WARNING: $hue: Passing a unit other than deg (60rad) is deprecated.
6262
You're passing 60rad, which is currently (incorrectly) converted to 60deg.
6363
Soon, it will instead be correctly converted to 3437.7467707849deg.
6464

65-
To preserve current behavior: $hue * 1deg/1rad
65+
To preserve current behavior: calc($hue * 1deg/1rad)
6666
To migrate to new behavior: 0deg + $hue
6767

6868
See https://sass-lang.com/d/color-units
@@ -98,6 +98,8 @@ DEPRECATION WARNING: $saturation: Passing a number without unit % (-10) is depre
9898

9999
To preserve current behavior: $saturation * 1%
100100

101+
More info: https://sass-lang.com/d/function-units
102+
101103
,
102104
1 | a {b: adjust-color(red, $saturation: -10)}
103105
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -117,7 +119,9 @@ a {
117119
<===> saturation/unknown/warning
118120
DEPRECATION WARNING: $saturation: Passing a number without unit % (-10in) is deprecated.
119121

120-
To preserve current behavior: $saturation / 1in * 1%
122+
To preserve current behavior: calc($saturation / 1in * 1%)
123+
124+
More info: https://sass-lang.com/d/function-units
121125

122126
,
123127
1 | a {b: adjust-color(red, $saturation: -10in)}
@@ -150,6 +154,8 @@ DEPRECATION WARNING: $lightness: Passing a number without unit % (10) is depreca
150154

151155
To preserve current behavior: $lightness * 1%
152156

157+
More info: https://sass-lang.com/d/function-units
158+
153159
,
154160
1 | a {b: adjust-color(red, $lightness: 10)}
155161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -169,10 +175,68 @@ a {
169175
<===> lightness/unknown/warning
170176
DEPRECATION WARNING: $lightness: Passing a number without unit % (10in) is deprecated.
171177

172-
To preserve current behavior: $lightness / 1in * 1%
178+
To preserve current behavior: calc($lightness / 1in * 1%)
179+
180+
More info: https://sass-lang.com/d/function-units
173181

174182
,
175183
1 | a {b: adjust-color(red, $lightness: 10in)}
176184
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177185
'
178186
input.scss 1:7 root stylesheet
187+
188+
<===>
189+
================================================================================
190+
<===> alpha/unitless/input.scss
191+
a {b: adjust-color(red, $alpha: -0.3)}
192+
193+
<===> alpha/unitless/output.css
194+
a {
195+
b: rgba(255, 0, 0, 0.7);
196+
}
197+
198+
<===>
199+
================================================================================
200+
<===> alpha/percent/input.scss
201+
a {b: adjust-color(red, $alpha: -0.3%)}
202+
203+
<===> alpha/percent/output.css
204+
a {
205+
b: rgba(255, 0, 0, 0.7);
206+
}
207+
208+
<===> alpha/percent/warning
209+
DEPRECATION WARNING: $alpha: Passing a number with unit % is deprecated.
210+
211+
To preserve current behavior: calc($alpha / 1%)
212+
213+
More info: https://sass-lang.com/d/function-units
214+
215+
,
216+
1 | a {b: adjust-color(red, $alpha: -0.3%)}
217+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
218+
'
219+
input.scss 1:7 root stylesheet
220+
221+
<===>
222+
================================================================================
223+
<===> alpha/unknown/input.scss
224+
a {b: adjust-color(red, $alpha: -0.3px)}
225+
226+
<===> alpha/unknown/output.css
227+
a {
228+
b: rgba(255, 0, 0, 0.7);
229+
}
230+
231+
<===> alpha/unknown/warning
232+
DEPRECATION WARNING: $alpha: Passing a number with unit px is deprecated.
233+
234+
To preserve current behavior: calc($alpha / 1px)
235+
236+
More info: https://sass-lang.com/d/function-units
237+
238+
,
239+
1 | a {b: adjust-color(red, $alpha: -0.3px)}
240+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
241+
'
242+
input.scss 1:7 root stylesheet

spec/core_functions/color/adjust_hue.hrx

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ a {
116116
<===> units/unknown/warning
117117
DEPRECATION WARNING: $degrees: Passing a unit other than deg (60in) is deprecated.
118118

119-
To preserve current behavior: $degrees / 1in
119+
To preserve current behavior: calc($degrees / 1in)
120120

121121
See https://sass-lang.com/d/color-units
122122

@@ -142,7 +142,7 @@ DEPRECATION WARNING: $degrees: Passing a unit other than deg (60rad) is deprecat
142142
You're passing 60rad, which is currently (incorrectly) converted to 60deg.
143143
Soon, it will instead be correctly converted to 3437.7467707849deg.
144144

145-
To preserve current behavior: $degrees * 1deg/1rad
145+
To preserve current behavior: calc($degrees * 1deg/1rad)
146146
To migrate to new behavior: 0deg + $degrees
147147

148148
See https://sass-lang.com/d/color-units

spec/core_functions/color/change_color/error/bounds.hrx

+18-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ a {b: change-color(red, $saturation: 200px)}
243243
<===> saturation/unit/error
244244
DEPRECATION WARNING: $saturation: Passing a number without unit % (200px) is deprecated.
245245

246-
To preserve current behavior: $saturation / 1px * 1%
246+
To preserve current behavior: calc($saturation / 1px * 1%)
247+
248+
More info: https://sass-lang.com/d/function-units
247249

248250
,
249251
3 | a {b: change-color(red, $saturation: 200px)}
@@ -318,7 +320,9 @@ a {b: change-color(red, $lightness: 200px)}
318320
<===> lightness/unit/error
319321
DEPRECATION WARNING: $lightness: Passing a number without unit % (200px) is deprecated.
320322

321-
To preserve current behavior: $lightness / 1px * 1%
323+
To preserve current behavior: calc($lightness / 1px * 1%)
324+
325+
More info: https://sass-lang.com/d/function-units
322326

323327
,
324328
3 | a {b: change-color(red, $lightness: 200px)}
@@ -391,6 +395,18 @@ Error: argument `$alpha` of `change-color($color, $red: false, $green: false, $b
391395
a {b: change-color(red, $alpha: 50%)}
392396

393397
<===> alpha/unit/error
398+
DEPRECATION WARNING: $alpha: Passing a number with unit % is deprecated.
399+
400+
To preserve current behavior: calc($alpha / 1%)
401+
402+
More info: https://sass-lang.com/d/function-units
403+
404+
,
405+
3 | a {b: change-color(red, $alpha: 50%)}
406+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
407+
'
408+
input.scss 3:7 root stylesheet
409+
394410
Error: $alpha: Expected 50% to be within 0 and 1.
395411
,
396412
3 | a {b: change-color(red, $alpha: 50%)}

spec/core_functions/color/change_color/units.hrx

+68-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ a {
3636
<===> hue/unknown/warning
3737
DEPRECATION WARNING: $hue: Passing a unit other than deg (60in) is deprecated.
3838

39-
To preserve current behavior: $hue / 1in
39+
To preserve current behavior: calc($hue / 1in)
4040

4141
See https://sass-lang.com/d/color-units
4242

@@ -62,7 +62,7 @@ DEPRECATION WARNING: $hue: Passing a unit other than deg (60rad) is deprecated.
6262
You're passing 60rad, which is currently (incorrectly) converted to 60deg.
6363
Soon, it will instead be correctly converted to 3437.7467707849deg.
6464

65-
To preserve current behavior: $hue * 1deg/1rad
65+
To preserve current behavior: calc($hue * 1deg/1rad)
6666
To migrate to new behavior: 0deg + $hue
6767

6868
See https://sass-lang.com/d/color-units
@@ -98,6 +98,8 @@ DEPRECATION WARNING: $saturation: Passing a number without unit % (50) is deprec
9898

9999
To preserve current behavior: $saturation * 1%
100100

101+
More info: https://sass-lang.com/d/function-units
102+
101103
,
102104
1 | a {b: change-color(red, $saturation: 50)}
103105
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -117,7 +119,9 @@ a {
117119
<===> saturation/unknown/warning
118120
DEPRECATION WARNING: $saturation: Passing a number without unit % (50in) is deprecated.
119121

120-
To preserve current behavior: $saturation / 1in * 1%
122+
To preserve current behavior: calc($saturation / 1in * 1%)
123+
124+
More info: https://sass-lang.com/d/function-units
121125

122126
,
123127
1 | a {b: change-color(red, $saturation: 50in)}
@@ -150,6 +154,8 @@ DEPRECATION WARNING: $lightness: Passing a number without unit % (30) is depreca
150154

151155
To preserve current behavior: $lightness * 1%
152156

157+
More info: https://sass-lang.com/d/function-units
158+
153159
,
154160
1 | a {b: change-color(red, $lightness: 30)}
155161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -169,10 +175,68 @@ a {
169175
<===> lightness/unknown/warning
170176
DEPRECATION WARNING: $lightness: Passing a number without unit % (30in) is deprecated.
171177

172-
To preserve current behavior: $lightness / 1in * 1%
178+
To preserve current behavior: calc($lightness / 1in * 1%)
179+
180+
More info: https://sass-lang.com/d/function-units
173181

174182
,
175183
1 | a {b: change-color(red, $lightness: 30in)}
176184
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177185
'
178186
input.scss 1:7 root stylesheet
187+
188+
<===>
189+
================================================================================
190+
<===> alpha/unitless/input.scss
191+
a {b: change-color(red, $alpha: 0.5)}
192+
193+
<===> alpha/unitless/output.css
194+
a {
195+
b: rgba(255, 0, 0, 0.5);
196+
}
197+
198+
<===>
199+
================================================================================
200+
<===> alpha/percent/input.scss
201+
a {b: adjust-color(red, $alpha: 0.5%)}
202+
203+
<===> alpha/percent/output.css
204+
a {
205+
b: red;
206+
}
207+
208+
<===> alpha/percent/warning
209+
DEPRECATION WARNING: $alpha: Passing a number with unit % is deprecated.
210+
211+
To preserve current behavior: calc($alpha / 1%)
212+
213+
More info: https://sass-lang.com/d/function-units
214+
215+
,
216+
1 | a {b: adjust-color(red, $alpha: 0.5%)}
217+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
218+
'
219+
input.scss 1:7 root stylesheet
220+
221+
<===>
222+
================================================================================
223+
<===> alpha/unknown/input.scss
224+
a {b: adjust-color(red, $alpha: 0.5px)}
225+
226+
<===> alpha/unknown/output.css
227+
a {
228+
b: red;
229+
}
230+
231+
<===> alpha/unknown/warning
232+
DEPRECATION WARNING: $alpha: Passing a number with unit px is deprecated.
233+
234+
To preserve current behavior: calc($alpha / 1px)
235+
236+
More info: https://sass-lang.com/d/function-units
237+
238+
,
239+
1 | a {b: adjust-color(red, $alpha: 0.5px)}
240+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
241+
'
242+
input.scss 1:7 root stylesheet

spec/core_functions/color/hsl/one_arg/no_alpha.hrx

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ DEPRECATION WARNING: $saturation: Passing a number without unit % (50) is deprec
9191

9292
To preserve current behavior: $saturation * 1%
9393

94+
More info: https://sass-lang.com/d/function-units
95+
9496
,
9597
1 | a {b: hsl(0 50 50%)}
9698
| ^^^^^^^^^^^^^
@@ -112,6 +114,8 @@ DEPRECATION WARNING: $lightness: Passing a number without unit % (50) is depreca
112114

113115
To preserve current behavior: $lightness * 1%
114116

117+
More info: https://sass-lang.com/d/function-units
118+
115119
,
116120
1 | a {b: hsl(0 100% 50)}
117121
| ^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)