Skip to content

Commit

Permalink
Add tests for CSS round() with one argument (#2037)
Browse files Browse the repository at this point in the history
This also updates tests expect global function warnings when
calculations are falling back on global Sass functions.

See sass/sass#3803
Closes #2036
  • Loading branch information
nex3 authored Nov 15, 2024
1 parent 106cd32 commit 7a0312f
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 13 deletions.
11 changes: 11 additions & 0 deletions spec/values/calculation/abs.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ a {
b: 2px;
}

<===> preserves_single_unit/warning
DEPRECATION WARNING: In future versions of Sass, abs() will be interpreted as the CSS abs() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.abs() instead.

See https://sass-lang.com/d/import

,
1 | a {b: abs(1 + 1px)}
| ^^^^^^^
'
input.scss 1:11 root stylesheet

<===>
================================================================================
<===> sass_script/input.scss
Expand Down
44 changes: 44 additions & 0 deletions spec/values/calculation/max.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ a {
b: 3.4px;
}

<===> simplified/operation/unitless_and_real/warning
DEPRECATION WARNING: In future versions of Sass, max() will be interpreted as the CSS max() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.max() instead.

See https://sass-lang.com/d/import

,
1 | a {b: max(1px, 2.5 + 0.9px)}
| ^^^^^^^^^^^
'
input.scss 1:16 root stylesheet

<===>
================================================================================
<===> preserved/math/first/input.scss
Expand Down Expand Up @@ -292,6 +303,17 @@ a {
b: max(1%, 3.4px);
}

<===> preserved/operation/unitless_and_real/plus/warning
DEPRECATION WARNING: In future versions of Sass, max() will be interpreted as the CSS max() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.max() instead.

See https://sass-lang.com/d/import

,
1 | a {b: max(1%, 2.5 + 0.9px)}
| ^^^^^^^^^^^
'
input.scss 1:15 root stylesheet

<===>
================================================================================
<===> preserved/operation/unitless_and_real/minus/input.scss
Expand All @@ -302,6 +324,17 @@ a {
b: max(1%, 1.6px);
}

<===> preserved/operation/unitless_and_real/minus/warning
DEPRECATION WARNING: In future versions of Sass, max() will be interpreted as the CSS max() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.max() instead.

See https://sass-lang.com/d/import

,
1 | a {b: max(1%, 2.5 - 0.9px)}
| ^^^^^^^^^^^
'
input.scss 1:15 root stylesheet

<===>
================================================================================
<===> preserved/operation/unitless_and_real/in_calc/input.scss
Expand All @@ -312,6 +345,17 @@ a {
b: max(1%, 3.4px);
}

<===> preserved/operation/unitless_and_real/in_calc/warning
DEPRECATION WARNING: In future versions of Sass, max() will be interpreted as the CSS max() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.max() instead.

See https://sass-lang.com/d/import

,
1 | a {b: calc(max(1%, 2.5 + 0.9px))}
| ^^^^^^^^^^^
'
input.scss 1:20 root stylesheet

<===>
================================================================================
<===> math/slash_as_division/input.scss
Expand Down
44 changes: 44 additions & 0 deletions spec/values/calculation/min.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ a {
b: 1px;
}

<===> simplified/operation/unitless_and_real/warning
DEPRECATION WARNING: In future versions of Sass, min() will be interpreted as the CSS min() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.min() instead.

See https://sass-lang.com/d/import

,
1 | a {b: min(1px, 2.5 + 0.9px)}
| ^^^^^^^^^^^
'
input.scss 1:16 root stylesheet

<===>
================================================================================
<===> preserved/math/first/input.scss
Expand Down Expand Up @@ -292,6 +303,17 @@ a {
b: min(1%, 3.4px);
}

<===> preserved/operation/unitless_and_real/plus/warning
DEPRECATION WARNING: In future versions of Sass, min() will be interpreted as the CSS min() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.min() instead.

See https://sass-lang.com/d/import

,
1 | a {b: min(1%, 2.5 + 0.9px)}
| ^^^^^^^^^^^
'
input.scss 1:15 root stylesheet

<===>
================================================================================
<===> preserved/operation/unitless_and_real/minus/input.scss
Expand All @@ -302,6 +324,17 @@ a {
b: min(1%, 1.6px);
}

<===> preserved/operation/unitless_and_real/minus/warning
DEPRECATION WARNING: In future versions of Sass, min() will be interpreted as the CSS min() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.min() instead.

See https://sass-lang.com/d/import

,
1 | a {b: min(1%, 2.5 - 0.9px)}
| ^^^^^^^^^^^
'
input.scss 1:15 root stylesheet

<===>
================================================================================
<===> preserved/operation/unitless_and_real/in_calc/input.scss
Expand All @@ -312,6 +345,17 @@ a {
b: min(1%, 3.4px);
}

<===> preserved/operation/unitless_and_real/in_calc/warning
DEPRECATION WARNING: In future versions of Sass, min() will be interpreted as the CSS min() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.min() instead.

See https://sass-lang.com/d/import

,
1 | a {b: calc(min(1%, 2.5 + 0.9px))}
| ^^^^^^^^^^^
'
input.scss 1:20 root stylesheet

<===>
================================================================================
<===> math/slash_as_division/input.scss
Expand Down
13 changes: 0 additions & 13 deletions spec/values/calculation/round/error.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,6 @@ Error: $number: var(--c) is not a number.
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> one_argument/unsimplifiable/input.scss
a {b: round(1px + 2px - var(--c))}

<===> one_argument/unsimplifiable/error
Error: Single argument 3px - var(--c) expected to be simplifiable.
,
1 | a {b: round(1px + 2px - var(--c))}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> one_argument/type/input.scss
Expand Down
42 changes: 42 additions & 0 deletions spec/values/calculation/round/one_argument.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ a {
b: -2px;
}

<===> preserves_units/warning
DEPRECATION WARNING: In future versions of Sass, round() will be interpreted as a CSS round() calculation. This requires an explicit modulus when rounding numbers with units. If you want to use the Sass function, call math.round() instead.

See https://sass-lang.com/d/import

,
1 | a {b: round(-7px / 4em) * 1em}
| ^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> preserves_single_unit/input.scss
Expand All @@ -52,6 +63,27 @@ a {
b: 2px;
}

<===> preserves_single_unit/warning
DEPRECATION WARNING: In future versions of Sass, round() will be interpreted as the CSS round() calculation. This doesn't allow unitless numbers to be mixed with numbers with units. If you want to use the Sass function, call math.round() instead.

See https://sass-lang.com/d/import

,
1 | a {b: round(1 + 1px)}
| ^^^^^^^
'
input.scss 1:13 root stylesheet

DEPRECATION WARNING: In future versions of Sass, round() will be interpreted as a CSS round() calculation. This requires an explicit modulus when rounding numbers with units. If you want to use the Sass function, call math.round() instead.

See https://sass-lang.com/d/import

,
1 | a {b: round(1 + 1px)}
| ^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> preserved/variable/input.scss
Expand Down Expand Up @@ -128,3 +160,13 @@ a {b: round(1.1)}
a {
b: 1.1;
}

<===>
================================================================================
<===> unsimplifiable/input.scss
a {b: round(1px + 2px - var(--c))}

<===> unsimplifiable/output.css
a {
b: round(3px - var(--c));
}

0 comments on commit 7a0312f

Please sign in to comment.