Skip to content

Commit

Permalink
Update tests for strict function unit deprecations (#1830)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Oct 28, 2022
1 parent df67c75 commit 40aa2b3
Show file tree
Hide file tree
Showing 14 changed files with 390 additions and 58 deletions.
20 changes: 18 additions & 2 deletions spec/core_functions/color/adjust_color/error/bounds.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ a {b: adjust-color(red, $saturation: 200px)}
<===> saturation/unit/error
DEPRECATION WARNING: $saturation: Passing a number without unit % (200px) is deprecated.

To preserve current behavior: $saturation / 1px * 1%
To preserve current behavior: calc($saturation / 1px * 1%)

More info: https://sass-lang.com/d/function-units

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

To preserve current behavior: $lightness / 1px * 1%
To preserve current behavior: calc($lightness / 1px * 1%)

More info: https://sass-lang.com/d/function-units

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

<===> alpha/unit/error
DEPRECATION WARNING: $alpha: Passing a number with unit % is deprecated.

To preserve current behavior: calc($alpha / 1%)

More info: https://sass-lang.com/d/function-units

,
3 | a {b: adjust-color(red, $alpha: 50%)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 3:7 root stylesheet

Error: $alpha: Expected 50% to be within -1 and 1.
,
3 | a {b: adjust-color(red, $alpha: 50%)}
Expand Down
72 changes: 68 additions & 4 deletions spec/core_functions/color/adjust_color/units.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ a {
<===> hue/unknown/warning
DEPRECATION WARNING: $hue: Passing a unit other than deg (60in) is deprecated.

To preserve current behavior: $hue / 1in
To preserve current behavior: calc($hue / 1in)

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

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

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

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

To preserve current behavior: $saturation * 1%

More info: https://sass-lang.com/d/function-units

,
1 | a {b: adjust-color(red, $saturation: -10)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -117,7 +119,9 @@ a {
<===> saturation/unknown/warning
DEPRECATION WARNING: $saturation: Passing a number without unit % (-10in) is deprecated.

To preserve current behavior: $saturation / 1in * 1%
To preserve current behavior: calc($saturation / 1in * 1%)

More info: https://sass-lang.com/d/function-units

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

To preserve current behavior: $lightness * 1%

More info: https://sass-lang.com/d/function-units

,
1 | a {b: adjust-color(red, $lightness: 10)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -169,10 +175,68 @@ a {
<===> lightness/unknown/warning
DEPRECATION WARNING: $lightness: Passing a number without unit % (10in) is deprecated.

To preserve current behavior: $lightness / 1in * 1%
To preserve current behavior: calc($lightness / 1in * 1%)

More info: https://sass-lang.com/d/function-units

,
1 | a {b: adjust-color(red, $lightness: 10in)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> alpha/unitless/input.scss
a {b: adjust-color(red, $alpha: -0.3)}

<===> alpha/unitless/output.css
a {
b: rgba(255, 0, 0, 0.7);
}

<===>
================================================================================
<===> alpha/percent/input.scss
a {b: adjust-color(red, $alpha: -0.3%)}

<===> alpha/percent/output.css
a {
b: rgba(255, 0, 0, 0.7);
}

<===> alpha/percent/warning
DEPRECATION WARNING: $alpha: Passing a number with unit % is deprecated.

To preserve current behavior: calc($alpha / 1%)

More info: https://sass-lang.com/d/function-units

,
1 | a {b: adjust-color(red, $alpha: -0.3%)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> alpha/unknown/input.scss
a {b: adjust-color(red, $alpha: -0.3px)}

<===> alpha/unknown/output.css
a {
b: rgba(255, 0, 0, 0.7);
}

<===> alpha/unknown/warning
DEPRECATION WARNING: $alpha: Passing a number with unit px is deprecated.

To preserve current behavior: calc($alpha / 1px)

More info: https://sass-lang.com/d/function-units

,
1 | a {b: adjust-color(red, $alpha: -0.3px)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet
4 changes: 2 additions & 2 deletions spec/core_functions/color/adjust_hue.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ a {
<===> units/unknown/warning
DEPRECATION WARNING: $degrees: Passing a unit other than deg (60in) is deprecated.

To preserve current behavior: $degrees / 1in
To preserve current behavior: calc($degrees / 1in)

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

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

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

See https://sass-lang.com/d/color-units
Expand Down
20 changes: 18 additions & 2 deletions spec/core_functions/color/change_color/error/bounds.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ a {b: change-color(red, $saturation: 200px)}
<===> saturation/unit/error
DEPRECATION WARNING: $saturation: Passing a number without unit % (200px) is deprecated.

To preserve current behavior: $saturation / 1px * 1%
To preserve current behavior: calc($saturation / 1px * 1%)

More info: https://sass-lang.com/d/function-units

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

To preserve current behavior: $lightness / 1px * 1%
To preserve current behavior: calc($lightness / 1px * 1%)

More info: https://sass-lang.com/d/function-units

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

<===> alpha/unit/error
DEPRECATION WARNING: $alpha: Passing a number with unit % is deprecated.

To preserve current behavior: calc($alpha / 1%)

More info: https://sass-lang.com/d/function-units

,
3 | a {b: change-color(red, $alpha: 50%)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 3:7 root stylesheet

Error: $alpha: Expected 50% to be within 0 and 1.
,
3 | a {b: change-color(red, $alpha: 50%)}
Expand Down
72 changes: 68 additions & 4 deletions spec/core_functions/color/change_color/units.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ a {
<===> hue/unknown/warning
DEPRECATION WARNING: $hue: Passing a unit other than deg (60in) is deprecated.

To preserve current behavior: $hue / 1in
To preserve current behavior: calc($hue / 1in)

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

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

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

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

To preserve current behavior: $saturation * 1%

More info: https://sass-lang.com/d/function-units

,
1 | a {b: change-color(red, $saturation: 50)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -117,7 +119,9 @@ a {
<===> saturation/unknown/warning
DEPRECATION WARNING: $saturation: Passing a number without unit % (50in) is deprecated.

To preserve current behavior: $saturation / 1in * 1%
To preserve current behavior: calc($saturation / 1in * 1%)

More info: https://sass-lang.com/d/function-units

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

To preserve current behavior: $lightness * 1%

More info: https://sass-lang.com/d/function-units

,
1 | a {b: change-color(red, $lightness: 30)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -169,10 +175,68 @@ a {
<===> lightness/unknown/warning
DEPRECATION WARNING: $lightness: Passing a number without unit % (30in) is deprecated.

To preserve current behavior: $lightness / 1in * 1%
To preserve current behavior: calc($lightness / 1in * 1%)

More info: https://sass-lang.com/d/function-units

,
1 | a {b: change-color(red, $lightness: 30in)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> alpha/unitless/input.scss
a {b: change-color(red, $alpha: 0.5)}

<===> alpha/unitless/output.css
a {
b: rgba(255, 0, 0, 0.5);
}

<===>
================================================================================
<===> alpha/percent/input.scss
a {b: adjust-color(red, $alpha: 0.5%)}

<===> alpha/percent/output.css
a {
b: red;
}

<===> alpha/percent/warning
DEPRECATION WARNING: $alpha: Passing a number with unit % is deprecated.

To preserve current behavior: calc($alpha / 1%)

More info: https://sass-lang.com/d/function-units

,
1 | a {b: adjust-color(red, $alpha: 0.5%)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> alpha/unknown/input.scss
a {b: adjust-color(red, $alpha: 0.5px)}

<===> alpha/unknown/output.css
a {
b: red;
}

<===> alpha/unknown/warning
DEPRECATION WARNING: $alpha: Passing a number with unit px is deprecated.

To preserve current behavior: calc($alpha / 1px)

More info: https://sass-lang.com/d/function-units

,
1 | a {b: adjust-color(red, $alpha: 0.5px)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet
4 changes: 4 additions & 0 deletions spec/core_functions/color/hsl/one_arg/no_alpha.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ DEPRECATION WARNING: $saturation: Passing a number without unit % (50) is deprec

To preserve current behavior: $saturation * 1%

More info: https://sass-lang.com/d/function-units

,
1 | a {b: hsl(0 50 50%)}
| ^^^^^^^^^^^^^
Expand All @@ -112,6 +114,8 @@ DEPRECATION WARNING: $lightness: Passing a number without unit % (50) is depreca

To preserve current behavior: $lightness * 1%

More info: https://sass-lang.com/d/function-units

,
1 | a {b: hsl(0 100% 50)}
| ^^^^^^^^^^^^^^
Expand Down
Loading

0 comments on commit 40aa2b3

Please sign in to comment.