Skip to content

Commit

Permalink
Add tests for calc-size()
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Nov 27, 2024
1 parent 3c196da commit 27b2365
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions spec/values/calculation/calc-size.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<===> README.md
Most of the same behavior tested for `calc()` applies to `calc-size()`, but for
terseness' sake isn't tested explicitly.

<===>
================================================================================
<===> one_arg/input.scss
a {b: calc-size(var(--foo))}

<===> one_arg/output.css
a {
b: calc-size(var(--foo));
}

<===>
================================================================================
<===> unsimplified/input.scss
a {b: calc-size(auto, 5% - 20px + size)}

<===> unsimplified/output.css
a {
b: calc-size(auto, 5% - 20px + size);
}

<===>
================================================================================
<===> simplified/input.scss
a {b: calc-size(auto, 100px - 20px + size)}

<===> simplified/output.css
a {
b: calc-size(auto, 80px + size);
}

<===>
================================================================================
<===> case_insensitive/input.scss
a {b: CaLc-size(auto, size - 20px)}

<===> case_insensitive/output.css
a {
b: calc-size(auto, size - 20px);
}

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

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

<===>
================================================================================
<===> error/too_few_args/input.scss
a {b: calc-size()}

<===> error/too_few_args/error
Error: Missing argument.
,
1 | a {b: calc-size()}
| ^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> error/too_many_args/input.scss
a {b: calc-size(auto, 0, 0)}

<===> error/too_many_args/error
Error: Only 2 arguments allowed, but 3 were passed.
,
1 | a {b: calc-size(auto, 0, 0)}
| ^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===>
================================================================================
<===> error/syntax/invalid_arg/input.scss
a {b: calc-size(auto, $)}

<===> error/syntax/invalid_arg/error
Error: Expected identifier.
,
1 | a {b: calc-size(auto, $)}
| ^
'
input.scss 1:24 root stylesheet

<===>
================================================================================
<===> error/sass_script/input.scss
a {b: calc-size(auto, 7 % 3)}

<===> error/sass_script/error
Error: This operation can't be used in a calculation.
,
1 | a {b: calc-size(auto, 7 % 3)}
| ^
'
input.scss 1:25 root stylesheet

0 comments on commit 27b2365

Please sign in to comment.