Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable calc function specs #1934

Merged
merged 5 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions spec/css/plain/error/expression/calculation.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ Error: Module namespaces aren't allowed in plain CSS.
a {b: calc(#%^&)}

<===> line_noise/error
Error: Expected number, variable, function, or calculation.
Error: Expected identifier.
,
1 | a {b: calc(#%^&)}
| ^
| ^
'
plain.css 1:12 @use
plain.css 1:13 @use
input.scss 1:1 root stylesheet

<===>
Expand All @@ -73,10 +73,10 @@ Error: Expected number, variable, function, or calculation.
a {b: calc()}

<===> wrong_args/error
Error: Expected number, variable, function, or calculation.
Error: Missing argument.
,
1 | a {b: calc()}
| ^
| ^^^^^^
'
plain.css 1:12 @use
plain.css 1:7 @use
input.scss 1:1 root stylesheet
12 changes: 6 additions & 6 deletions spec/css/plain/error/expression/list.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ a {
}

<===> empty/error
Error: Parentheses aren't allowed in plain CSS.
Error: Expected expression.
,
2 | x: ();
| ^
| ^
'
plain.css 2:6 @import
plain.css 2:7 @import
input.scss 1:9 root stylesheet

<===>
Expand All @@ -24,10 +24,10 @@ a {
}

<===> empty_comma/error
Error: Parentheses aren't allowed in plain CSS.
Error: Expected expression.
,
2 | x: (,);
| ^
| ^
'
plain.css 2:6 @import
plain.css 2:7 @import
input.scss 1:9 root stylesheet
6 changes: 3 additions & 3 deletions spec/css/plain/error/expression/map.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ a {
}

<===> error
Error: Parentheses aren't allowed in plain CSS.
Error: expected ")".
,
2 | x: (y: z);
| ^
| ^
'
plain.css 2:6 @import
plain.css 2:8 @import
input.scss 1:9 root stylesheet
2 changes: 1 addition & 1 deletion spec/css/plain/error/expression/parentheses.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ a {
Error: Parentheses aren't allowed in plain CSS.
,
2 | x: (y);
| ^
| ^^^
'
plain.css 2:6 @import
input.scss 1:9 root stylesheet
8 changes: 4 additions & 4 deletions spec/libsass-closed-issues/issue_246.hrx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<===> options.yml
---
:warning_todo:
- sass/libsass#2887
:ignore_for:
- libsass

<===> input.scss
$content-width: 960px;
Expand All @@ -18,12 +18,12 @@ $content-width: 960px;
<===> output.css
/* demo.css: */
.selector {
padding: 0 calc(100%/2 - 480px);
padding: 0 calc(50% - 480px);
}

/* bin/sassc demo.scss */
.selector {
padding: 0 calc(100%/2 - 480px);
padding: 0 calc(50% - 480px);
}

<===> warning
Expand Down
43 changes: 43 additions & 0 deletions spec/operators/modulo.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<===> options.yml
:ignore_for:
- libsass

<===>
================================================================================
<===> degenerate/modulus/infinity/positive_and_positive/input.scss
a {b: 1px % calc(infinity * 1px)}

<===> degenerate/modulus/infinity/positive_and_positive/output.css
a {
b: 1px;
}

<===>
================================================================================
<===> degenerate/modulus/infinity/positive_and_negative/input.scss
a {b: 1px % calc(-infinity * 1px)}

<===> degenerate/modulus/infinity/positive_and_negative/output.css
a {
b: calc(NaN * 1px);
}

<===>
================================================================================
<===> degenerate/modulus/infinity/negative_and_negative/input.scss
a {b: -1px % calc(-infinity * 1px)}

<===> degenerate/modulus/infinity/negative_and_negative/output.css
a {
b: -1px;
}

<===>
================================================================================
<===> degenerate/modulus/infinity/negative_and_positive/input.scss
a {b: -1px % calc(infinity * 1px)}

<===> degenerate/modulus/infinity/negative_and_positive/output.css
a {
b: calc(NaN * 1px);
}
42 changes: 29 additions & 13 deletions spec/values/calculation/abs.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,38 @@ b {

<===> math/slash_as_division/warning
DEPRECATION WARNING: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div(2px, abs(1.5)) or calc(2px / abs(1.5))

More info and automated migrator: https://sass-lang.com/d/slash-div

,
2 | a: 2px / abs(1.5);
| ^^^^^^^^^^^^^^
'
input.scss 2:6 root stylesheet

<===>
================================================================================
<===> case_insensitive/input.scss
a {b: AbS(-2)}

<===> case_insensitive/output.css
a {
b: 2;
}

<===>
================================================================================
<===> overridden/input.scss
@function abs($arg) {@return $arg}
a {b: abs(-2)}

<===> overridden/output.css
a {
b: -2;
}

<===>
================================================================================
<===> error/sass_script_and_variable/input.scss
Expand Down Expand Up @@ -150,14 +174,10 @@ Error: $number: "0" is not a number.
a {b: abs()}

<===> error/too_few_args/error
Error: Missing argument $number.
,--> input.scss
Error: Missing argument.
,
1 | a {b: abs()}
| ^^^^^ invocation
'
,--> sass:math
1 | @function abs($number) {
| ============ declaration
| ^^^^^
'
input.scss 1:7 root stylesheet

Expand All @@ -168,13 +188,9 @@ a {b: abs(1, 2)}

<===> error/too_many_args/error
Error: Only 1 argument allowed, but 2 were passed.
,--> input.scss
,
1 | a {b: abs(1, 2)}
| ^^^^^^^^^ invocation
'
,--> sass:math
1 | @function abs($number) {
| ============ declaration
| ^^^^^^^^^
'
input.scss 1:7 root stylesheet

Expand Down
39 changes: 30 additions & 9 deletions spec/values/calculation/acos.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ a {
b: acos(2px + var(--c));
}

<===>
================================================================================
<===> case_insensitive/input.scss
a {b: AcOs(1)}

<===> case_insensitive/output.css
a {
b: 0deg;
}

<===>
================================================================================
<===> overridden/input.scss
@function acos($arg) {@return $arg}
a {b: acos(1)}

<===> overridden/output.css
a {
b: 1;
}

<===>
================================================================================
<===> error/unit/unknown/input.scss
Expand Down Expand Up @@ -109,10 +130,10 @@ Error: Expected -1.75px/em to have no units.
a {b: acos("0")}

<===> error/type/error
Error: Expected number, variable, function, or calculation.
Error: This expression can't be used in a calculation.
,
1 | a {b: acos("0")}
| ^
| ^^^
'
input.scss 1:12 root stylesheet

Expand All @@ -122,25 +143,25 @@ Error: Expected number, variable, function, or calculation.
a {b: acos()}

<===> error/too_few_args/error
Error: Expected number, variable, function, or calculation.
Error: Missing argument.
,
1 | a {b: acos()}
| ^
| ^^^^^^
'
input.scss 1:12 root stylesheet
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> error/too_many_args/input.scss
a {b: acos(0, 0)}

<===> error/too_many_args/error
Error: expected "+", "-", "*", "/", or ")".
Error: Only 1 argument allowed, but 2 were passed.
,
1 | a {b: acos(0, 0)}
| ^
| ^^^^^^^^^^
'
input.scss 1:13 root stylesheet
input.scss 1:7 root stylesheet

<===>
================================================================================
Expand All @@ -161,7 +182,7 @@ Error: Expected identifier.
a {b: acos(7 % 3)}

<===> error/sass_script/error
Error: expected "+", "-", "*", "/", or ")".
Error: This operation can't be used in a calculation.
,
1 | a {b: acos(7 % 3)}
| ^
Expand Down
39 changes: 30 additions & 9 deletions spec/values/calculation/asin.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ a {
b: asin(2px + var(--c));
}

<===>
================================================================================
<===> case_insensitive/input.scss
a {b: aSiN(1)}

<===> case_insensitive/output.css
a {
b: 90deg;
}

<===>
================================================================================
<===> overridden/input.scss
@function asin($arg) {@return $arg}
a {b: asin(1)}

<===> overridden/output.css
a {
b: 1;
}

<===>
================================================================================
<===> error/unit/unknown/input.scss
Expand Down Expand Up @@ -109,10 +130,10 @@ Error: Expected -1.75px/em to have no units.
a {b: asin("0")}

<===> error/type/error
Error: Expected number, variable, function, or calculation.
Error: This expression can't be used in a calculation.
,
1 | a {b: asin("0")}
| ^
| ^^^
'
input.scss 1:12 root stylesheet

Expand All @@ -122,25 +143,25 @@ Error: Expected number, variable, function, or calculation.
a {b: asin()}

<===> error/too_few_args/error
Error: Expected number, variable, function, or calculation.
Error: Missing argument.
,
1 | a {b: asin()}
| ^
| ^^^^^^
'
input.scss 1:12 root stylesheet
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> error/too_many_args/input.scss
a {b: asin(0, 0)}

<===> error/too_many_args/error
Error: expected "+", "-", "*", "/", or ")".
Error: Only 1 argument allowed, but 2 were passed.
,
1 | a {b: asin(0, 0)}
| ^
| ^^^^^^^^^^
'
input.scss 1:13 root stylesheet
input.scss 1:7 root stylesheet

<===>
================================================================================
Expand All @@ -161,7 +182,7 @@ Error: Expected identifier.
a {b: asin(7 % 3)}

<===> error/sass_script/error
Error: expected "+", "-", "*", "/", or ")".
Error: This operation can't be used in a calculation.
,
1 | a {b: asin(7 % 3)}
| ^
Expand Down
Loading