Skip to content

Commit 249287d

Browse files
committed
Update tests for strict function unit deprecations
See #1813 See sass/sass#3374
1 parent df67c75 commit 249287d

File tree

12 files changed

+311
-30
lines changed

12 files changed

+311
-30
lines changed

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ 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%)
247247

248248
,
249249
3 | a {b: adjust-color(red, $saturation: 200px)}
@@ -318,7 +318,7 @@ a {b: adjust-color(red, $lightness: 200px)}
318318
<===> lightness/unit/error
319319
DEPRECATION WARNING: $lightness: Passing a number without unit % (200px) is deprecated.
320320

321-
To preserve current behavior: $lightness / 1px * 1%
321+
To preserve current behavior: calc($lightness / 1px * 1%)
322322

323323
,
324324
3 | a {b: adjust-color(red, $lightness: 200px)}
@@ -391,6 +391,16 @@ Error: argument `$alpha` of `adjust-color($color, $red: false, $green: false, $b
391391
a {b: adjust-color(red, $alpha: 50%)}
392392

393393
<===> alpha/unit/error
394+
WARNING: $alpha: Passing a number with unit % is deprecated.
395+
396+
To preserve current behavior: calc($alpha / 1%)
397+
398+
,
399+
3 | a {b: adjust-color(red, $alpha: 50%)}
400+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
401+
'
402+
input.scss 3:7 root stylesheet
403+
394404
Error: $alpha: Expected 50% to be within -1 and 1.
395405
,
396406
3 | a {b: adjust-color(red, $alpha: 50%)}

spec/core_functions/color/adjust_color/units.hrx

+56-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
@@ -117,7 +117,7 @@ a {
117117
<===> saturation/unknown/warning
118118
DEPRECATION WARNING: $saturation: Passing a number without unit % (-10in) is deprecated.
119119

120-
To preserve current behavior: $saturation / 1in * 1%
120+
To preserve current behavior: calc($saturation / 1in * 1%)
121121

122122
,
123123
1 | a {b: adjust-color(red, $saturation: -10in)}
@@ -169,10 +169,62 @@ a {
169169
<===> lightness/unknown/warning
170170
DEPRECATION WARNING: $lightness: Passing a number without unit % (10in) is deprecated.
171171

172-
To preserve current behavior: $lightness / 1in * 1%
172+
To preserve current behavior: calc($lightness / 1in * 1%)
173173

174174
,
175175
1 | a {b: adjust-color(red, $lightness: 10in)}
176176
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177177
'
178178
input.scss 1:7 root stylesheet
179+
180+
<===>
181+
================================================================================
182+
<===> alpha/unitless/input.scss
183+
a {b: adjust-color(red, $alpha: -0.3)}
184+
185+
<===> alpha/unitless/output.css
186+
a {
187+
b: rgba(255, 0, 0, 0.7);
188+
}
189+
190+
<===>
191+
================================================================================
192+
<===> alpha/percent/input.scss
193+
a {b: adjust-color(red, $alpha: -0.3%)}
194+
195+
<===> alpha/percent/output.css
196+
a {
197+
b: rgba(255, 0, 0, 0.7);
198+
}
199+
200+
<===> alpha/percent/warning
201+
WARNING: $alpha: Passing a number with unit % is deprecated.
202+
203+
To preserve current behavior: calc($alpha / 1%)
204+
205+
,
206+
1 | a {b: adjust-color(red, $alpha: -0.3%)}
207+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208+
'
209+
input.scss 1:7 root stylesheet
210+
211+
<===>
212+
================================================================================
213+
<===> alpha/unknown/input.scss
214+
a {b: adjust-color(red, $alpha: -0.3px)}
215+
216+
<===> alpha/unknown/output.css
217+
a {
218+
b: rgba(255, 0, 0, 0.7);
219+
}
220+
221+
<===> alpha/unknown/warning
222+
WARNING: $alpha: Passing a number with unit px is deprecated.
223+
224+
To preserve current behavior: calc($alpha / 1px)
225+
226+
,
227+
1 | a {b: adjust-color(red, $alpha: -0.3px)}
228+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
229+
'
230+
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

+12-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ 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%)
247247

248248
,
249249
3 | a {b: change-color(red, $saturation: 200px)}
@@ -318,7 +318,7 @@ a {b: change-color(red, $lightness: 200px)}
318318
<===> lightness/unit/error
319319
DEPRECATION WARNING: $lightness: Passing a number without unit % (200px) is deprecated.
320320

321-
To preserve current behavior: $lightness / 1px * 1%
321+
To preserve current behavior: calc($lightness / 1px * 1%)
322322

323323
,
324324
3 | a {b: change-color(red, $lightness: 200px)}
@@ -391,6 +391,16 @@ Error: argument `$alpha` of `change-color($color, $red: false, $green: false, $b
391391
a {b: change-color(red, $alpha: 50%)}
392392

393393
<===> alpha/unit/error
394+
WARNING: $alpha: Passing a number with unit % is deprecated.
395+
396+
To preserve current behavior: calc($alpha / 1%)
397+
398+
,
399+
3 | a {b: change-color(red, $alpha: 50%)}
400+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
401+
'
402+
input.scss 3:7 root stylesheet
403+
394404
Error: $alpha: Expected 50% to be within 0 and 1.
395405
,
396406
3 | a {b: change-color(red, $alpha: 50%)}

spec/core_functions/color/change_color/units.hrx

+56-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
@@ -117,7 +117,7 @@ a {
117117
<===> saturation/unknown/warning
118118
DEPRECATION WARNING: $saturation: Passing a number without unit % (50in) is deprecated.
119119

120-
To preserve current behavior: $saturation / 1in * 1%
120+
To preserve current behavior: calc($saturation / 1in * 1%)
121121

122122
,
123123
1 | a {b: change-color(red, $saturation: 50in)}
@@ -169,10 +169,62 @@ a {
169169
<===> lightness/unknown/warning
170170
DEPRECATION WARNING: $lightness: Passing a number without unit % (30in) is deprecated.
171171

172-
To preserve current behavior: $lightness / 1in * 1%
172+
To preserve current behavior: calc($lightness / 1in * 1%)
173173

174174
,
175175
1 | a {b: change-color(red, $lightness: 30in)}
176176
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177177
'
178178
input.scss 1:7 root stylesheet
179+
180+
<===>
181+
================================================================================
182+
<===> alpha/unitless/input.scss
183+
a {b: change-color(red, $alpha: 0.5)}
184+
185+
<===> alpha/unitless/output.css
186+
a {
187+
b: rgba(255, 0, 0, 0.5);
188+
}
189+
190+
<===>
191+
================================================================================
192+
<===> alpha/percent/input.scss
193+
a {b: adjust-color(red, $alpha: 0.5%)}
194+
195+
<===> alpha/percent/output.css
196+
a {
197+
b: red;
198+
}
199+
200+
<===> alpha/percent/warning
201+
WARNING: $alpha: Passing a number with unit % is deprecated.
202+
203+
To preserve current behavior: calc($alpha / 1%)
204+
205+
,
206+
1 | a {b: adjust-color(red, $alpha: 0.5%)}
207+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208+
'
209+
input.scss 1:7 root stylesheet
210+
211+
<===>
212+
================================================================================
213+
<===> alpha/unknown/input.scss
214+
a {b: adjust-color(red, $alpha: 0.5px)}
215+
216+
<===> alpha/unknown/output.css
217+
a {
218+
b: red;
219+
}
220+
221+
<===> alpha/unknown/warning
222+
WARNING: $alpha: Passing a number with unit px is deprecated.
223+
224+
To preserve current behavior: calc($alpha / 1px)
225+
226+
,
227+
1 | a {b: adjust-color(red, $alpha: 0.5px)}
228+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
229+
'
230+
input.scss 1:7 root stylesheet

spec/core_functions/color/hsl/three_args/units.hrx

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

54-
To preserve current behavior: $hue / 1in
54+
To preserve current behavior: calc($hue / 1in)
5555

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

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

87-
To preserve current behavior: $hue * 1deg/1rad
87+
To preserve current behavior: calc($hue * 1deg/1rad)
8888
To migrate to new behavior: 0deg + $hue
8989

9090
See https://sass-lang.com/d/color-units
@@ -143,7 +143,7 @@ a {
143143
<===> saturation/unknown/warning
144144
DEPRECATION WARNING: $saturation: Passing a number without unit % (50in) is deprecated.
145145

146-
To preserve current behavior: $saturation / 1in * 1%
146+
To preserve current behavior: calc($saturation / 1in * 1%)
147147

148148
,
149149
1 | a {b: hsl(0, 50in, 50%)}
@@ -199,7 +199,7 @@ a {
199199
<===> lightness/unknown/warning
200200
DEPRECATION WARNING: $lightness: Passing a number without unit % (50in) is deprecated.
201201

202-
To preserve current behavior: $lightness / 1in * 1%
202+
To preserve current behavior: calc($lightness / 1in * 1%)
203203

204204
,
205205
1 | a {b: hsl(0, 100%, 50in)}

spec/core_functions/color/hwb/three_args/units.hrx

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ DEPRECATION WARNING: $hue: Passing a unit other than deg (1rad) is deprecated.
2424
You're passing 1rad, which is currently (incorrectly) converted to 1deg.
2525
Soon, it will instead be correctly converted to 57.2957795131deg.
2626

27-
To preserve current behavior: $hue * 1deg/1rad
27+
To preserve current behavior: calc($hue * 1deg/1rad)
2828
To migrate to new behavior: 0deg + $hue
2929

3030
See https://sass-lang.com/d/color-units
@@ -49,7 +49,7 @@ a {
4949
<===> hue/non_angle/warning
5050
DEPRECATION WARNING: $hue: Passing a unit other than deg (1in) is deprecated.
5151

52-
To preserve current behavior: $hue / 1in
52+
To preserve current behavior: calc($hue / 1in)
5353

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

0 commit comments

Comments
 (0)