From 7d6231e3bd7bbf09fce0a8cdae43b9d96614e22b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 30 Aug 2023 14:19:29 -0700 Subject: [PATCH 1/5] Revert "Revert "Calc functions tests (#1912)" (#1931)" This reverts commit 790ec468f44f1c3902fb4361f9f09a31756a3247. --- spec/core_functions/math/abs.hrx | 70 ++-- spec/core_functions/math/round.hrx | 73 ++-- spec/values/calculation/abs.hrx | 192 +++++++++ spec/values/calculation/acos.hrx | 169 ++++++++ spec/values/calculation/asin.hrx | 169 ++++++++ spec/values/calculation/atan.hrx | 146 +++++++ spec/values/calculation/atan2.hrx | 212 ++++++++++ spec/values/calculation/cos.hrx | 189 +++++++++ spec/values/calculation/exp.hrx | 147 +++++++ spec/values/calculation/hypot.hrx | 247 ++++++++++++ spec/values/calculation/log.hrx | 248 ++++++++++++ spec/values/calculation/max.hrx | 46 ++- spec/values/calculation/min.hrx | 70 ++-- spec/values/calculation/mod.hrx | 374 +++++++++++++++++ spec/values/calculation/pow.hrx | 190 +++++++++ spec/values/calculation/rem.hrx | 376 ++++++++++++++++++ spec/values/calculation/round/error.hrx | 250 ++++++++++++ .../values/calculation/round/one_argument.hrx | 97 +++++ .../calculation/round/strategy/README.md | 5 + .../calculation/round/strategy/down.hrx | 188 +++++++++ .../calculation/round/strategy/nearest.hrx | 227 +++++++++++ .../calculation/round/strategy/to-zero.hrx | 127 ++++++ spec/values/calculation/round/strategy/up.hrx | 187 +++++++++ .../calculation/round/three_arguments.hrx | 59 +++ .../calculation/round/two_arguments.hrx | 321 +++++++++++++++ spec/values/calculation/sign.hrx | 152 +++++++ spec/values/calculation/sin.hrx | 199 +++++++++ spec/values/calculation/sqrt.hrx | 136 +++++++ spec/values/calculation/tan.hrx | 199 +++++++++ 29 files changed, 4976 insertions(+), 89 deletions(-) create mode 100644 spec/values/calculation/abs.hrx create mode 100644 spec/values/calculation/acos.hrx create mode 100644 spec/values/calculation/asin.hrx create mode 100644 spec/values/calculation/atan.hrx create mode 100644 spec/values/calculation/atan2.hrx create mode 100644 spec/values/calculation/cos.hrx create mode 100644 spec/values/calculation/exp.hrx create mode 100644 spec/values/calculation/hypot.hrx create mode 100644 spec/values/calculation/log.hrx create mode 100644 spec/values/calculation/mod.hrx create mode 100644 spec/values/calculation/pow.hrx create mode 100644 spec/values/calculation/rem.hrx create mode 100644 spec/values/calculation/round/error.hrx create mode 100644 spec/values/calculation/round/one_argument.hrx create mode 100644 spec/values/calculation/round/strategy/README.md create mode 100644 spec/values/calculation/round/strategy/down.hrx create mode 100644 spec/values/calculation/round/strategy/nearest.hrx create mode 100644 spec/values/calculation/round/strategy/to-zero.hrx create mode 100644 spec/values/calculation/round/strategy/up.hrx create mode 100644 spec/values/calculation/round/three_arguments.hrx create mode 100644 spec/values/calculation/round/two_arguments.hrx create mode 100644 spec/values/calculation/sign.hrx create mode 100644 spec/values/calculation/sin.hrx create mode 100644 spec/values/calculation/sqrt.hrx create mode 100644 spec/values/calculation/tan.hrx diff --git a/spec/core_functions/math/abs.hrx b/spec/core_functions/math/abs.hrx index 545d0fc1ce..faaf3ec470 100644 --- a/spec/core_functions/math/abs.hrx +++ b/spec/core_functions/math/abs.hrx @@ -1,5 +1,13 @@ +<===> options.yml +--- +:ignore_for: +- libsass + +<===> +================================================================================ <===> zero/input.scss -a {b: abs(0)} +@use "sass:math"; +a {b: math.abs(0)} <===> zero/output.css a { @@ -9,7 +17,8 @@ a { <===> ================================================================================ <===> positive/integer/input.scss -a {b: abs(1)} +@use "sass:math"; +a {b: math.abs(1)} <===> positive/integer/output.css a { @@ -19,7 +28,8 @@ a { <===> ================================================================================ <===> positive/decimal/input.scss -a {b: abs(5.6)} +@use "sass:math"; +a {b: math.abs(5.6)} <===> positive/decimal/output.css a { @@ -29,7 +39,8 @@ a { <===> ================================================================================ <===> negative/integer/input.scss -a {b: abs(-17)} +@use "sass:math"; +a {b: math.abs(-17)} <===> negative/integer/output.css a { @@ -39,7 +50,8 @@ a { <===> ================================================================================ <===> negative/decimal/input.scss -a {b: abs(-123.456)} +@use "sass:math"; +a {b: math.abs(-123.456)} <===> negative/decimal/output.css a { @@ -53,7 +65,8 @@ a { - sass/libsass#2887 <===> preserves_units/input.scss -a {b: abs(-7px / 4em) * 1em} +@use "sass:math"; +a {b: math.abs(-7px / 4em) * 1em} <===> preserves_units/output.css a { @@ -68,15 +81,16 @@ Recommendation: math.div(-7px, 4em) More info and automated migrator: https://sass-lang.com/d/slash-div , -1 | a {b: abs(-7px / 4em) * 1em} - | ^^^^^^^^^^ +2 | a {b: math.abs(-7px / 4em) * 1em} + | ^^^^^^^^^^ ' - input.scss 1:11 root stylesheet + input.scss 2:16 root stylesheet <===> ================================================================================ <===> named/input.scss -a {b: abs($number: -3)} +@use "sass:math"; +a { b: math.abs($number: 3)} <===> named/output.css a { @@ -86,69 +100,71 @@ a { <===> ================================================================================ <===> error/type/input.scss -a {b: abs(c)} +@use "sass:math"; +a {b: math.abs(c)} <===> error/type/error Error: $number: c is not a number. , -1 | a {b: abs(c)} - | ^^^^^^ +2 | a {b: math.abs(c)} + | ^^^^^^^^^^^ ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> error/type/error-libsass -Error: argument `$number` of `abs($number)` must be a number +Error: argument `$number` of `math.abs($number)` must be a number on line 1:7 of input.scss, in function `round` from line 1:7 of input.scss ->> a {b: abs(c)} +>> a {b: math.abs(c)} ------^ <===> ================================================================================ <===> error/too_few_args/input.scss -a {b: abs()} +@use "sass:math"; +a {b: math.abs()} <===> error/too_few_args/error Error: Missing argument $number. ,--> input.scss -1 | a {b: abs()} - | ^^^^^ invocation +2 | a {b: math.abs()} + | ^^^^^^^^^^ invocation ' ,--> sass:math 1 | @function abs($number) { | ============ declaration ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> error/too_few_args/error-libsass Error: Function abs is missing argument $number. on line 1 of input.scss ->> a {b: abs()} +>> a {b: math.abs()} ------^ <===> ================================================================================ <===> error/too_many_args/input.scss -a {b: abs(1, 2)} - +@use "sass:math"; +a {b: math.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 +2 | a {b: math.abs(1, 2)} + | ^^^^^^^^^^^^^^ invocation ' ,--> sass:math 1 | @function abs($number) { | ============ declaration ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> error/too_many_args/error-libsass Error: wrong number of arguments (2 for 1) for `abs' on line 1:7 of input.scss ->> a {b: abs(1, 2)} +>> a {b: math.abs(1, 2)} ------^ diff --git a/spec/core_functions/math/round.hrx b/spec/core_functions/math/round.hrx index 4bf6350445..e448d16d16 100644 --- a/spec/core_functions/math/round.hrx +++ b/spec/core_functions/math/round.hrx @@ -1,5 +1,13 @@ +<===> options.yml +--- +:ignore_for: +- libsass + +<===> +================================================================================ <===> integer/input.scss -a {b: round(1)} +@use "sass:math"; +a {b: math.round(1)} <===> integer/output.css a { @@ -9,7 +17,8 @@ a { <===> ================================================================================ <===> up/high/input.scss -a {b: round(2.9)} +@use "sass:math"; +a {b: math.round(2.9)} <===> up/high/output.css a { @@ -19,7 +28,8 @@ a { <===> ================================================================================ <===> up/point_five/input.scss -a {b: round(16.5)} +@use "sass:math"; +a {b: math.round(16.5)} <===> up/point_five/output.css a { @@ -29,7 +39,8 @@ a { <===> ================================================================================ <===> up/negative/input.scss -a {b: round(-5.4)} +@use "sass:math"; +a {b: math.round(-5.4)} <===> up/negative/output.css a { @@ -39,7 +50,8 @@ a { <===> ================================================================================ <===> up/to_zero/input.scss -a {b: round(-0.2)} +@use "sass:math"; +a {b: math.round(-0.2)} <===> up/to_zero/output.css a { @@ -49,7 +61,8 @@ a { <===> ================================================================================ <===> down/low/input.scss -a {b: round(2.2)} +@use "sass:math"; +a {b: math.round(2.2)} <===> down/low/output.css a { @@ -59,7 +72,8 @@ a { <===> ================================================================================ <===> down/negative/input.scss -a {b: round(-5.6)} +@use "sass:math"; +a {b: math.round(-5.6)} <===> down/negative/output.css a { @@ -69,7 +83,8 @@ a { <===> ================================================================================ <===> down/to_zero/input.scss -a {b: round(0.2)} +@use "sass:math"; +a {b: math.round(0.2)} <===> down/to_zero/output.css a { @@ -85,7 +100,8 @@ a { <===> down/within_precision/input.scss // This is the largest number that's representable as a float and outside the // precision range to be considered equal to 1.5. -a {b: round(1.4999999999949998)} +@use "sass:math"; +a {b: math.round(1.4999999999949998)} <===> down/within_precision/output.css a { @@ -99,7 +115,8 @@ a { - sass/libsass#2887 <===> preserves_units/input.scss -a {b: round(7px / 4em) * 1em} +@use "sass:math"; +a {b: math.round(7px / 4em) * 1em} <===> preserves_units/output.css a { @@ -114,15 +131,16 @@ Recommendation: math.div(7px, 4em) More info and automated migrator: https://sass-lang.com/d/slash-div , -1 | a {b: round(7px / 4em) * 1em} - | ^^^^^^^^^ +2 | a {b: math.round(7px / 4em) * 1em} + | ^^^^^^^^^ ' - input.scss 1:13 root stylesheet + input.scss 2:18 root stylesheet <===> ================================================================================ <===> named/input.scss -a {b: round($number: 1.6)} +@use "sass:math"; +a {b: math.round($number: 1.6)} <===> named/output.css a { @@ -132,15 +150,16 @@ a { <===> ================================================================================ <===> error/type/input.scss -a {b: round(c)} +@use "sass:math"; +a {b: math.round(c)} <===> error/type/error Error: $number: c is not a number. , -1 | a {b: round(c)} - | ^^^^^^^^ +2 | a {b: math.round(c)} + | ^^^^^^^^^^^^^ ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> error/type/error-libsass Error: argument `$number` of `round($number)` must be a number @@ -153,19 +172,20 @@ Error: argument `$number` of `round($number)` must be a number <===> ================================================================================ <===> error/too_few_args/input.scss -a {b: round()} +@use "sass:math"; +a {b: math.round()} <===> error/too_few_args/error Error: Missing argument $number. ,--> input.scss -1 | a {b: round()} - | ^^^^^^^ invocation +2 | a {b: math.round()} + | ^^^^^^^^^^^^ invocation ' ,--> sass:math 1 | @function round($number) { | ============== declaration ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> error/too_few_args/error-libsass Error: Function round is missing argument $number. @@ -177,20 +197,21 @@ Error: Function round is missing argument $number. <===> ================================================================================ <===> error/too_many_args/input.scss -a {b: round(1, 2)} +@use "sass:math"; +a {b: math.round(1, 2)} <===> error/too_many_args/error Error: Only 1 argument allowed, but 2 were passed. ,--> input.scss -1 | a {b: round(1, 2)} - | ^^^^^^^^^^^ invocation +2 | a {b: math.round(1, 2)} + | ^^^^^^^^^^^^^^^^ invocation ' ,--> sass:math 1 | @function round($number) { | ============== declaration ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> error/too_many_args/error-libsass Error: wrong number of arguments (2 for 1) for `round' diff --git a/spec/values/calculation/abs.hrx b/spec/values/calculation/abs.hrx new file mode 100644 index 0000000000..d06e33694a --- /dev/null +++ b/spec/values/calculation/abs.hrx @@ -0,0 +1,192 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `abs()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> zero/input.scss +a {b: abs(0)} + +<===> zero/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> positive/input.scss +a {b: abs(1)} + +<===> positive/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: abs(-5.6)} + +<===> negative/output.css +a { + b: 5.6; +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: abs(1px + 2px - var(--c)) +} + +<===> simplification/output.css +a { + b: abs(3px - var(--c)); +} + +<===> +================================================================================ +<===> preserves_units/input.scss +a {b: abs(-7px / 4em) * 1em} + +<===> preserves_units/output.css +a { + b: 1.75px; +} + +<===> +================================================================================ +<===> preserves_single_unit/input.scss +a {b: abs(1 + 1px)} + +<===> preserves_single_unit/output.css +a { + b: 2px; +} + +<===> +================================================================================ +<===> sass_script/input.scss +a {b: abs($number: -3)} + +<===> sass_script/output.css +a { + b: 3; +} + +<===> +================================================================================ +<===> percentage_warning/input.scss +a {b: abs(-7.5%)} + +<===> percentage_warning/output.css +a { + b: 7.5%; +} + +<===> percentage_warning/warning +DEPRECATION WARNING: Passing percentage units to the global abs() function is deprecated. +In the future, this will emit a CSS abs() function to be resolved by the browser. +To preserve current behavior: math.abs(-7.5%) +To emit a CSS abs() now: abs(#{-7.5%}) +More info: https://sass-lang.com/d/abs-percent + , +1 | a {b: abs(-7.5%)} + | ^^^^^^^^^^^^^^^^^ + ' + input.scss 1:1 root stylesheet + +<===> +================================================================================ +<===> math/slash_as_division/input.scss +b { + a: 2px / abs(1.5); +} + +<===> math/slash_as_division/output.css +b { + a: 1.3333333333px; +} + +<===> 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 + +<===> +================================================================================ +<===> error/sass_script_and_variable/input.scss +a {b: abs($number: var(--c))} + +<===> error/sass_script_and_variable/error +Error: $number: var(--c) is not a number. + , +1 | a {b: abs($number: var(--c))} + | ^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: abs("0")} + +<===> error/type/error +Error: $number: "0" is not a number. + , +1 | a {b: abs("0")} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: abs()} + +<===> error/too_few_args/error +Error: Missing argument $number. + ,--> input.scss +1 | a {b: abs()} + | ^^^^^ invocation + ' + ,--> sass:math +1 | @function abs($number) { + | ============ declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +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 + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: abs($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: abs($)} + | ^ + ' + input.scss 1:12 root stylesheet diff --git a/spec/values/calculation/acos.hrx b/spec/values/calculation/acos.hrx new file mode 100644 index 0000000000..35081f4eb3 --- /dev/null +++ b/spec/values/calculation/acos.hrx @@ -0,0 +1,169 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `acos()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> less_than_negative_one/input.scss +a {b: acos(-2)} + +<===> less_than_negative_one/output.css +a { + b: calc(NaN * 1deg); +} + +<===> +================================================================================ +<===> negative_one/input.scss +a {b: acos(-1)} + +<===> negative_one/output.css +a { + b: 180deg; +} + +<===> +================================================================================ +<===> zero/input.scss +a {b: acos(0)} + +<===> zero/output.css +a { + b: 90deg; +} + +<===> +================================================================================ +<===> one/input.scss +a {b: acos(1)} + +<===> one/output.css +a { + b: 0deg; +} + +<===> +================================================================================ +<===> greater_than_one/input.scss +a {b: acos(2)} + +<===> greater_than_one/output.css +a { + b: calc(NaN * 1deg); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: acos(3px - 1px + var(--c)); +} + +<===> simplification/output.css +a { + b: acos(2px + var(--c)); +} + +<===> +================================================================================ +<===> error/unit/unknown/input.scss +a {b: acos(1%)} + +<===> error/unit/unknown/error +Error: Expected 1% to have no units. + , +1 | a {b: acos(1%)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/known/input.scss +a {b: acos(1px)} + +<===> error/unit/known/error +Error: Expected 1px to have no units. + , +1 | a {b: acos(1px)} + | ^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/complex/input.scss +a {b: acos(-7px / 4em)} + +<===> error/unit/complex/error +Error: Expected -1.75px/em to have no units. + , +1 | a {b: acos(-7px / 4em)} + | ^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: acos("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: acos("0")} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: acos()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: acos()} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: acos(0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: acos(0, 0)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: acos($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: acos($)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: acos(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: acos(7 % 3)} + | ^ + ' + input.scss 1:14 root stylesheet diff --git a/spec/values/calculation/asin.hrx b/spec/values/calculation/asin.hrx new file mode 100644 index 0000000000..0731aceaaa --- /dev/null +++ b/spec/values/calculation/asin.hrx @@ -0,0 +1,169 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `asin()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> less_than_negative_one/input.scss +a {b: asin(-2)} + +<===> less_than_negative_one/output.css +a { + b: calc(NaN * 1deg); +} + +<===> +================================================================================ +<===> negative_one/input.scss +a {b: asin(-1)} + +<===> negative_one/output.css +a { + b: -90deg; +} + +<===> +================================================================================ +<===> zero/input.scss +a {b: asin(0)} + +<===> zero/output.css +a { + b: 0deg; +} + +<===> +================================================================================ +<===> one/input.scss +a {b: asin(1)} + +<===> one/output.css +a { + b: 90deg; +} + +<===> +================================================================================ +<===> greater_than_one/input.scss +a {b: asin(2)} + +<===> greater_than_one/output.css +a { + b: calc(NaN * 1deg); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: asin(3px - 1px + var(--c)); +} + +<===> simplification/output.css +a { + b: asin(2px + var(--c)); +} + +<===> +================================================================================ +<===> error/unit/unknown/input.scss +a {b: asin(1%)} + +<===> error/unit/unknown/error +Error: Expected 1% to have no units. + , +1 | a {b: asin(1%)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/known/input.scss +a {b: asin(1px)} + +<===> error/unit/known/error +Error: Expected 1px to have no units. + , +1 | a {b: asin(1px)} + | ^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/complex/input.scss +a {b: asin(-7px / 4em)} + +<===> error/unit/complex/error +Error: Expected -1.75px/em to have no units. + , +1 | a {b: asin(-7px / 4em)} + | ^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: asin("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: asin("0")} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: asin()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: asin()} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: asin(0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: asin(0, 0)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: asin($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: asin($)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: asin(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: asin(7 % 3)} + | ^ + ' + input.scss 1:14 root stylesheet diff --git a/spec/values/calculation/atan.hrx b/spec/values/calculation/atan.hrx new file mode 100644 index 0000000000..c1e3d88cf1 --- /dev/null +++ b/spec/values/calculation/atan.hrx @@ -0,0 +1,146 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `atan()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> negative_infinity/input.scss +a {b: atan(-infinity)} + +<===> negative_infinity/output.css +a { + b: -90deg; +} + +<===> +================================================================================ +<===> zero/input.scss +a {b: atan(0)} + +<===> zero/output.css +a { + b: 0deg; +} + +<===> +================================================================================ +<===> one/input.scss +a {b: atan(1)} + +<===> one/output.css +a { + b: 45deg; +} + +<===> +================================================================================ +<===> infinity/input.scss +a {b: atan(infinity)} + +<===> infinity/output.css +a { + b: 90deg; +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: atan(3px - 1px + var(--c)); +} + +<===> simplification/output.css +a { + b: atan(2px + var(--c)); +} + +<===> +================================================================================ +<===> error/unit/unknown/input.scss +a {b: atan(1%)} + +<===> error/unit/unknown/error +Error: Expected 1% to have no units. + , +1 | a {b: atan(1%)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/known/input.scss +a {b: atan(1px)} + +<===> error/unit/known/error +Error: Expected 1px to have no units. + , +1 | a {b: atan(1px)} + | ^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/complex/input.scss +a {b: atan(-7px / 4em)} + +<===> error/unit/complex/error +Error: Expected -1.75px/em to have no units. + , +1 | a {b: atan(-7px / 4em)} + | ^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: atan("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: atan("0")} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: atan()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: atan()} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: atan(0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: atan(0, 0)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: atan(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: atan(7 % 3)} + | ^ + ' + input.scss 1:14 root stylesheet diff --git a/spec/values/calculation/atan2.hrx b/spec/values/calculation/atan2.hrx new file mode 100644 index 0000000000..11d3247bec --- /dev/null +++ b/spec/values/calculation/atan2.hrx @@ -0,0 +1,212 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `atan2()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> units/none/input.scss +a {b: atan2(1, -10)} + +<===> units/none/output.css +a { + b: 174.2894068625deg; +} + +<===> +================================================================================ +<===> units/compatible/input.scss +a {b: atan2(1cm, -10mm)} + +<===> units/compatible/output.css +a { + b: 135deg; +} + +<===> +================================================================================ +<===> units/real_and_unknown/input.scss +a {b: atan2(1px, 10%)} + +<===> units/real_and_unknown/output.css +a { + b: atan2(1px, 10%); +} + +<===> +================================================================================ +<===> units/unknown/input.scss +a { + b: atan2(1%, 2%); +} + +<===> units/unknown/output.css +a { + b: atan2(1%, 2%); +} + +<===> +================================================================================ +<===> units/fake/input.scss +a { + b: atan2(1foo, 2bar); +} + +<===> units/fake/output.css +a { + b: atan2(1foo, 2bar); +} + +<===> +================================================================================ +<===> units/same_fake/input.scss +a { + b: atan2(1foo, 2foo); +} + +<===> units/same_fake/output.css +a { + b: 26.5650511771deg; +} + +<===> +================================================================================ +<===> units/real_and_fake/input.scss +a { + b: atan2(1px, 2bar); +} + +<===> units/real_and_fake/output.css +a { + b: atan2(1px, 2bar); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: atan2(3px - 1px + var(--c), -7px / 4em * 1em); +} + +<===> simplification/output.css +a { + b: atan2(2px + var(--c), -1.75px); +} + +<===> +================================================================================ +<===> error/units/unitless_and_real/input.scss +a {b: atan2(1, 1px)} + +<===> error/units/unitless_and_real/error +Error: 1 and 1px are incompatible. + , +1 | a {b: atan2(1, 1px)} + | ^ 1 + | === 1px + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/units/known_incompatible/input.scss +a {b: atan2(1deg, 1px)} + +<===> error/units/known_incompatible/error +Error: 1deg and 1px are incompatible. + , +1 | a {b: atan2(1deg, 1px)} + | ^^^^ 1deg + | === 1px + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/units/complex_and_unknown/input.scss +a {b: atan2(1px*2px, 10%)} + +<===> error/units/complex_and_unknown/error +Error: Number 2px*px isn't compatible with CSS calculations. + , +1 | a {b: atan2(1px*2px, 10%)} + | ^^^^^^^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: atan2(1, $)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: atan2(1, $)} + | ^ + ' + input.scss 1:17 root stylesheet + +<===> +================================================================================ +<===> error/x_type/input.scss +a {b: atan2(0, "0")} + +<===> error/x_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: atan2(0, "0")} + | ^ + ' + input.scss 1:16 root stylesheet + +<===> +================================================================================ +<===> error/y_type/input.scss +a {b: atan2("0", 0)} + +<===> error/y_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: atan2("0", 0)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: atan2(0)} + +<===> error/too_few_args/error +Error: 2 arguments required, but only 1 was passed. + , +1 | a {b: atan2(0)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: atan2(0, 0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: atan2(0, 0, 0)} + | ^ + ' + input.scss 1:17 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: atan2(7 % 3, 1)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", ",", or ")". + , +1 | a {b: atan2(7 % 3, 1)} + | ^ + ' + input.scss 1:15 root stylesheet diff --git a/spec/values/calculation/cos.hrx b/spec/values/calculation/cos.hrx new file mode 100644 index 0000000000..f8b513517f --- /dev/null +++ b/spec/values/calculation/cos.hrx @@ -0,0 +1,189 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `cos()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> deg/input.scss +a {b: cos(1deg)} + +<===> deg/output.css +a { + b: 0.9998476952; +} + +<===> +================================================================================ +<===> grad/input.scss +a {b: cos(1grad)} + +<===> grad/output.css +a { + b: 0.9998766325; +} + +<===> +================================================================================ +<===> rad/input.scss +a {b: cos(1rad)} + +<===> rad/output.css +a { + b: 0.5403023059; +} + +<===> +================================================================================ +<===> turn/input.scss +a {b: cos(1turn)} + +<===> turn/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> negative_infinity/input.scss +a {b: cos(-infinity)} + +<===> negative_infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> zero/input.scss +a {b: cos(0)} + +<===> zero/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> infinity/input.scss +a {b: cos(infinity)} + +<===> infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: cos(3px - 1px + var(--c)); +} + +<===> simplification/output.css +a { + b: cos(2px + var(--c)); +} + +<===> +================================================================================ +<===> error/unit/unknown/input.scss +a {b: cos(1%)} + +<===> error/unit/unknown/error +Error: $number: Expected 1% to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: cos(1%)} + | ^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/known/input.scss +a {b: cos(1px)} + +<===> error/unit/known/error +Error: $number: Expected 1px to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: cos(1px)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/complex/input.scss +a {b: cos(-7px / 4em)} + +<===> error/unit/complex/error +Error: $number: Expected -1.75px/em to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: cos(-7px / 4em)} + | ^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: cos("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: cos("0")} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: cos()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: cos()} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: cos(0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: cos(0, 0)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: cos($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: cos($)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: cos(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: cos(7 % 3)} + | ^ + ' + input.scss 1:13 root stylesheet diff --git a/spec/values/calculation/exp.hrx b/spec/values/calculation/exp.hrx new file mode 100644 index 0000000000..307fa827a8 --- /dev/null +++ b/spec/values/calculation/exp.hrx @@ -0,0 +1,147 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `exp()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> zero/input.scss +a {b: exp(0)} + +<===> zero/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> positive/input.scss +a {b: exp(5)} + +<===> positive/output.css +a { + b: 148.4131591026; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: exp(-10.5)} + +<===> negative/output.css +a { + b: 0.0000275364; +} + +<===> +================================================================================ +<===> result_is_infinity/input.scss +a {b: exp(1000.65)} + +<===> result_is_infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: exp(1px + 2px - var(--c)) +} + +<===> simplification/output.css +a { + b: exp(3px - var(--c)); +} + +<===> +================================================================================ +<===> error/units/unknown/input.scss +a {b: exp(1%)} + +<===> error/units/unknown/error +Error: Expected 1% to have no units. + , +1 | a {b: exp(1%)} + | ^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/unit/known/input.scss +a {b: exp(1px)} + +<===> error/unit/known/error +Error: Expected 1px to have no units. + , +1 | a {b: exp(1px)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: exp("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: exp("0")} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: exp()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: exp()} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: exp(0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: exp(0, 0)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: exp($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: exp($)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: exp(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: exp(7 % 3)} + | ^ + ' + input.scss 1:13 root stylesheet + diff --git a/spec/values/calculation/hypot.hrx b/spec/values/calculation/hypot.hrx new file mode 100644 index 0000000000..d1a124a5c6 --- /dev/null +++ b/spec/values/calculation/hypot.hrx @@ -0,0 +1,247 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `hypot()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> units/none/input.scss +a {b: hypot(3, 4, 5, 6, 7)} + +<===> units/none/output.css +a { + b: 11.6189500386; +} + +<===> +================================================================================ +<===> units/compatible/input.scss +a {b: hypot(13cm, 4mm, 5q, 6in, 7px)} + +<===> units/compatible/output.css +a { + b: 20.0366545892cm; +} + +<===> +================================================================================ +<===> units/real_and_unknown/input.scss +a {b: hypot(13cm, 4%)} + +<===> units/real_and_unknown/output.css +a { + b: hypot(13cm, 4%); +} + +<===> +================================================================================ +<===> units/unknown/input.scss +a { + b: hypot(1%, 2%); +} + +<===> units/unknown/output.css +a { + b: hypot(1%, 2%); +} + +<===> +================================================================================ +<===> units/fake/input.scss +a { + b: hypot(1foo, 2bar); +} + +<===> units/fake/output.css +a { + b: hypot(1foo, 2bar); +} + +<===> +================================================================================ +<===> units/same_fake/input.scss +a { + b: hypot(1foo, 2foo); +} + +<===> units/same_fake/output.css +a { + b: 2.2360679775foo; +} + +<===> +================================================================================ +<===> units/real_and_fake/input.scss +a { + b: hypot(1px, 2bar); +} + +<===> units/real_and_fake/output.css +a { + b: hypot(1px, 2bar); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: hypot(1px + 2px - var(--c), -7px + 4em) +} + +<===> simplification/output.css +a { + b: hypot(3px - var(--c), -7px + 4em); +} + +<===> +================================================================================ +<===> infinity/first/input.scss +a {b: hypot(infinity, 1, 1)} + +<===> infinity/first/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> infinity/second/input.scss +a {b: hypot(1, infinity, 1)} + +<===> infinity/second/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> error/unsimplifiable/input.scss +a {b: hypot(-7px / 4em)} + +<===> error/unsimplifiable/error +Error: Number -1.75px/em isn't compatible with CSS calculations. + , +1 | a {b: hypot(-7px / 4em)} + | ^^^^^^^^^^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/units/incompatible/first_and_second/input.scss +a {b: hypot(1deg, 1px, 1turn)} + +<===> error/units/incompatible/first_and_second/error +Error: 1deg and 1px are incompatible. + , +1 | a {b: hypot(1deg, 1px, 1turn)} + | ^^^^ 1deg + | === 1px + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/units/incompatible/first_and_third/input.scss +a {b: hypot(1deg, 1turn, 1px)} + +<===> error/units/incompatible/first_and_third/error +Error: 1deg and 1px are incompatible. + , +1 | a {b: hypot(1deg, 1turn, 1px)} + | ^^^^ 1deg + | === 1px + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/units/incompatible/second_and_third/input.scss +a {b: hypot(1turn, 1deg, 1px)} + +<===> error/units/incompatible/second_and_third/error +Error: 1turn and 1px are incompatible. + , +1 | a {b: hypot(1turn, 1deg, 1px)} + | ^^^^^ 1turn + | === 1px + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/units/real_and_unitless/input.scss +a {b: hypot(1px, 1)} + +<===> error/units/real_and_unitless/error +Error: 1px and 1 are incompatible. + , +1 | a {b: hypot(1px, 1)} + | ^^^ 1px + | = 1 + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/first_type/input.scss +a {b: hypot("0", 1px, 1px)} + +<===> error/first_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: hypot("0", 1px, 1px)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/second_type/input.scss +a {b: hypot(1px, "0", 1px)} + +<===> error/second_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: hypot(1px, "0", 1px)} + | ^ + ' + input.scss 1:18 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: hypot()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: hypot()} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: hypot(12, $, 14)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: hypot(12, $, 14)} + | ^ + ' + input.scss 1:18 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: hypot(7 % 3, 1)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", ",", or ")". + , +1 | a {b: hypot(7 % 3, 1)} + | ^ + ' + input.scss 1:15 root stylesheet diff --git a/spec/values/calculation/log.hrx b/spec/values/calculation/log.hrx new file mode 100644 index 0000000000..c2481a490e --- /dev/null +++ b/spec/values/calculation/log.hrx @@ -0,0 +1,248 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `log()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> negative/input.scss +a {b: log(-1)} + +<===> negative/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> zero/input.scss +a {b: log(0)} + +<===> zero/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> positive/input.scss +a {b: log(2)} + +<===> positive/output.css +a { + b: 0.6931471806; +} + +<===> +================================================================================ +<===> infinity/input.scss +a {b: log(infinity)} + +<===> infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> base/negative/input.scss +a {b: log(2, -1)} + +<===> base/negative/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> base/zero/input.scss +a {b: log(2, 0)} + +<===> base/zero/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> base/between_zero_and_one/input.scss +a {b: log(2, 0.5)} + +<===> base/between_zero_and_one/output.css +a { + b: -1; +} + +<===> +================================================================================ +<===> base/one/input.scss +a {b: log(2, 1)} + +<===> base/one/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> base/positive/input.scss +a {b: log(2, 10)} + +<===> base/positive/output.css +a { + b: 0.3010299957; +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: log(3px - 1px + var(--c), var(--e)); +} + +<===> simplification/output.css +a { + b: log(2px + var(--c), var(--e)); +} + +<===> +================================================================================ +<===> error/units/unknown/input.scss +a {b: log(1%)} + +<===> error/units/unknown/error +Error: Expected 1% to have no units. + , +1 | a {b: log(1%)} + | ^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/unitless_and_real/input.scss +a {b: log(1, 1px)} + +<===> error/units/unitless_and_real/error +Error: Expected 1px to have no units. + , +1 | a {b: log(1, 1px)} + | ^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/known_incompatible/input.scss +a {b: log(1deg, 1px)} + +<===> error/units/known_incompatible/error +Error: Expected 1deg to have no units. + , +1 | a {b: log(1deg, 1px)} + | ^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/complex_and_unknown/input.scss +a {b: log(1px*2px, 10%)} + +<===> error/units/complex_and_unknown/error +Error: Expected 2px*px to have no units. + , +1 | a {b: log(1px*2px, 10%)} + | ^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/known/input.scss +a {b: log(3px)} + +<===> error/units/known/error +Error: Expected 3px to have no units. + , +1 | a {b: log(3px)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/number_type/input.scss +a {b: log("0")} + +<===> error/number_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: log("0")} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/base_type/input.scss +a {b: log(0, "0")} + +<===> error/base_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: log(0, "0")} + | ^ + ' + input.scss 1:14 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: log()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: log()} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: log(0, 0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: log(0, 0, 0)} + | ^ + ' + input.scss 1:15 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: log($, 10)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: log($, 10)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: log(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", ",", or ")". + , +1 | a {b: log(7 % 3)} + | ^ + ' + input.scss 1:13 root stylesheet diff --git a/spec/values/calculation/max.hrx b/spec/values/calculation/max.hrx index 7364ce9e83..9139e063fc 100644 --- a/spec/values/calculation/max.hrx +++ b/spec/values/calculation/max.hrx @@ -86,10 +86,10 @@ Error: 1c and 3 are incompatible. <===> ================================================================================ -<===> error/unitless_and_unit/in_calc/input.scss +<===> error/unitless_and_real/in_calc/input.scss a {b: max(calc(1px + 2))} -<===> error/unitless_and_unit/in_calc/error +<===> error/unitless_and_real/in_calc/error Error: 1px and 2 are incompatible. , 1 | a {b: max(calc(1px + 2))} @@ -183,10 +183,10 @@ a { <===> ================================================================================ -<===> simplified/unitless_and_unit/input.scss +<===> simplified/unitless_and_real/input.scss a {b: max(1px, 2.5, 0.9px)} -<===> simplified/unitless_and_unit/output.css +<===> simplified/unitless_and_real/output.css a { b: 2.5; } @@ -203,10 +203,10 @@ a { <===> ================================================================================ -<===> simplified/operation/unitless_and_unit/input.scss +<===> simplified/operation/unitless_and_real/input.scss a {b: max(1px, 2.5 + 0.9px)} -<===> simplified/operation/unitless_and_unit/output.css +<===> simplified/operation/unitless_and_real/output.css a { b: 3.4px; } @@ -284,30 +284,52 @@ b { <===> ================================================================================ -<===> preserved/operation/unitless_and_unit/plus/input.scss +<===> preserved/operation/unitless_and_real/plus/input.scss a {b: max(1%, 2.5 + 0.9px)} -<===> preserved/operation/unitless_and_unit/plus/output.css +<===> preserved/operation/unitless_and_real/plus/output.css a { b: max(1%, 3.4px); } <===> ================================================================================ -<===> preserved/operation/unitless_and_unit/minus/input.scss +<===> preserved/operation/unitless_and_real/minus/input.scss a {b: max(1%, 2.5 - 0.9px)} -<===> preserved/operation/unitless_and_unit/minus/output.css +<===> preserved/operation/unitless_and_real/minus/output.css a { b: max(1%, 1.6px); } <===> ================================================================================ -<===> preserved/operation/unitless_and_unit/in_calc/input.scss +<===> preserved/operation/unitless_and_real/in_calc/input.scss a {b: calc(max(1%, 2.5 + 0.9px))} -<===> preserved/operation/unitless_and_unit/in_calc/output.css +<===> preserved/operation/unitless_and_real/in_calc/output.css a { b: max(1%, 3.4px); } + +<===> +================================================================================ +<===> math/slash_as_division/input.scss +b { + a: 2px / max(1.5); +} + +<===> math/slash_as_division/output.css +b { + a: 1.3333333333px; +} + +<===> 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, max(1.5)) or calc(2px / max(1.5)) +More info and automated migrator: https://sass-lang.com/d/slash-div + , +2 | a: 2px / max(1.5); + | ^^^^^^^^^^^^^^ + ' + input.scss 2:6 root stylesheet diff --git a/spec/values/calculation/min.hrx b/spec/values/calculation/min.hrx index 768f763a2c..ab07a967a0 100644 --- a/spec/values/calculation/min.hrx +++ b/spec/values/calculation/min.hrx @@ -86,10 +86,10 @@ Error: 1c and 3 are incompatible. <===> ================================================================================ -<===> error/unitless_and_unit/in_calc/input.scss +<===> error/unitless_and_real/in_calc/input.scss a {b: min(calc(1px + 2))} -<===> error/unitless_and_unit/in_calc/error +<===> error/unitless_and_real/in_calc/error Error: 1px and 2 are incompatible. , 1 | a {b: min(calc(1px + 2))} @@ -193,80 +193,80 @@ a { <===> ================================================================================ -<===> simplified/unitless_and_unit/input.scss +<===> simplified/unitless_and_real/input.scss a {b: min(1px, 2.5, 0.9px)} -<===> simplified/unitless_and_unit/output.css +<===> simplified/unitless_and_real/output.css a { b: 0.9px; } <===> ================================================================================ -<===> simplified/operation/unitless_and_unit/input.scss +<===> simplified/operation/unitless_and_real/input.scss a {b: min(1px, 2.5 + 0.9px)} -<===> simplified/operation/unitless_and_unit/output.css +<===> simplified/operation/unitless_and_real/output.css a { b: 1px; } <===> ================================================================================ -<===> perserved/math/first/input.scss +<===> preserved/math/first/input.scss a {b: min(1% + 1px, 2px)} -<===> perserved/math/first/output.css +<===> preserved/math/first/output.css a { b: min(1% + 1px, 2px); } <===> ================================================================================ -<===> perserved/math/second/input.scss +<===> preserved/math/second/input.scss a {b: min(1px, 1% + 2px)} -<===> perserved/math/second/output.css +<===> preserved/math/second/output.css a { b: min(1px, 1% + 2px); } <===> ================================================================================ -<===> perserved/math/third/input.scss +<===> preserved/math/third/input.scss a {b: min(1px, 2px, 1% + 3px)} -<===> perserved/math/third/output.css +<===> preserved/math/third/output.css a { b: min(1px, 2px, 1% + 3px); } <===> ================================================================================ -<===> perserved/unit/first/input.scss +<===> preserved/unit/first/input.scss a {b: min(1%, 2px)} -<===> perserved/unit/first/output.css +<===> preserved/unit/first/output.css a { b: min(1%, 2px); } <===> ================================================================================ -<===> perserved/unit/second/input.scss +<===> preserved/unit/second/input.scss a {b: min(1px, 2%)} -<===> perserved/unit/second/output.css +<===> preserved/unit/second/output.css a { b: min(1px, 2%); } <===> ================================================================================ -<===> perserved/unit/third/input.scss +<===> preserved/unit/third/input.scss a {b: min(1px, 2px, 3%)} -<===> perserved/unit/third/output.css +<===> preserved/unit/third/output.css a { b: min(1px, 2px, 3%); } @@ -284,30 +284,52 @@ b { <===> ================================================================================ -<===> preserved/operation/unitless_and_unit/plus/input.scss +<===> preserved/operation/unitless_and_real/plus/input.scss a {b: min(1%, 2.5 + 0.9px)} -<===> preserved/operation/unitless_and_unit/plus/output.css +<===> preserved/operation/unitless_and_real/plus/output.css a { b: min(1%, 3.4px); } <===> ================================================================================ -<===> preserved/operation/unitless_and_unit/minus/input.scss +<===> preserved/operation/unitless_and_real/minus/input.scss a {b: min(1%, 2.5 - 0.9px)} -<===> preserved/operation/unitless_and_unit/minus/output.css +<===> preserved/operation/unitless_and_real/minus/output.css a { b: min(1%, 1.6px); } <===> ================================================================================ -<===> preserved/operation/unitless_and_unit/in_calc/input.scss +<===> preserved/operation/unitless_and_real/in_calc/input.scss a {b: calc(min(1%, 2.5 + 0.9px))} -<===> preserved/operation/unitless_and_unit/in_calc/output.css +<===> preserved/operation/unitless_and_real/in_calc/output.css a { b: min(1%, 3.4px); } + +<===> +================================================================================ +<===> math/slash_as_division/input.scss +b { + a: 2px / min(1.5); +} + +<===> math/slash_as_division/output.css +b { + a: 1.3333333333px; +} + +<===> 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, min(1.5)) or calc(2px / min(1.5)) +More info and automated migrator: https://sass-lang.com/d/slash-div + , +2 | a: 2px / min(1.5); + | ^^^^^^^^^^^^^^ + ' + input.scss 2:6 root stylesheet diff --git a/spec/values/calculation/mod.hrx b/spec/values/calculation/mod.hrx new file mode 100644 index 0000000000..4f3e9cd61a --- /dev/null +++ b/spec/values/calculation/mod.hrx @@ -0,0 +1,374 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `mod()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> units/none/input.scss +a {b: mod(7, 3)} + +<===> units/none/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> units/compatible/input.scss +a {b: mod(5px, 3px)} + +<===> units/compatible/output.css +a { + b: 2px; +} + +<===> +================================================================================ +<===> units/real_and_unknown/input.scss +a {b: mod(5px, 3%)} + +<===> units/real_and_unknown/output.css +a { + b: mod(5px, 3%); +} + +<===> +================================================================================ +<===> units/unknown/input.scss +a { + b: mod(1%, 2%); +} + +<===> units/unknown/output.css +a { + b: 1%; +} + +<===> +================================================================================ +<===> units/fake/input.scss +a { + b: mod(1foo, 2bar); +} + +<===> units/fake/output.css +a { + b: mod(1foo, 2bar); +} + +<===> +================================================================================ +<===> units/same_fake/input.scss +a { + b: mod(1foo, 2foo); +} + +<===> units/same_fake/output.css +a { + b: 1foo; +} + +<===> +================================================================================ +<===> units/real_and_fake/input.scss +a { + b: mod(1px, 2bar); +} + +<===> units/real_and_fake/output.css +a { + b: mod(1px, 2bar); +} + +<===> +================================================================================ +<===> equals/input.scss +a {b: mod(1, 1)} + +<===> equals/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> positive_and_negative/input.scss +a {b: mod(2, -5)} + +<===> positive_and_negative/output.css +a { + b: -3; +} + +<===> +================================================================================ +<===> negative_and_positive/input.scss +a {b: mod(-2, 5)} + +<===> negative_and_positive/output.css +a { + b: 3; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: mod(-2, -5)} + +<===> negative/output.css +a { + b: -2; +} + +<===> +================================================================================ +<===> y_zero/input.scss +a {b: mod(6, 0)} + +<===> y_zero/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> x_zero/input.scss +a {b: mod(0, 6)} + +<===> x_zero/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> zeros/input.scss +a {b: mod(0, 0)} + +<===> zeros/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> y_infinity/positive/input.scss +a {b: mod(infinity, 10)} + +<===> y_infinity/positive/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> x_infinity/positive/input.scss +a {b: mod(-10, infinity)} + +<===> x_infinity/positive/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> x_infinity/negative/input.scss +a {b: mod(10, -infinity)} + +<===> x_infinity/negative/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: mod(3px - 1px + var(--c), -7px / 4em * 1em); +} + +<===> simplification/output.css +a { + b: mod(2px + var(--c), -1.75px); +} + +<===> +================================================================================ +<===> positive_zero/input.scss +@use "sass:math"; +a {b: math.div(1, mod(7, 7))} + +<===> positive_zero/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> negative_zero/input.scss +@use "sass:math"; +a {b: math.div(1, mod(-7, 7))} + +<===> negative_zero/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> error/units/real_and_unitless/input.scss +a {b: mod(16px, 5)} + +<===> error/units/real_and_unitless/error +Error: 16px and 5 are incompatible. + , +1 | a {b: mod(16px, 5)} + | ^^^^ 16px + | = 5 + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/units/incompatible/input.scss +a {b: mod(16px, 5deg)} + +<===> error/units/incompatible/error +Error: 16px and 5deg are incompatible. + , +1 | a {b: mod(16px, 5deg)} + | ^^^^ 16px + | ==== 5deg + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/units/complex_and_unknown/input.scss +a {b: mod(1px*2px, 10%)} + +<===> error/units/complex_and_unknown/error +Error: Number 2px*px isn't compatible with CSS calculations. + , +1 | a {b: mod(1px*2px, 10%)} + | ^^^^^^^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: mod(3)} + +<===> error/too_few_args/error +Error: 2 arguments required, but only 1 was passed. + , +1 | a {b: mod(3)} + | ^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: mod(10, $)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: mod(10, $)} + | ^ + ' + input.scss 1:16 root stylesheet + +<===> +================================================================================ +<===> error/modulus_type/input.scss +a {b: mod(0, "0")} + +<===> error/modulus_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: mod(0, "0")} + | ^ + ' + input.scss 1:14 root stylesheet + +<===> +================================================================================ +<===> error/dividend_type/input.scss +a {b: mod("0", 0)} + +<===> error/dividend_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: mod("0", 0)} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: mod(3, 2, 1)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: mod(3, 2, 1)} + | ^ + ' + input.scss 1:15 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: mod(7 % 3, 1)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", ",", or ")". + , +1 | a {b: mod(7 % 3, 1)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> nan/negative_zero_and_positive_infinity/input.scss +a {b: mod(-0, infinity)} + +<===> nan/negative_zero_and_positive_infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> nan/zero_and_negative_infinity/input.scss +a {b: mod(0, -infinity)} + +<===> nan/zero_and_negative_infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> nan/negative_and_positive_infinity/input.scss +a {b: mod(-5, infinity)} + +<===> nan/negative_and_positive_infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> nan/positive_and_negative_infinity/input.scss +a {b: mod(5, -infinity)} + +<===> nan/positive_and_negative_infinity/output.css +a { + b: calc(NaN); +} diff --git a/spec/values/calculation/pow.hrx b/spec/values/calculation/pow.hrx new file mode 100644 index 0000000000..c9d74478de --- /dev/null +++ b/spec/values/calculation/pow.hrx @@ -0,0 +1,190 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `pow()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> positive/input.scss +a {b: pow(10, 10)} + +<===> positive/output.css +a { + b: 10000000000; +} + +<===> +================================================================================ +<===> base/negative/input.scss +a {b: pow(-10, 10)} + +<===> base/negative/output.css +a { + b: 10000000000; +} + +<===> +================================================================================ +<===> exponent/negative/input.scss +a {b: pow(10, -10)} + +<===> exponent/negative/output.css +a { + b: 0.0000000001; +} + +<===> +================================================================================ +<===> zeros/input.scss +a {b: pow(0, 0)} + +<===> zeros/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> y_infinity/positive/input.scss +a {b: pow(infinity, 10)} + +<===> y_infinity/positive/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> x_infinity/positive/input.scss +a {b: pow(10, infinity)} + +<===> x_infinity/positive/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> simplification/input.scss +a {b: pow(3px - 1px + var(--c), 4px + 10px)} + +<===> simplification/output.css +a { + b: pow(2px + var(--c), 14px); +} + +<===> +================================================================================ +<===> error/units/compatible/input.scss +a {b: pow(10px, 10px)} + +<===> error/units/compatible/error +Error: Expected 10px to have no units. + , +1 | a {b: pow(10px, 10px)} + | ^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/unknown_and_unitless/input.scss +a {b: pow(10%, 10)} + +<===> error/units/unknown_and_unitless/error +Error: Expected 10% to have no units. + , +1 | a {b: pow(10%, 10)} + | ^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/real_and_unitless/input.scss +a {b: pow(10px, 10)} + +<===> error/units/real_and_unitless/error +Error: Expected 10px to have no units. + , +1 | a {b: pow(10px, 10)} + | ^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: pow(10, $)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: pow(10, $)} + | ^ + ' + input.scss 1:16 root stylesheet + +<===> +================================================================================ +<===> error/base_type/input.scss +a {b: pow(0, "0")} + +<===> error/base_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: pow(0, "0")} + | ^ + ' + input.scss 1:14 root stylesheet + +<===> +================================================================================ +<===> error/exponent_type/input.scss +a {b: pow("0", 0)} + +<===> error/exponent_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: pow("0", 0)} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: pow(3)} + +<===> error/too_few_args/error +Error: 2 arguments required, but only 1 was passed. + , +1 | a {b: pow(3)} + | ^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: pow(3, 2, 1)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: pow(3, 2, 1)} + | ^ + ' + input.scss 1:15 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: pow(7 % 3, 1)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", ",", or ")". + , +1 | a {b: pow(7 % 3, 1)} + | ^ + ' + input.scss 1:13 root stylesheet diff --git a/spec/values/calculation/rem.hrx b/spec/values/calculation/rem.hrx new file mode 100644 index 0000000000..aa5aefd882 --- /dev/null +++ b/spec/values/calculation/rem.hrx @@ -0,0 +1,376 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `rem()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> units/none/input.scss +a {b: rem(7, 3)} + +<===> units/none/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> units/compatible/input.scss +a {b: rem(5px, 3px)} + +<===> units/compatible/output.css +a { + b: 2px; +} + +<===> +================================================================================ +<===> units/real_and_unknown/input.scss +a {b: rem(5px, 3%)} + +<===> units/real_and_unknown/output.css +a { + b: rem(5px, 3%); +} + +<===> +================================================================================ +<===> units/unknown/input.scss +a { + b: rem(1%, 2%); +} + +<===> units/unknown/output.css +a { + b: 1%; +} + +<===> +================================================================================ +<===> units/fake/input.scss +a { + b: rem(1foo, 2bar); +} + +<===> units/fake/output.css +a { + b: rem(1foo, 2bar); +} + +<===> +================================================================================ +<===> units/same_fake/input.scss +a { + b: rem(1foo, 2foo); +} + +<===> units/same_fake/output.css +a { + b: 1foo; +} + +<===> +================================================================================ +<===> units/real_and_fake/input.scss +a { + b: rem(1px, 2bar); +} + +<===> units/real_and_fake/output.css +a { + b: rem(1px, 2bar); +} + +<===> +================================================================================ +<===> equals/input.scss +a {b: rem(1, 1)} + +<===> equals/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> positive_and_negative/input.scss +a {b: rem(2, -5)} + +<===> positive_and_negative/output.css +a { + b: 2; +} + +<===> +================================================================================ +<===> negative_and_positive/input.scss +a {b: rem(-2, 5)} + +<===> negative_and_positive/output.css +a { + b: -2; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: rem(-2, -5)} + +<===> negative/output.css +a { + b: -2; +} + +<===> +================================================================================ +<===> y_zero/input.scss +a {b: rem(6, 0)} + +<===> y_zero/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> x_zero/input.scss +a {b: rem(0, 6)} + +<===> x_zero/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> zeros/input.scss +a {b: rem(0, 0)} + +<===> zeros/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> y_infinity/positive/input.scss +a {b: rem(infinity, 10)} + +<===> y_infinity/positive/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> x_infinity/positive/input.scss +a {b: rem(-10, infinity)} + +<===> x_infinity/positive/output.css +a { + b: -10; +} + +<===> +================================================================================ +<===> x_infinity/negative/input.scss +a {b: rem(10, -infinity)} + +<===> x_infinity/negative/output.css +a { + b: 10; +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: rem(3px - 1px + var(--c), -7px / 4em * 1em); +} + +<===> simplification/output.css +a { + b: rem(2px + var(--c), -1.75px); +} + +<===> +================================================================================ +<===> positive_zero/input.scss +@use "sass:math"; +a {b: math.div(1, rem(7, 7))} + +<===> positive_zero/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> negative_zero/input.scss +@use "sass:math"; +a {b: math.div(1, rem(-7, 7))} + +<===> negative_zero/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> error/units/real_and_unitless/input.scss +a {b: rem(16px, 5)} + +<===> error/units/real_and_unitless/error +Error: 16px and 5 are incompatible. + , +1 | a {b: rem(16px, 5)} + | ^^^^ 16px + | = 5 + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/units/incompatible/input.scss +a {b: rem(16px, 5deg)} + +<===> error/units/incompatible/error +Error: 16px and 5deg are incompatible. + , +1 | a {b: rem(16px, 5deg)} + | ^^^^ 16px + | ==== 5deg + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/units/complex_and_unknown/input.scss +a {b: rem(1px*2px, 10%)} + +<===> error/units/complex_and_unknown/error +Error: Number 2px*px isn't compatible with CSS calculations. + , +1 | a {b: rem(1px*2px, 10%)} + | ^^^^^^^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: rem(3)} + +<===> error/too_few_args/error +Error: 2 arguments required, but only 1 was passed. + , +1 | a {b: rem(3)} + | ^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: rem(10, $)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: rem(10, $)} + | ^ + ' + input.scss 1:16 root stylesheet + +<===> +================================================================================ +<===> error/modulus_type/input.scss +a {b: rem(0, "0")} + +<===> error/modulus_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: rem(0, "0")} + | ^ + ' + input.scss 1:14 root stylesheet + +<===> +================================================================================ +<===> error/dividend_type/input.scss +a {b: rem("0", 0)} + +<===> error/dividend_type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: rem("0", 0)} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: rem(3, 2, 1)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: rem(3, 2, 1)} + | ^ + ' + input.scss 1:15 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: rem(7 % 3, 1)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", ",", or ")". + , +1 | a {b: rem(7 % 3, 1)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> negative_zero_and_positive_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, rem(-0, infinity))} + +<===> negative_zero_and_positive_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> zero_and_negative_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, rem(0, -infinity))} + +<===> zero_and_negative_infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> negative_and_positive_infinity/input.scss +a {b: rem(-5, infinity)} + +<===> negative_and_positive_infinity/output.css +a { + b: -5; +} + +<===> +================================================================================ +<===> positive_and_negative_infinity/input.scss +a {b: rem(5, -infinity)} + +<===> positive_and_negative_infinity/output.css +a { + b: 5; +} diff --git a/spec/values/calculation/round/error.hrx b/spec/values/calculation/round/error.hrx new file mode 100644 index 0000000000..71d557deab --- /dev/null +++ b/spec/values/calculation/round/error.hrx @@ -0,0 +1,250 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `round()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> too_few_args/input.scss +a {b: round()} + +<===> too_few_args/error +Error: Missing argument $number. + ,--> input.scss +1 | a {b: round()} + | ^^^^^^^ invocation + ' + ,--> sass:math +1 | @function round($number) { + | ============== declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> too_many_args/input.scss +a {b: round(1, 2, 3, 4)} + +<===> too_many_args/error +Error: Only 1 argument allowed, but 4 were passed. + ,--> input.scss +1 | a {b: round(1, 2, 3, 4)} + | ^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:math +1 | @function round($number) { + | ============== declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> one_argument/sass_script/variable_named_argument/input.scss +a {b: round($number: var(--c))} + +<===> one_argument/sass_script/variable_named_argument/error +Error: $number: var(--c) is not a number. + , +1 | a {b: round($number: var(--c))} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + ' + 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 +a {b: round("0")} + +<===> one_argument/type/error +Error: $number: "0" is not a number. + , +1 | a {b: round("0")} + | ^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> one_argument/syntax/invalid_arg/input.scss +a {b: round($)} + +<===> one_argument/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: round($)} + | ^ + ' + input.scss 1:14 root stylesheet + +<===> +================================================================================ +<===> two_argument/units/real_and_unitless/input.scss +a {b: round(10px, 5)} + +<===> two_argument/units/real_and_unitless/error +Error: 10px and 5 are incompatible. + , +1 | a {b: round(10px, 5)} + | ^^^^ 10px + | = 5 + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> two_argument/units/known_incompatible/input.scss +a {b: round(10deg, 5px)} + +<===> two_argument/units/known_incompatible/error +Error: 10deg and 5px are incompatible. + , +1 | a {b: round(10deg, 5px)} + | ^^^^^ 10deg + | === 5px + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> two_argument/units/complex_and_unknown/input.scss +a {b: round(1px*2px, 10%)} + +<===> two_argument/units/complex_and_unknown/error +Error: Number 2px*px isn't compatible with CSS calculations. + , +1 | a {b: round(1px*2px, 10%)} + | ^^^^^^^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> two_argument/missing_step/input.scss +a {b: round(nearest, 5)} + +<===> two_argument/missing_step/error +Error: If strategy is not null, step is required. + , +1 | a {b: round(nearest, 5)} + | ^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> two_argument/x_type/input.scss +a {b: round(0, "0")} + +<===> two_argument/x_type/error +Error: Only 1 argument allowed, but 2 were passed. + ,--> input.scss +1 | a {b: round(0, "0")} + | ^^^^^^^^^^^^^ invocation + ' + ,--> sass:math +1 | @function round($number) { + | ============== declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> two_argument/y_type/input.scss +a {b: round("0", 0)} + +<===> two_argument/y_type/error +Error: Only 1 argument allowed, but 2 were passed. + ,--> input.scss +1 | a {b: round("0", 0)} + | ^^^^^^^^^^^^^ invocation + ' + ,--> sass:math +1 | @function round($number) { + | ============== declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> two_argument/sass_script/input.scss +a {b: round(7 % 3, 1)} + +<===> two_argument/sass_script/error +Error: Only 1 argument allowed, but 2 were passed. + ,--> input.scss +1 | a {b: round(7 % 3, 1)} + | ^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:math +1 | @function round($number) { + | ============== declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> three_argument/strategy/operation/input.scss +a { + e: round(10px + 2px, 8px, 9px); +} +<===> three_argument/strategy/operation/error +Error: 12px must be either nearest, up, down or to-zero. + , +2 | e: round(10px + 2px, 8px, 9px); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:6 root stylesheet + +<===> +================================================================================ +<===> three_argument/strategy_type/input.scss +$wrong_input: "nearest"; +a {b: round($wrong_input, 0, 0)} + +<===> three_argument/strategy_type/error +Error: Value "nearest" can't be used in a calculation. + , +2 | a {b: round($wrong_input, 0, 0)} + | ^^^^^^^^^^^^ + ' + input.scss 2:13 root stylesheet + +<===> +================================================================================ +<===> three_argument/number_type/input.scss +$wrong_input: "0"; +a {b: round(nearest, $wrong_input, 0)} + +<===> three_argument/number_type/error +Error: Value "0" can't be used in a calculation. + , +2 | a {b: round(nearest, $wrong_input, 0)} + | ^^^^^^^^^^^^ + ' + input.scss 2:22 root stylesheet + +<===> +================================================================================ +<===> three_argument/step_type/input.scss +$wrong_input: "0"; +a {b: round(nearest, 0, $wrong_input)} + +<===> three_argument/step_type/error +Error: Value "0" can't be used in a calculation. + , +2 | a {b: round(nearest, 0, $wrong_input)} + | ^^^^^^^^^^^^ + ' + input.scss 2:25 root stylesheet diff --git a/spec/values/calculation/round/one_argument.hrx b/spec/values/calculation/round/one_argument.hrx new file mode 100644 index 0000000000..8f6735ecb9 --- /dev/null +++ b/spec/values/calculation/round/one_argument.hrx @@ -0,0 +1,97 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `round()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> zero/input.scss +a {b: round(0)} + +<===> zero/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> positive/input.scss +a {b: round(1)} + +<===> positive/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: round(-5.6)} + +<===> negative/output.css +a { + b: -6; +} + +<===> +================================================================================ +<===> preserves_units/input.scss +a {b: round(-7px / 4em) * 1em} + +<===> preserves_units/output.css +a { + b: -2px; +} + +<===> +================================================================================ +<===> preserves_single_unit/input.scss +a {b: round(1 + 1px)} + +<===> preserves_single_unit/output.css +a { + b: 2px; +} + +<===> +================================================================================ +<===> preserved/variable/input.scss +a { + b: round(var(--c)) +} + +<===> preserved/variable/output.css +a { + b: round(var(--c)); +} + +<===> +================================================================================ +<===> sass_script/input.scss +a {b: round($number: -3)} + +<===> sass_script/output.css +a { + b: -3; +} + +<===> +================================================================================ +<===> math/slash_as_division/input.scss +b { + a: 2px / round(1.5); +} + +<===> math/slash_as_division/output.css +b { + a: 1px; +} + +<===> 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, round(1.5)) or calc(2px / round(1.5)) +More info and automated migrator: https://sass-lang.com/d/slash-div + , +2 | a: 2px / round(1.5); + | ^^^^^^^^^^^^^^^^ + ' + input.scss 2:6 root stylesheet diff --git a/spec/values/calculation/round/strategy/README.md b/spec/values/calculation/round/strategy/README.md new file mode 100644 index 0000000000..8a4aaa82a2 --- /dev/null +++ b/spec/values/calculation/round/strategy/README.md @@ -0,0 +1,5 @@ +# Three-argument round strategy testing + +Tests the `round()` function with the various combinations of rounding modes to cover all possibilities and edge cases to ensure robustness. Some tests are based on [web-platform-tests] for the CSS round function. + +[web-platform-tests]: https://github.com/web-platform-tests/wpt/blob/master/css/css-values/round-function.html diff --git a/spec/values/calculation/round/strategy/down.hrx b/spec/values/calculation/round/strategy/down.hrx new file mode 100644 index 0000000000..19e39b6847 --- /dev/null +++ b/spec/values/calculation/round/strategy/down.hrx @@ -0,0 +1,188 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `round()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> step_is_multiple_of_number/input.scss +a {b: round(down, 5px, 25px)} + +<===> step_is_multiple_of_number/output.css +a { + b: 0px; +} + +<===> +================================================================================ +<===> number_is_multiple_of_step/input.scss +a {b: round(down, 25px, 5px)} + +<===> number_is_multiple_of_step/output.css +a { + b: 25px; +} + +<===> +================================================================================ +<===> positive/input.scss +a {b: round(down, 122px, 25px)} + +<===> positive/output.css +a { + b: 100px; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: round(down, -101, -25)} + +<===> negative/output.css +a { + b: -125; +} + +<===> +================================================================================ +<===> negative_step/input.scss +a {b: round(down, 12, -7)} + +<===> negative_step/output.css +a { + b: 7; +} + +<===> +================================================================================ +<===> infinity/input.scss +a {b: round(down, infinity, infinity)} + +<===> infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> step_is_zero/input.scss +a {b: round(down, 10px, 0px)} + +<===> step_is_zero/output.css +a { + b: calc(NaN * 1px); +} + +<===> +================================================================================ +<===> positive_and_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(down, 10, infinity))} + +<===> positive_and_infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> negative_and_infinity/input.scss +@use "sass:math"; +a {b: round(down, -10, infinity)} + +<===> negative_and_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> upper_multiple/number_is_bigger/input.scss +a {b: round(down, 23px, 10px)} + +<===> upper_multiple/number_is_bigger/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_smaller/input.scss +a {b: round(down, 18px, 10px)} + +<===> upper_multiple/number_is_smaller/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_half/input.scss +a {b: round(down, 15px, 10px)} + +<===> upper_multiple/number_is_half/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_negative/input.scss +a {b: round(down, -13px, 10px)} + +<===> upper_multiple/number_is_negative/output.css +a { + b: -20px; +} + +<===> +================================================================================ +<===> lower_multiple/number_is_bigger/input.scss +a {b: round(down, 13px, 10px)} + +<===> lower_multiple/number_is_bigger/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> lower_multiple/number_is_negative/input.scss +a {b: round(down, -18px, 10px)} + +<===> lower_multiple/number_is_negative/output.css +a { + b: -20px; +} + +<===> +================================================================================ +<===> negative_zero/positive_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(down, -1 * 0, infinity))} + +<===> negative_zero/positive_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> positive_zero/zero/input.scss +@use "sass:math"; +a {b: math.div(1, round(down, 0, infinity))} + +<===> positive_zero/zero/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> positive_zero/one/input.scss +@use "sass:math"; +a {b: math.div(1, round(down, 1, infinity))} + +<===> positive_zero/one/output.css +a { + b: calc(infinity); +} diff --git a/spec/values/calculation/round/strategy/nearest.hrx b/spec/values/calculation/round/strategy/nearest.hrx new file mode 100644 index 0000000000..743b56244c --- /dev/null +++ b/spec/values/calculation/round/strategy/nearest.hrx @@ -0,0 +1,227 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `round()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: round(nearest, 3.8px - 1px + var(--test), 1.1px + 4px)} + +<===> simplification/output.css +a { + b: round(nearest, 2.8px + var(--test), 5.1px); +} + +<===> +================================================================================ +<===> positive/input.scss +a {b: round(nearest, 117px, 25px)} + +<===> positive/output.css +a { + b: 125px; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: round(nearest, -101, -25)} + +<===> negative/output.css +a { + b: -100; +} + +<===> +================================================================================ +<===> step_is_zero/input.scss +a {b: round(nearest, 10px, 0px)} + +<===> step_is_zero/output.css +a { + b: calc(NaN * 1px); +} + +<===> +================================================================================ +<===> positive_and_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(nearest, 10, infinity))} + +<===> positive_and_infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> negative_and_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(nearest, -10, infinity))} + +<===> negative_and_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> infinity_and_negative/input.scss +a {b: round(nearest, infinity, -5)} + +<===> infinity_and_negative/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> infinity_and_positive/input.scss +a {b: round(nearest, infinity, 5)} + +<===> infinity_and_positive/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> negative_infinity_and_negative/input.scss +a {b: round(nearest, -infinity, -5)} + +<===> negative_infinity_and_negative/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> negative_infinity_and_positive/input.scss +a {b: round(nearest, -infinity, 5)} + +<===> negative_infinity_and_positive/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> infinity/negative/input.scss +a {b: round(nearest, -infinity, -infinity)} + +<===> infinity/negative/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> infinity/negative_and_positive/input.scss +a {b: round(nearest, -infinity, infinity)} + +<===> infinity/negative_and_positive/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> infinity/positive_and_negative/input.scss +a {b: round(nearest, infinity, -infinity)} + +<===> infinity/positive_and_negative/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> infinity/positive_and_positive/input.scss +@use "sass:math"; +a {b: round(nearest, infinity, infinity)} + +<===> infinity/positive_and_positive/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> step_is_multiple_of_number/input.scss +a {b: round(nearest, 5px, 25px)} + +<===> step_is_multiple_of_number/output.css +a { + b: 0px; +} + +<===> +================================================================================ +<===> number_is_multiple_of_step/input.scss +a {b: round(nearest, 25px, 5px)} + +<===> number_is_multiple_of_step/output.css +a { + b: 25px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_bigger/input.scss +a {b: round(nearest, 23px, 10px)} + +<===> upper_multiple/number_is_bigger/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_smaller/input.scss +a {b: round(nearest, 18px, 10px)} + +<===> upper_multiple/number_is_smaller/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_half/input.scss +a {b: round(nearest, 15px, 10px)} + +<===> upper_multiple/number_is_half/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_negative/input.scss +a {b: round(nearest, -13px, 10px)} + +<===> upper_multiple/number_is_negative/output.css +a { + b: -10px; +} + +<===> +================================================================================ +<===> lower_multiple/number_is_bigger/input.scss +a {b: round(nearest, 13px, 10px)} + +<===> lower_multiple/number_is_bigger/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> lower_multiple/number_is_negative/input.scss +a {b: round(nearest, -18px, 10px)} + +<===> lower_multiple/number_is_negative/output.css +a { + b: -20px; +} diff --git a/spec/values/calculation/round/strategy/to-zero.hrx b/spec/values/calculation/round/strategy/to-zero.hrx new file mode 100644 index 0000000000..8d9b36628f --- /dev/null +++ b/spec/values/calculation/round/strategy/to-zero.hrx @@ -0,0 +1,127 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `round()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> strategy/to-zero/positive/input.scss +a {b: round(to-zero, 120px, 25px)} + +<===> strategy/to-zero/positive/output.css +a { + b: 100px; +} + +<===> +================================================================================ +<===> strategy/to-zero/negative/input.scss +a {b: round(to-zero, -120px, -25px)} + +<===> strategy/to-zero/negative/output.css +a { + b: -125px; +} + +<===> +================================================================================ +<===> strategy/to-zero/upper_multiple/number_is_bigger/input.scss +a {b: round(to-zero, 23px, 10px)} + +<===> strategy/to-zero/upper_multiple/number_is_bigger/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> strategy/to-zero/upper_multiple/number_is_smaller/input.scss +a {b: round(to-zero, 18px, 10px)} + +<===> strategy/to-zero/upper_multiple/number_is_smaller/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> strategy/to-zero/upper_multiple/number_is_half/input.scss +a {b: round(to-zero, 15px, 10px)} + +<===> strategy/to-zero/upper_multiple/number_is_half/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> strategy/to-zero/upper_multiple/number_is_negative/input.scss +a {b: round(to-zero, -13px, 10px)} + +<===> strategy/to-zero/upper_multiple/number_is_negative/output.css +a { + b: -10px; +} + +<===> +================================================================================ +<===> strategy/to-zero/lower_multiple/number_is_bigger/input.scss +a {b: round(to-zero, 13px, 10px)} + +<===> strategy/to-zero/lower_multiple/number_is_bigger/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> strategy/to-zero/lower_multiple/number_is_negative/input.scss +a {b: round(to-zero, -18px, 10px)} + +<===> strategy/to-zero/lower_multiple/number_is_negative/output.css +a { + b: -10px; +} + +<===> +================================================================================ +<===> strategy/to-zero/negative_zero/positive_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(to-zero, -5, infinity))} + +<===> strategy/to-zero/negative_zero/positive_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> strategy/to-zero/negative_zero/negative_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(to-zero, -5, -infinity))} + +<===> strategy/to-zero/negative_zero/negative_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> strategy/to-zero/positive_zero/positive_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(to-zero, 5, infinity))} + +<===> strategy/to-zero/positive_zero/positive_infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> strategy/to-zero/positive_zero/negative_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(to-zero, 5, -infinity))} + +<===> strategy/to-zero/positive_zero/negative_infinity/output.css +a { + b: calc(infinity); +} diff --git a/spec/values/calculation/round/strategy/up.hrx b/spec/values/calculation/round/strategy/up.hrx new file mode 100644 index 0000000000..9bf46be19e --- /dev/null +++ b/spec/values/calculation/round/strategy/up.hrx @@ -0,0 +1,187 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `round()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> strategy/up/positive/input.scss +a {b: round(up, 101px, 25px)} + +<===> strategy/up/positive/output.css +a { + b: 125px; +} + +<===> +================================================================================ +<===> strategy/up/step_is_multiple_of_number/input.scss +a {b: round(up, 5px, 25px)} + +<===> strategy/up/step_is_multiple_of_number/output.css +a { + b: 25px; +} + +<===> +================================================================================ +<===> strategy/up/number_is_multiple_of_step/input.scss +a {b: round(up, 25px, 5px)} + +<===> strategy/up/number_is_multiple_of_step/output.css +a { + b: 25px; +} + +<===> +================================================================================ +<===> strategy/up/negative/input.scss +a {b: round(up, -101, -25)} + +<===> strategy/up/negative/output.css +a { + b: -100; +} + +<===> +================================================================================ +<===> strategy/up/negative_step/input.scss +a {b: round(up, 12px, -7px)} + +<===> strategy/up/negative_step/output.css +a { + b: 14px; +} + +<===> +================================================================================ +<===> strategy/up/step_is_zero/input.scss +a {b: round(up, 10px, 0px)} + +<===> strategy/up/step_is_zero/output.css +a { + b: calc(NaN * 1px); +} + +<===> +================================================================================ +<===> strategy/up/positive_and_infinity/input.scss +a {b: round(up, 10, infinity)} + +<===> strategy/up/positive_and_infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> strategy/up/negative_and_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(up, -10, infinity))} + +<===> strategy/up/negative_and_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> strategy/up/infinity/input.scss +@use "sass:math"; +a {b: round(up, infinity, infinity)} + +<===> strategy/up/infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> strategy/up/upper_multiple/number_is_bigger/input.scss +a {b: round(up, 23px, 10px)} + +<===> strategy/up/upper_multiple/number_is_bigger/output.css +a { + b: 30px; +} + +<===> +================================================================================ +<===> strategy/up/upper_multiple/number_is_smaller/input.scss +a {b: round(up, 18px, 10px)} + +<===> strategy/up/upper_multiple/number_is_smaller/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> strategy/up/upper_multiple/number_is_half/input.scss +a {b: round(up, 15px, 10px)} + +<===> strategy/up/upper_multiple/number_is_half/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> strategy/up/upper_multiple/number_is_negative/input.scss +a {b: round(up, -13px, 10px)} + +<===> strategy/up/upper_multiple/number_is_negative/output.css +a { + b: -10px; +} + +<===> +================================================================================ +<===> strategy/up/lower_multiple/number_is_bigger/input.scss +a {b: round(up, 13px, 10px)} + +<===> strategy/up/lower_multiple/number_is_bigger/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> strategy/up/lower_multiple/number_is_negative/input.scss +a {b: round(up, -18px, 10px)} + +<===> strategy/up/lower_multiple/number_is_negative/output.css +a { + b: -10px; +} + +<===> +================================================================================ +<===> strategy/up/negative_zero/positive_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(up, -1 * 0, infinity))} + +<===> strategy/up/negative_zero/positive_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> strategy/up/positive_zero/zero/input.scss +@use "sass:math"; +a {b: math.div(1, round(up, 0, infinity))} + +<===> strategy/up/positive_zero/zero/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> strategy/up/positive_zero/one/input.scss +a {b: round(up, 1, infinity)} + +<===> strategy/up/positive_zero/one/output.css +a { + b: calc(infinity); +} diff --git a/spec/values/calculation/round/three_arguments.hrx b/spec/values/calculation/round/three_arguments.hrx new file mode 100644 index 0000000000..45579e68e5 --- /dev/null +++ b/spec/values/calculation/round/three_arguments.hrx @@ -0,0 +1,59 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `round()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> strategy/unknown_variable/input.scss +a { + e: round(var(--c), 8px, 9px); +} +<===> strategy/unknown_variable/output.css +a { + e: round(var(--c), 8px, 9px); +} + +<===> +================================================================================ +<===> step/unknown_variable/input.scss +a { + d: round(up, 8px, var(--c)); +} +<===> step/unknown_variable/output.css +a { + d: round(up, 8px, var(--c)); +} + +<===> +================================================================================ +<===> preserved/interpolation/input.scss +a { + e: round(#{"up"}, 3px, 9px); +} + +<===> preserved/interpolation/output.css +a { + e: round(up, 3px, 9px); +} + +<===> +================================================================================ +<===> units/real_and_unknown/input.scss +a {b: round(nearest, 1px, 10%)} + +<===> units/real_and_unknown/output.css +a { + b: round(nearest, 1px, 10%); +} + +<===> +================================================================================ +<===> units/unknown/input.scss +a { + b: round(nearest, 1%, 2%); +} + +<===> units/unknown/output.css +a { + b: 2%; +} diff --git a/spec/values/calculation/round/two_arguments.hrx b/spec/values/calculation/round/two_arguments.hrx new file mode 100644 index 0000000000..3971116e8e --- /dev/null +++ b/spec/values/calculation/round/two_arguments.hrx @@ -0,0 +1,321 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `round()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> units/none/input.scss +a {b: round(117, 25)} + +<===> units/none/output.css +a { + b: 125; +} + +<===> +================================================================================ +<===> units/compatible/input.scss +a {b: round(117cm, 25mm)} + +<===> units/compatible/output.css +a { + b: 117.5cm; +} + +<===> +================================================================================ +<===> units/real_and_unknown/input.scss +a {b: round(1px, 10%)} + +<===> units/real_and_unknown/output.css +a { + b: round(1px, 10%); +} + +<===> +================================================================================ +<===> units/unknown/input.scss +a { + b: round(1%, 2%); +} + +<===> units/unknown/output.css +a { + b: 2%; +} + +<===> +================================================================================ +<===> units/fake/input.scss +a { + b: round(1foo, 2bar); +} + +<===> units/fake/output.css +a { + b: round(1foo, 2bar); +} + +<===> +================================================================================ +<===> units/same_fake/input.scss +a { + b: round(1foo, 2foo); +} + +<===> units/same_fake/output.css +a { + b: 2foo; +} + +<===> +================================================================================ +<===> units/real_and_fake/input.scss +a { + b: round(1px, 2bar); +} + +<===> units/real_and_fake/output.css +a { + b: round(1px, 2bar); +} + +<===> +================================================================================ +<===> simplification/input.scss +a {b: round(3.4px + 10%, 1px + 4px)} + +<===> simplification/output.css +a { + b: round(3.4px + 10%, 5px); +} + +<===> +================================================================================ +<===> step_is_zero/input.scss +a {b: round(5px, 0px)} + +<===> step_is_zero/output.css +a { + b: calc(NaN * 1px); +} + +<===> +================================================================================ +<===> equals/input.scss +a {b: round(10px, 10px)} + +<===> equals/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> nan/input.scss +a {b: round(NaN, NaN)} + +<===> nan/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> unknown_variable/input.scss +a { + c: round(up, var(--c)); +} + +<===> unknown_variable/output.css +a { + c: round(up, var(--c)); +} + +<===> +================================================================================ +<===> preserved/interpolation/input.scss +a { + e: round(#{"5.5px, 1px"}); +} + +<===> preserved/interpolation/output.css +a { + e: round(5.5px, 1px); +} + +<===> +================================================================================ +<===> upper_multiple/number_is_bigger/input.scss +a {b: round(23px, 10px)} + +<===> upper_multiple/number_is_bigger/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_smaller/input.scss +a {b: round(18px, 10px)} + +<===> upper_multiple/number_is_smaller/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_half/input.scss +a {b: round(15px, 10px)} + +<===> upper_multiple/number_is_half/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> upper_multiple/number_is_negative/input.scss +a {b: round(-13px, 10px)} + +<===> upper_multiple/number_is_negative/output.css +a { + b: -10px; +} + +<===> +================================================================================ +<===> lower_multiple/number_is_bigger/input.scss +a {b: round(13px, 10px)} + +<===> lower_multiple/number_is_bigger/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> lower_multiple/number_is_negative/input.scss +a {b: round(-18px, 10px)} + +<===> lower_multiple/number_is_negative/output.css +a { + b: -20px; +} + +<===> +================================================================================ +<===> negative_zero/positive_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(-5, infinity))} + +<===> negative_zero/positive_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> negative_zero/negative_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(-5, -infinity))} + +<===> negative_zero/negative_infinity/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> positive_zero/positive_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(5, infinity))} + +<===> positive_zero/positive_infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> positive_zero/negative_infinity/input.scss +@use "sass:math"; +a {b: math.div(1, round(5, -infinity))} + +<===> positive_zero/negative_infinity/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> negative_step/upper_multiple/number_is_bigger/input.scss +a {b: round(23px, -10px)} + +<===> negative_step/upper_multiple/number_is_bigger/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> negative_step/upper_multiple/number_is_smaller/input.scss +a {b: round(18px, -10px)} + +<===> negative_step/upper_multiple/number_is_smaller/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> negative_step/upper_multiple/number_is_half/input.scss +a {b: round(15px, -10px)} + +<===> negative_step/upper_multiple/number_is_half/output.css +a { + b: 20px; +} + +<===> +================================================================================ +<===> negative_step/upper_multiple/number_is_negative/input.scss +a {b: round(-13px, -10px)} + +<===> negative_step/upper_multiple/number_is_negative/output.css +a { + b: -10px; +} + +<===> +================================================================================ +<===> negative_step/lower_multiple/number_is_bigger/input.scss +a {b: round(13px, -10px)} + +<===> negative_step/lower_multiple/number_is_bigger/output.css +a { + b: 10px; +} + +<===> +================================================================================ +<===> negative_step/lower_multiple/number_is_negative/input.scss +a {b: round(-18px, -10px)} + +<===> negative_step/lower_multiple/number_is_negative/output.css +a { + b: -20px; +} + +<===> +================================================================================ +<===> math/unknown_units/input.scss +a { + b: round(1px + 0%, 1px + 0%); +} + +<===> math/unknown_units/output.css +a { + b: round(1px + 0%, 1px + 0%); +} diff --git a/spec/values/calculation/sign.hrx b/spec/values/calculation/sign.hrx new file mode 100644 index 0000000000..8226107a2d --- /dev/null +++ b/spec/values/calculation/sign.hrx @@ -0,0 +1,152 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `sign()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> positive/input.scss +a {b: sign(3)} + +<===> positive/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: sign(-5.6)} + +<===> negative/output.css +a { + b: -1; +} + +<===> +================================================================================ +<===> zero/input.scss +@use "sass:math"; +a {b: math.div(1, sign(0))} + +<===> zero/output.css +a { + b: calc(infinity); +} + +<===> +================================================================================ +<===> nan/input.scss +a {b: sign(NaN)} + +<===> nan/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> negative_zero/input.scss +@use "sass:math"; +a {b: math.div(1, sign(-0.0))} + +<===> negative_zero/output.css +a { + b: calc(-infinity); +} + +<===> +================================================================================ +<===> zero_fuzzy/input.scss +a {b: sign(0.000000000001)} + +<===> zero_fuzzy/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> preserves_units/input.scss +a {b: sign(-7px / 4em) * 1em} + +<===> preserves_units/output.css +a { + b: -1px; +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: sign(1px + 2px - var(--c)) +} + +<===> simplification/output.css +a { + b: sign(3px - var(--c)); +} + +<===> +================================================================================ +<===> error/type/input.scss +a {b: sign("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: sign("0")} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: sign()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: sign()} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: sign(0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: sign(0, 0)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: sign($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: sign($)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: sign(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: sign(7 % 3)} + | ^ + ' + input.scss 1:14 root stylesheet diff --git a/spec/values/calculation/sin.hrx b/spec/values/calculation/sin.hrx new file mode 100644 index 0000000000..5be9f9933d --- /dev/null +++ b/spec/values/calculation/sin.hrx @@ -0,0 +1,199 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `sin()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> deg/input.scss +a {b: sin(1deg)} + +<===> deg/output.css +a { + b: 0.0174524064; +} + +<===> +================================================================================ +<===> grad/input.scss +a {b: sin(1grad)} + +<===> grad/output.css +a { + b: 0.0157073173; +} + +<===> +================================================================================ +<===> rad/input.scss +a {b: sin(1rad)} + +<===> rad/output.css +a { + b: 0.8414709848; +} + +<===> +================================================================================ +<===> turn/input.scss +a {b: sin(1turn)} + +<===> turn/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> negative_infinity/input.scss +a {b: sin(-infinity)} + +<===> negative_infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> negative_one/input.scss +a {b: sin(-1)} + +<===> negative_one/output.css +a { + b: -0.8414709848; +} + +<===> +================================================================================ +<===> zero/input.scss +a {b: sin(0)} + +<===> zero/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> infinity/input.scss +a {b: sin(infinity)} + +<===> infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: sin(3px - 1px + var(--c)); +} + +<===> simplification/output.css +a { + b: sin(2px + var(--c)); +} + +<===> +================================================================================ +<===> error/units/unknown/input.scss +a {b: sin(1%)} + +<===> error/units/unknown/error +Error: $number: Expected 1% to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: sin(1%)} + | ^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/known/input.scss +a {b: sin(1px)} + +<===> error/units/known/error +Error: $number: Expected 1px to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: sin(1px)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/complex/input.scss +a {b: sin(-7px / 4em)} + +<===> error/units/complex/error +Error: $number: Expected -1.75px/em to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: sin(-7px / 4em)} + | ^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: sin("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: sin("0")} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: sin()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: sin()} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: sin(0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: sin(0, 0)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: sin($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: sin($)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: sin(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: sin(7 % 3)} + | ^ + ' + input.scss 1:13 root stylesheet diff --git a/spec/values/calculation/sqrt.hrx b/spec/values/calculation/sqrt.hrx new file mode 100644 index 0000000000..aa920ed49b --- /dev/null +++ b/spec/values/calculation/sqrt.hrx @@ -0,0 +1,136 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `sqrt()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> zero/input.scss +a {b: sqrt(0)} + +<===> zero/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> units/unitless/input.scss +a {b: sqrt(2)} + +<===> units/unitless/output.css +a { + b: 1.4142135624; +} + +<===> +================================================================================ +<===> negative/input.scss +a {b: sqrt(-9)} + +<===> negative/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: sqrt(1px + 2px - var(--c)) +} + +<===> simplification/output.css +a { + b: sqrt(3px - var(--c)); +} + +<===> +================================================================================ +<===> error/units/unknown/input.scss +a {b: sqrt(1%)} + +<===> error/units/unknown/error +Error: Expected 1% to have no units. + , +1 | a {b: sqrt(1%)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/real/input.scss +a {b: sqrt(16px)} + +<===> error/units/real/error +Error: Expected 16px to have no units. + , +1 | a {b: sqrt(16px)} + | ^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: sqrt("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: sqrt("0")} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/syntax/too_few_args/input.scss +a {b: sqrt()} + +<===> error/syntax/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: sqrt()} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: sqrt($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: sqrt($)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: sqrt(3, 4)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: sqrt(3, 4)} + | ^ + ' + input.scss 1:13 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: sqrt(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: sqrt(7 % 3)} + | ^ + ' + input.scss 1:14 root stylesheet diff --git a/spec/values/calculation/tan.hrx b/spec/values/calculation/tan.hrx new file mode 100644 index 0000000000..ffd2ec314d --- /dev/null +++ b/spec/values/calculation/tan.hrx @@ -0,0 +1,199 @@ +<===> README.md +Most of the same behavior tested for `calc()` applies to `tan()`, but for +terseness' sake isn't tested explicitly. + +<===> +================================================================================ +<===> deg/input.scss +a {b: tan(1deg)} + +<===> deg/output.css +a { + b: 0.0174550649; +} + +<===> +================================================================================ +<===> grad/input.scss +a {b: tan(1grad)} + +<===> grad/output.css +a { + b: 0.0157092553; +} + +<===> +================================================================================ +<===> rad/input.scss +a {b: tan(1rad)} + +<===> rad/output.css +a { + b: 1.5574077247; +} + +<===> +================================================================================ +<===> turn/input.scss +a {b: tan(1turn)} + +<===> turn/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> negative_infinity/input.scss +a {b: tan(-infinity)} + +<===> negative_infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> negative_one/input.scss +a {b: tan(-1)} + +<===> negative_one/output.css +a { + b: -1.5574077247; +} + +<===> +================================================================================ +<===> zero/input.scss +a {b: tan(0)} + +<===> zero/output.css +a { + b: 0; +} + +<===> +================================================================================ +<===> infinity/input.scss +a {b: tan(infinity)} + +<===> infinity/output.css +a { + b: calc(NaN); +} + +<===> +================================================================================ +<===> simplification/input.scss +a { + b: tan(3px - 1px + var(--c)); +} + +<===> simplification/output.css +a { + b: tan(2px + var(--c)); +} + +<===> +================================================================================ +<===> error/units/unknown/input.scss +a {b: tan(1%)} + +<===> error/units/unknown/error +Error: $number: Expected 1% to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: tan(1%)} + | ^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/known/input.scss +a {b: tan(1px)} + +<===> error/units/known/error +Error: $number: Expected 1px to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: tan(1px)} + | ^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/units/complex/input.scss +a {b: tan(-7px / 4em)} + +<===> error/units/complex/error +Error: $number: Expected -1.75px/em to have an angle unit (deg, grad, rad, turn). + , +1 | a {b: tan(-7px / 4em)} + | ^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> error/type/input.scss +a {b: tan("0")} + +<===> error/type/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: tan("0")} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +a {b: tan()} + +<===> error/too_few_args/error +Error: Expected number, variable, function, or calculation. + , +1 | a {b: tan()} + | ^ + ' + input.scss 1:11 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +a {b: tan(0, 0)} + +<===> error/too_many_args/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: tan(0, 0)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/syntax/invalid_arg/input.scss +a {b: tan($)} + +<===> error/syntax/invalid_arg/error +Error: Expected identifier. + , +1 | a {b: tan($)} + | ^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> error/sass_script/input.scss +a {b: tan(7 % 3)} + +<===> error/sass_script/error +Error: expected "+", "-", "*", "/", or ")". + , +1 | a {b: tan(7 % 3)} + | ^ + ' + input.scss 1:13 root stylesheet From 66cbb9fec6b4acc37804be65ad5a22f8eb38a6bf Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 31 Aug 2023 17:16:45 -0700 Subject: [PATCH 2/5] Update existing tests for new calculation parsing --- .../plain/error/expression/calculation.hrx | 12 +-- spec/css/plain/error/expression/list.hrx | 12 +-- spec/css/plain/error/expression/map.hrx | 6 +- .../plain/error/expression/parentheses.hrx | 2 +- spec/libsass-closed-issues/issue_246.hrx | 4 +- spec/values/calculation/abs.hrx | 21 ++--- spec/values/calculation/acos.hrx | 18 ++--- spec/values/calculation/asin.hrx | 18 ++--- spec/values/calculation/atan.hrx | 18 ++--- spec/values/calculation/atan2.hrx | 16 ++-- spec/values/calculation/calc/error/syntax.hrx | 76 ++++++++++++++----- spec/values/calculation/calc/no_operator.hrx | 14 +--- spec/values/calculation/calc/operator.hrx | 52 +++++++++---- spec/values/calculation/clamp.hrx | 18 ++--- spec/values/calculation/cos.hrx | 18 ++--- spec/values/calculation/exp.hrx | 19 +++-- spec/values/calculation/hypot.hrx | 16 ++-- spec/values/calculation/log.hrx | 22 +++--- spec/values/calculation/max.hrx | 2 +- spec/values/calculation/min.hrx | 2 +- spec/values/calculation/mod.hrx | 16 ++-- spec/values/calculation/pow.hrx | 16 ++-- spec/values/calculation/rem.hrx | 16 ++-- spec/values/calculation/round/error.hrx | 20 ++--- .../calculation/round/three_arguments.hrx | 18 ++--- spec/values/calculation/sign.hrx | 18 ++--- spec/values/calculation/sin.hrx | 18 ++--- spec/values/calculation/sqrt.hrx | 18 ++--- spec/values/calculation/tan.hrx | 18 ++--- 29 files changed, 276 insertions(+), 248 deletions(-) diff --git a/spec/css/plain/error/expression/calculation.hrx b/spec/css/plain/error/expression/calculation.hrx index 696032fcfb..50db29cf0a 100644 --- a/spec/css/plain/error/expression/calculation.hrx +++ b/spec/css/plain/error/expression/calculation.hrx @@ -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 <===> @@ -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 diff --git a/spec/css/plain/error/expression/list.hrx b/spec/css/plain/error/expression/list.hrx index bdd261082f..283ce7e5c2 100644 --- a/spec/css/plain/error/expression/list.hrx +++ b/spec/css/plain/error/expression/list.hrx @@ -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 <===> @@ -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 diff --git a/spec/css/plain/error/expression/map.hrx b/spec/css/plain/error/expression/map.hrx index 976f7cb8ad..3939ea085e 100644 --- a/spec/css/plain/error/expression/map.hrx +++ b/spec/css/plain/error/expression/map.hrx @@ -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 diff --git a/spec/css/plain/error/expression/parentheses.hrx b/spec/css/plain/error/expression/parentheses.hrx index c96695f618..3dc81f4164 100644 --- a/spec/css/plain/error/expression/parentheses.hrx +++ b/spec/css/plain/error/expression/parentheses.hrx @@ -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 diff --git a/spec/libsass-closed-issues/issue_246.hrx b/spec/libsass-closed-issues/issue_246.hrx index a4ba8966a1..bc807ac61f 100644 --- a/spec/libsass-closed-issues/issue_246.hrx +++ b/spec/libsass-closed-issues/issue_246.hrx @@ -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 diff --git a/spec/values/calculation/abs.hrx b/spec/values/calculation/abs.hrx index d06e33694a..9782305f8a 100644 --- a/spec/values/calculation/abs.hrx +++ b/spec/values/calculation/abs.hrx @@ -110,8 +110,11 @@ 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); | ^^^^^^^^^^^^^^ @@ -150,14 +153,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 @@ -168,13 +167,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 diff --git a/spec/values/calculation/acos.hrx b/spec/values/calculation/acos.hrx index 35081f4eb3..eeb31cdac7 100644 --- a/spec/values/calculation/acos.hrx +++ b/spec/values/calculation/acos.hrx @@ -109,10 +109,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 @@ -122,12 +122,12 @@ 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 <===> ================================================================================ @@ -135,12 +135,12 @@ Error: Expected number, variable, function, or calculation. 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 <===> ================================================================================ @@ -161,7 +161,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)} | ^ diff --git a/spec/values/calculation/asin.hrx b/spec/values/calculation/asin.hrx index 0731aceaaa..0384150576 100644 --- a/spec/values/calculation/asin.hrx +++ b/spec/values/calculation/asin.hrx @@ -109,10 +109,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 @@ -122,12 +122,12 @@ 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 <===> ================================================================================ @@ -135,12 +135,12 @@ Error: Expected number, variable, function, or calculation. 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 <===> ================================================================================ @@ -161,7 +161,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)} | ^ diff --git a/spec/values/calculation/atan.hrx b/spec/values/calculation/atan.hrx index c1e3d88cf1..ba27fbc3f3 100644 --- a/spec/values/calculation/atan.hrx +++ b/spec/values/calculation/atan.hrx @@ -99,10 +99,10 @@ Error: Expected -1.75px/em to have no units. a {b: atan("0")} <===> error/type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: atan("0")} - | ^ + | ^^^ ' input.scss 1:12 root stylesheet @@ -112,12 +112,12 @@ Error: Expected number, variable, function, or calculation. a {b: atan()} <===> error/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: atan()} - | ^ + | ^^^^^^ ' - input.scss 1:12 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -125,12 +125,12 @@ Error: Expected number, variable, function, or calculation. a {b: atan(0, 0)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 1 argument allowed, but 2 were passed. , 1 | a {b: atan(0, 0)} - | ^ + | ^^^^^^^^^^ ' - input.scss 1:13 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -138,7 +138,7 @@ Error: expected "+", "-", "*", "/", or ")". a {b: atan(7 % 3)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: atan(7 % 3)} | ^ diff --git a/spec/values/calculation/atan2.hrx b/spec/values/calculation/atan2.hrx index 11d3247bec..cad4dd0f9b 100644 --- a/spec/values/calculation/atan2.hrx +++ b/spec/values/calculation/atan2.hrx @@ -152,10 +152,10 @@ Error: Expected identifier. a {b: atan2(0, "0")} <===> error/x_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: atan2(0, "0")} - | ^ + | ^^^ ' input.scss 1:16 root stylesheet @@ -165,10 +165,10 @@ Error: Expected number, variable, function, or calculation. a {b: atan2("0", 0)} <===> error/y_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: atan2("0", 0)} - | ^ + | ^^^ ' input.scss 1:13 root stylesheet @@ -191,12 +191,12 @@ Error: 2 arguments required, but only 1 was passed. a {b: atan2(0, 0, 0)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 2 arguments allowed, but 3 were passed. , 1 | a {b: atan2(0, 0, 0)} - | ^ + | ^^^^^^^^^^^^^^ ' - input.scss 1:17 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -204,7 +204,7 @@ Error: expected "+", "-", "*", "/", or ")". a {b: atan2(7 % 3, 1)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", ",", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: atan2(7 % 3, 1)} | ^ diff --git a/spec/values/calculation/calc/error/syntax.hrx b/spec/values/calculation/calc/error/syntax.hrx index 89db4e06e4..8d803d73cb 100644 --- a/spec/values/calculation/calc/error/syntax.hrx +++ b/spec/values/calculation/calc/error/syntax.hrx @@ -2,12 +2,12 @@ a {b: calc()} <===> empty/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: calc()} - | ^ + | ^^^^^^ ' - input.scss 1:12 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -15,12 +15,12 @@ Error: Expected number, variable, function, or calculation. a {b: calc(+ 1px)} <===> leading_operator/error -Error: Expected digit. +Error: This expression can't be used in a calculation. , 1 | a {b: calc(+ 1px)} - | ^ + | ^^^^^ ' - input.scss 1:13 root stylesheet + input.scss 1:12 root stylesheet <===> ================================================================================ @@ -28,7 +28,7 @@ Error: Expected digit. a {b: calc(1px *)} <===> trailing_operator/error -Error: Expected number, variable, function, or calculation. +Error: Expected expression. , 1 | a {b: calc(1px *)} | ^ @@ -41,7 +41,7 @@ Error: Expected number, variable, function, or calculation. a {b: calc(1px ** 2px)} <===> double_operator/error -Error: Expected number, variable, function, or calculation. +Error: Expected expression. , 1 | a {b: calc(1px ** 2px)} | ^ @@ -54,12 +54,12 @@ Error: Expected number, variable, function, or calculation. a {b: calc(1px, 2px)} <===> multiple_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 1 argument allowed, but 2 were passed. , 1 | a {b: calc(1px, 2px)} - | ^ + | ^^^^^^^^^^^^^^ ' - input.scss 1:15 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -67,7 +67,7 @@ Error: expected "+", "-", "*", "/", or ")". a {b: calc(1px % 2px)} <===> unknown_operator/error -Error: expected "+", "-", "*", "/", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: calc(1px % 2px)} | ^ @@ -80,12 +80,12 @@ Error: expected "+", "-", "*", "/", or ")". a {b: calc(#)} <===> hash/error -Error: Expected number, variable, function, or calculation. +Error: Expected identifier. , 1 | a {b: calc(#)} - | ^ + | ^ ' - input.scss 1:12 root stylesheet + input.scss 1:13 root stylesheet <===> ================================================================================ @@ -106,12 +106,12 @@ Error: Expected identifier. a {b: calc(1 (#{c}))} <===> interpolation/in_parens/error -Error: expected "+", "-", "*", "/", or ")". +Error: This expression can't be used in a calculation. , 1 | a {b: calc(1 (#{c}))} - | ^ + | ^^^^^^^^ ' - input.scss 1:14 root stylesheet + input.scss 1:12 root stylesheet <===> ================================================================================ @@ -119,12 +119,12 @@ Error: expected "+", "-", "*", "/", or ")". a {b: calc(1 c(#{d}))} <===> interpolation/in_floating_function/error -Error: expected "+", "-", "*", "/", or ")". +Error: This expression can't be used in a calculation. , 1 | a {b: calc(1 c(#{d}))} - | ^ + | ^^^^^^^^^ ' - input.scss 1:14 root stylesheet + input.scss 1:12 root stylesheet <===> ================================================================================ @@ -139,6 +139,21 @@ Error: expected ")". ' input.scss 1:14 root stylesheet +<===> +================================================================================ +<===> interpolation/line_noise/input.scss +// Interpolation no longer shifts the parser into a special mode where it allows +// any interpolated declaration value. +a {b: calc(!{@}#$%^&*#{c}_-[+]=)} + +<===> interpolation/line_noise/error +Error: expected ")". + , +3 | a {b: calc(!{@}#$%^&*#{c}_-[+]=)} + | ^ + ' + input.scss 3:12 root stylesheet + <===> ================================================================================ <===> no_whitespace/plus/before/input.scss @@ -158,6 +173,25 @@ Error: "+" and "-" must be surrounded by whitespace in calculations. a {b: calc(1 +1)} <===> no_whitespace/plus/after/error +DEPRECATION WARNING on line 1, column 12 of input.scss: +This operation is parsed as: + + 1 + 1 + +but you may have intended it to mean: + + 1 (+1) + +Add a space after + to clarify that it's meant to be a binary operation, or wrap +it in parentheses to make it a unary operation. This will be an error in future +versions of Sass. + +More info and automated migrator: https://sass-lang.com/d/strict-unary + , +1 | a {b: calc(1 +1)} + | ^^^^ + ' + Error: "+" and "-" must be surrounded by whitespace in calculations. , 1 | a {b: calc(1 +1)} diff --git a/spec/values/calculation/calc/no_operator.hrx b/spec/values/calculation/calc/no_operator.hrx index a7c8ce3623..5d15fad3ff 100644 --- a/spec/values/calculation/calc/no_operator.hrx +++ b/spec/values/calculation/calc/no_operator.hrx @@ -385,18 +385,6 @@ a { b: max(1%, 2px); } -<===> -================================================================================ -<===> interpolation/line_noise/input.scss -// Interpolation shifts the parser into a special mode where it allows any -// interpolated declaration value. -a {b: calc(!{@}#$%^&*#{c}_-[+]=)} - -<===> interpolation/line_noise/output.css -a { - b: calc(!{@}#$%^&*c_-[+]=); -} - <===> ================================================================================ <===> interpolation/number/input.scss @@ -418,7 +406,7 @@ a {b: calc((#{1px + 2px}))} <===> interpolation/parens/output.css a { - b: calc(3px); + b: calc((3px)); } <===> diff --git a/spec/values/calculation/calc/operator.hrx b/spec/values/calculation/calc/operator.hrx index c2b8fa2431..367e2c8357 100644 --- a/spec/values/calculation/calc/operator.hrx +++ b/spec/values/calculation/calc/operator.hrx @@ -328,42 +328,52 @@ a { <===> ================================================================================ -<===> precedence/interpolation/parens/lhs/input.scss -a {b: calc((#{c}) + 1)} +<===> precedence/interpolation/parens/input.scss +a {b: calc((#{c}))} -<===> precedence/interpolation/parens/lhs/output.css +<===> precedence/interpolation/parens/output.css a { - b: calc((c) + 1); + b: calc((c)); } <===> ================================================================================ -<===> precedence/interpolation/parens/rhs/input.scss -a {b: calc(1 + (#{c}))} +<===> precedence/interpolation/calculation/plain/input.scss +a {b: calc(calc(#{c}))} -<===> precedence/interpolation/parens/rhs/output.css +<===> precedence/interpolation/calculation/plain/output.css a { - b: calc(1 + (c)); + b: calc(c); } <===> ================================================================================ -<===> precedence/interpolation/calculation/lhs/input.scss -a {b: calc(calc(#{c}) + 1)} +<===> precedence/interpolation/calculation/whitespace/input.scss +a {b: calc(calc(#{"c "}))} -<===> precedence/interpolation/calculation/lhs/output.css +<===> precedence/interpolation/calculation/whitespace/output.css a { - b: calc((c) + 1); + b: calc((c )); } <===> ================================================================================ -<===> precedence/interpolation/calculation/rhs/input.scss -a {b: calc(1 + calc(#{c}))} +<===> precedence/interpolation/calculation/slash/input.scss +a {b: calc(calc(#{"c/"}))} -<===> precedence/interpolation/calculation/rhs/output.css +<===> precedence/interpolation/calculation/slash/output.css a { - b: calc(1 + (c)); + b: calc((c/)); +} + +<===> +================================================================================ +<===> precedence/interpolation/calculation/asterisk/input.scss +a {b: calc(calc(#{"c*"}))} + +<===> precedence/interpolation/calculation/asterisk/output.css +a { + b: calc((c*)); } <===> @@ -457,6 +467,16 @@ a { b: calc(1 + var(--c)); } +<===> +================================================================================ +<===> var/calculation/input.scss +a {b: calc(1 + calc(var(--c)))} + +<===> var/calculation/output.css +a { + b: calc(1 + (var(--c))); +} + <===> ================================================================================ <===> sass_script/plus_string/lhs/input.scss diff --git a/spec/values/calculation/clamp.hrx b/spec/values/calculation/clamp.hrx index 79e09fa2d9..b79a28a30b 100644 --- a/spec/values/calculation/clamp.hrx +++ b/spec/values/calculation/clamp.hrx @@ -8,12 +8,12 @@ terseness' sake isn't tested explicitly. a {b: clamp()} <===> error/syntax/no_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: clamp()} - | ^ + | ^^^^^^^ ' - input.scss 1:13 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -47,12 +47,12 @@ Error: 3 arguments required, but only 2 were passed. a {b: clamp(1px, 2px, 3px, 4px)} <===> error/syntax/four_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 3 arguments allowed, but 4 were passed. , 1 | a {b: clamp(1px, 2px, 3px, 4px)} - | ^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 1:26 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -60,12 +60,12 @@ Error: expected "+", "-", "*", "/", or ")". a {b: clamp(1px 2px 3px...)} <===> error/syntax/rest/error -Error: expected "+", "-", "*", "/", ",", or ")". +Error: Rest arguments can't be used with calculations. , 1 | a {b: clamp(1px 2px 3px...)} - | ^ + | ^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 1:17 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ diff --git a/spec/values/calculation/cos.hrx b/spec/values/calculation/cos.hrx index f8b513517f..fef6f34ded 100644 --- a/spec/values/calculation/cos.hrx +++ b/spec/values/calculation/cos.hrx @@ -129,10 +129,10 @@ Error: $number: Expected -1.75px/em to have an angle unit (deg, grad, rad, turn) a {b: cos("0")} <===> error/type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: cos("0")} - | ^ + | ^^^ ' input.scss 1:11 root stylesheet @@ -142,12 +142,12 @@ Error: Expected number, variable, function, or calculation. a {b: cos()} <===> error/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: cos()} - | ^ + | ^^^^^ ' - input.scss 1:11 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -155,12 +155,12 @@ Error: Expected number, variable, function, or calculation. a {b: cos(0, 0)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 1 argument allowed, but 2 were passed. , 1 | a {b: cos(0, 0)} - | ^ + | ^^^^^^^^^ ' - input.scss 1:12 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -181,7 +181,7 @@ Error: Expected identifier. a {b: cos(7 % 3)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: cos(7 % 3)} | ^ diff --git a/spec/values/calculation/exp.hrx b/spec/values/calculation/exp.hrx index 307fa827a8..baeea8c370 100644 --- a/spec/values/calculation/exp.hrx +++ b/spec/values/calculation/exp.hrx @@ -86,10 +86,10 @@ Error: Expected 1px to have no units. a {b: exp("0")} <===> error/type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: exp("0")} - | ^ + | ^^^ ' input.scss 1:11 root stylesheet @@ -99,12 +99,12 @@ Error: Expected number, variable, function, or calculation. a {b: exp()} <===> error/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: exp()} - | ^ + | ^^^^^ ' - input.scss 1:11 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -112,12 +112,12 @@ Error: Expected number, variable, function, or calculation. a {b: exp(0, 0)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 1 argument allowed, but 2 were passed. , 1 | a {b: exp(0, 0)} - | ^ + | ^^^^^^^^^ ' - input.scss 1:12 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -138,10 +138,9 @@ Error: Expected identifier. a {b: exp(7 % 3)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: exp(7 % 3)} | ^ ' input.scss 1:13 root stylesheet - diff --git a/spec/values/calculation/hypot.hrx b/spec/values/calculation/hypot.hrx index d1a124a5c6..0129372e7d 100644 --- a/spec/values/calculation/hypot.hrx +++ b/spec/values/calculation/hypot.hrx @@ -187,10 +187,10 @@ Error: 1px and 1 are incompatible. a {b: hypot("0", 1px, 1px)} <===> error/first_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: hypot("0", 1px, 1px)} - | ^ + | ^^^ ' input.scss 1:13 root stylesheet @@ -200,10 +200,10 @@ Error: Expected number, variable, function, or calculation. a {b: hypot(1px, "0", 1px)} <===> error/second_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: hypot(1px, "0", 1px)} - | ^ + | ^^^ ' input.scss 1:18 root stylesheet @@ -213,12 +213,12 @@ Error: Expected number, variable, function, or calculation. a {b: hypot()} <===> error/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: hypot()} - | ^ + | ^^^^^^^ ' - input.scss 1:13 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -239,7 +239,7 @@ Error: Expected identifier. a {b: hypot(7 % 3, 1)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", ",", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: hypot(7 % 3, 1)} | ^ diff --git a/spec/values/calculation/log.hrx b/spec/values/calculation/log.hrx index c2481a490e..c0c0b3665e 100644 --- a/spec/values/calculation/log.hrx +++ b/spec/values/calculation/log.hrx @@ -175,10 +175,10 @@ Error: Expected 3px to have no units. a {b: log("0")} <===> error/number_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: log("0")} - | ^ + | ^^^ ' input.scss 1:11 root stylesheet @@ -188,10 +188,10 @@ Error: Expected number, variable, function, or calculation. a {b: log(0, "0")} <===> error/base_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: log(0, "0")} - | ^ + | ^^^ ' input.scss 1:14 root stylesheet @@ -201,12 +201,12 @@ Error: Expected number, variable, function, or calculation. a {b: log()} <===> error/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: log()} - | ^ + | ^^^^^ ' - input.scss 1:11 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -214,12 +214,12 @@ Error: Expected number, variable, function, or calculation. a {b: log(0, 0, 0)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 2 arguments allowed, but 3 were passed. , 1 | a {b: log(0, 0, 0)} - | ^ + | ^^^^^^^^^^^^ ' - input.scss 1:15 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -240,7 +240,7 @@ Error: Expected identifier. a {b: log(7 % 3)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", ",", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: log(7 % 3)} | ^ diff --git a/spec/values/calculation/max.hrx b/spec/values/calculation/max.hrx index 9139e063fc..7e9655f24b 100644 --- a/spec/values/calculation/max.hrx +++ b/spec/values/calculation/max.hrx @@ -8,7 +8,7 @@ terseness' sake isn't tested explicitly. a {b: max()} <===> error/syntax/no_args/error -Error: At least one argument must be passed. +Error: Missing argument. , 1 | a {b: max()} | ^^^^^ diff --git a/spec/values/calculation/min.hrx b/spec/values/calculation/min.hrx index ab07a967a0..dabf8a52b5 100644 --- a/spec/values/calculation/min.hrx +++ b/spec/values/calculation/min.hrx @@ -8,7 +8,7 @@ terseness' sake isn't tested explicitly. a {b: min()} <===> error/syntax/no_args/error -Error: At least one argument must be passed. +Error: Missing argument. , 1 | a {b: min()} | ^^^^^ diff --git a/spec/values/calculation/mod.hrx b/spec/values/calculation/mod.hrx index 4f3e9cd61a..9716440cfd 100644 --- a/spec/values/calculation/mod.hrx +++ b/spec/values/calculation/mod.hrx @@ -287,10 +287,10 @@ Error: Expected identifier. a {b: mod(0, "0")} <===> error/modulus_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: mod(0, "0")} - | ^ + | ^^^ ' input.scss 1:14 root stylesheet @@ -300,10 +300,10 @@ Error: Expected number, variable, function, or calculation. a {b: mod("0", 0)} <===> error/dividend_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: mod("0", 0)} - | ^ + | ^^^ ' input.scss 1:11 root stylesheet @@ -313,12 +313,12 @@ Error: Expected number, variable, function, or calculation. a {b: mod(3, 2, 1)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 2 arguments allowed, but 3 were passed. , 1 | a {b: mod(3, 2, 1)} - | ^ + | ^^^^^^^^^^^^ ' - input.scss 1:15 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -326,7 +326,7 @@ Error: expected "+", "-", "*", "/", or ")". a {b: mod(7 % 3, 1)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", ",", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: mod(7 % 3, 1)} | ^ diff --git a/spec/values/calculation/pow.hrx b/spec/values/calculation/pow.hrx index c9d74478de..7a9a0931b1 100644 --- a/spec/values/calculation/pow.hrx +++ b/spec/values/calculation/pow.hrx @@ -130,10 +130,10 @@ Error: Expected identifier. a {b: pow(0, "0")} <===> error/base_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: pow(0, "0")} - | ^ + | ^^^ ' input.scss 1:14 root stylesheet @@ -143,10 +143,10 @@ Error: Expected number, variable, function, or calculation. a {b: pow("0", 0)} <===> error/exponent_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: pow("0", 0)} - | ^ + | ^^^ ' input.scss 1:11 root stylesheet @@ -169,12 +169,12 @@ Error: 2 arguments required, but only 1 was passed. a {b: pow(3, 2, 1)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 2 arguments allowed, but 3 were passed. , 1 | a {b: pow(3, 2, 1)} - | ^ + | ^^^^^^^^^^^^ ' - input.scss 1:15 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -182,7 +182,7 @@ Error: expected "+", "-", "*", "/", or ")". a {b: pow(7 % 3, 1)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", ",", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: pow(7 % 3, 1)} | ^ diff --git a/spec/values/calculation/rem.hrx b/spec/values/calculation/rem.hrx index aa5aefd882..1d1aef48cb 100644 --- a/spec/values/calculation/rem.hrx +++ b/spec/values/calculation/rem.hrx @@ -287,10 +287,10 @@ Error: Expected identifier. a {b: rem(0, "0")} <===> error/modulus_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: rem(0, "0")} - | ^ + | ^^^ ' input.scss 1:14 root stylesheet @@ -300,10 +300,10 @@ Error: Expected number, variable, function, or calculation. a {b: rem("0", 0)} <===> error/dividend_type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: rem("0", 0)} - | ^ + | ^^^ ' input.scss 1:11 root stylesheet @@ -313,12 +313,12 @@ Error: Expected number, variable, function, or calculation. a {b: rem(3, 2, 1)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 2 arguments allowed, but 3 were passed. , 1 | a {b: rem(3, 2, 1)} - | ^ + | ^^^^^^^^^^^^ ' - input.scss 1:15 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -326,7 +326,7 @@ Error: expected "+", "-", "*", "/", or ")". a {b: rem(7 % 3, 1)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", ",", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: rem(7 % 3, 1)} | ^ diff --git a/spec/values/calculation/round/error.hrx b/spec/values/calculation/round/error.hrx index 71d557deab..9956371d44 100644 --- a/spec/values/calculation/round/error.hrx +++ b/spec/values/calculation/round/error.hrx @@ -8,14 +8,10 @@ terseness' sake isn't tested explicitly. a {b: round()} <===> too_few_args/error -Error: Missing argument $number. - ,--> input.scss +Error: Missing argument. + , 1 | a {b: round()} - | ^^^^^^^ invocation - ' - ,--> sass:math -1 | @function round($number) { - | ============== declaration + | ^^^^^^^ ' input.scss 1:7 root stylesheet @@ -25,14 +21,10 @@ Error: Missing argument $number. a {b: round(1, 2, 3, 4)} <===> too_many_args/error -Error: Only 1 argument allowed, but 4 were passed. - ,--> input.scss +Error: Only 3 arguments allowed, but 4 were passed. + , 1 | a {b: round(1, 2, 3, 4)} - | ^^^^^^^^^^^^^^^^^ invocation - ' - ,--> sass:math -1 | @function round($number) { - | ============== declaration + | ^^^^^^^^^^^^^^^^^ ' input.scss 1:7 root stylesheet diff --git a/spec/values/calculation/round/three_arguments.hrx b/spec/values/calculation/round/three_arguments.hrx index 45579e68e5..6a11f3d35c 100644 --- a/spec/values/calculation/round/three_arguments.hrx +++ b/spec/values/calculation/round/three_arguments.hrx @@ -15,25 +15,25 @@ a { <===> ================================================================================ -<===> step/unknown_variable/input.scss +<===> strategy/interpolation/input.scss a { - d: round(up, 8px, var(--c)); + e: round(#{"up"}, 3px, 9px); } -<===> step/unknown_variable/output.css + +<===> strategy/interpolation/output.css a { - d: round(up, 8px, var(--c)); + e: 9px; } <===> ================================================================================ -<===> preserved/interpolation/input.scss +<===> step/unknown_variable/input.scss a { - e: round(#{"up"}, 3px, 9px); + d: round(up, 8px, var(--c)); } - -<===> preserved/interpolation/output.css +<===> step/unknown_variable/output.css a { - e: round(up, 3px, 9px); + d: round(up, 8px, var(--c)); } <===> diff --git a/spec/values/calculation/sign.hrx b/spec/values/calculation/sign.hrx index 8226107a2d..4d63e4ea5b 100644 --- a/spec/values/calculation/sign.hrx +++ b/spec/values/calculation/sign.hrx @@ -92,10 +92,10 @@ a { a {b: sign("0")} <===> error/type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: sign("0")} - | ^ + | ^^^ ' input.scss 1:12 root stylesheet @@ -105,12 +105,12 @@ Error: Expected number, variable, function, or calculation. a {b: sign()} <===> error/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: sign()} - | ^ + | ^^^^^^ ' - input.scss 1:12 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -118,12 +118,12 @@ Error: Expected number, variable, function, or calculation. a {b: sign(0, 0)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 1 argument allowed, but 2 were passed. , 1 | a {b: sign(0, 0)} - | ^ + | ^^^^^^^^^^ ' - input.scss 1:13 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -144,7 +144,7 @@ Error: Expected identifier. a {b: sign(7 % 3)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: sign(7 % 3)} | ^ diff --git a/spec/values/calculation/sin.hrx b/spec/values/calculation/sin.hrx index 5be9f9933d..8d6fa3a33a 100644 --- a/spec/values/calculation/sin.hrx +++ b/spec/values/calculation/sin.hrx @@ -139,10 +139,10 @@ Error: $number: Expected -1.75px/em to have an angle unit (deg, grad, rad, turn) a {b: sin("0")} <===> error/type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: sin("0")} - | ^ + | ^^^ ' input.scss 1:11 root stylesheet @@ -152,12 +152,12 @@ Error: Expected number, variable, function, or calculation. a {b: sin()} <===> error/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: sin()} - | ^ + | ^^^^^ ' - input.scss 1:11 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -165,12 +165,12 @@ Error: Expected number, variable, function, or calculation. a {b: sin(0, 0)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 1 argument allowed, but 2 were passed. , 1 | a {b: sin(0, 0)} - | ^ + | ^^^^^^^^^ ' - input.scss 1:12 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -191,7 +191,7 @@ Error: Expected identifier. a {b: sin(7 % 3)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: sin(7 % 3)} | ^ diff --git a/spec/values/calculation/sqrt.hrx b/spec/values/calculation/sqrt.hrx index aa920ed49b..35711212d9 100644 --- a/spec/values/calculation/sqrt.hrx +++ b/spec/values/calculation/sqrt.hrx @@ -76,10 +76,10 @@ Error: Expected 16px to have no units. a {b: sqrt("0")} <===> error/type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: sqrt("0")} - | ^ + | ^^^ ' input.scss 1:12 root stylesheet @@ -89,12 +89,12 @@ Error: Expected number, variable, function, or calculation. a {b: sqrt()} <===> error/syntax/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: sqrt()} - | ^ + | ^^^^^^ ' - input.scss 1:12 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -115,12 +115,12 @@ Error: Expected identifier. a {b: sqrt(3, 4)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 1 argument allowed, but 2 were passed. , 1 | a {b: sqrt(3, 4)} - | ^ + | ^^^^^^^^^^ ' - input.scss 1:13 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -128,7 +128,7 @@ Error: expected "+", "-", "*", "/", or ")". a {b: sqrt(7 % 3)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: sqrt(7 % 3)} | ^ diff --git a/spec/values/calculation/tan.hrx b/spec/values/calculation/tan.hrx index ffd2ec314d..521ceeb0d4 100644 --- a/spec/values/calculation/tan.hrx +++ b/spec/values/calculation/tan.hrx @@ -139,10 +139,10 @@ Error: $number: Expected -1.75px/em to have an angle unit (deg, grad, rad, turn) a {b: tan("0")} <===> error/type/error -Error: Expected number, variable, function, or calculation. +Error: This expression can't be used in a calculation. , 1 | a {b: tan("0")} - | ^ + | ^^^ ' input.scss 1:11 root stylesheet @@ -152,12 +152,12 @@ Error: Expected number, variable, function, or calculation. a {b: tan()} <===> error/too_few_args/error -Error: Expected number, variable, function, or calculation. +Error: Missing argument. , 1 | a {b: tan()} - | ^ + | ^^^^^ ' - input.scss 1:11 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -165,12 +165,12 @@ Error: Expected number, variable, function, or calculation. a {b: tan(0, 0)} <===> error/too_many_args/error -Error: expected "+", "-", "*", "/", or ")". +Error: Only 1 argument allowed, but 2 were passed. , 1 | a {b: tan(0, 0)} - | ^ + | ^^^^^^^^^ ' - input.scss 1:12 root stylesheet + input.scss 1:7 root stylesheet <===> ================================================================================ @@ -191,7 +191,7 @@ Error: Expected identifier. a {b: tan(7 % 3)} <===> error/sass_script/error -Error: expected "+", "-", "*", "/", or ")". +Error: This operation can't be used in a calculation. , 1 | a {b: tan(7 % 3)} | ^ From 6a091955e22f6e39835f03323325592f7fd27c7f Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 31 Aug 2023 18:07:04 -0700 Subject: [PATCH 3/5] Update calc function specs to cover new parsing logic --- spec/operators/modulo.hrx | 43 +++++++++++++++++++ spec/values/calculation/abs.hrx | 21 +++++++++ spec/values/calculation/acos.hrx | 21 +++++++++ spec/values/calculation/asin.hrx | 21 +++++++++ spec/values/calculation/atan.hrx | 21 +++++++++ spec/values/calculation/atan2.hrx | 21 +++++++++ spec/values/calculation/clamp.hrx | 10 +++++ spec/values/calculation/cos.hrx | 21 +++++++++ spec/values/calculation/exp.hrx | 21 +++++++++ spec/values/calculation/hypot.hrx | 21 +++++++++ spec/values/calculation/log.hrx | 21 +++++++++ spec/values/calculation/max.hrx | 21 +++++++++ spec/values/calculation/min.hrx | 21 +++++++++ spec/values/calculation/mod.hrx | 21 +++++++++ spec/values/calculation/pow.hrx | 21 +++++++++ spec/values/calculation/rem.hrx | 21 +++++++++ .../values/calculation/round/one_argument.hrx | 21 +++++++++ .../calculation/round/two_arguments.hrx | 21 +++++++++ spec/values/calculation/sign.hrx | 21 +++++++++ spec/values/calculation/sin.hrx | 21 +++++++++ spec/values/calculation/sqrt.hrx | 21 +++++++++ spec/values/calculation/tan.hrx | 21 +++++++++ 22 files changed, 473 insertions(+) create mode 100644 spec/operators/modulo.hrx diff --git a/spec/operators/modulo.hrx b/spec/operators/modulo.hrx new file mode 100644 index 0000000000..86677dacb1 --- /dev/null +++ b/spec/operators/modulo.hrx @@ -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); +} diff --git a/spec/values/calculation/abs.hrx b/spec/values/calculation/abs.hrx index 9782305f8a..9ccc890c7a 100644 --- a/spec/values/calculation/abs.hrx +++ b/spec/values/calculation/abs.hrx @@ -121,6 +121,27 @@ More info and automated migrator: https://sass-lang.com/d/slash-div ' 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 diff --git a/spec/values/calculation/acos.hrx b/spec/values/calculation/acos.hrx index eeb31cdac7..940d82d84d 100644 --- a/spec/values/calculation/acos.hrx +++ b/spec/values/calculation/acos.hrx @@ -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 diff --git a/spec/values/calculation/asin.hrx b/spec/values/calculation/asin.hrx index 0384150576..6d1b6b4fbc 100644 --- a/spec/values/calculation/asin.hrx +++ b/spec/values/calculation/asin.hrx @@ -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 diff --git a/spec/values/calculation/atan.hrx b/spec/values/calculation/atan.hrx index ba27fbc3f3..05758f8d3d 100644 --- a/spec/values/calculation/atan.hrx +++ b/spec/values/calculation/atan.hrx @@ -54,6 +54,27 @@ a { b: atan(2px + var(--c)); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: AtAn(1)} + +<===> case_insensitive/output.css +a { + b: 45deg; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function atan($arg) {@return $arg} +a {b: atan(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/unit/unknown/input.scss diff --git a/spec/values/calculation/atan2.hrx b/spec/values/calculation/atan2.hrx index cad4dd0f9b..8c96664cca 100644 --- a/spec/values/calculation/atan2.hrx +++ b/spec/values/calculation/atan2.hrx @@ -92,6 +92,27 @@ a { b: atan2(2px + var(--c), -1.75px); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: aTaN2(1, -10)} + +<===> case_insensitive/output.css +a { + b: 174.2894068625deg; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function atan2($arg) {@return $arg} +a {b: atan2(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/units/unitless_and_real/input.scss diff --git a/spec/values/calculation/clamp.hrx b/spec/values/calculation/clamp.hrx index b79a28a30b..0254ae43db 100644 --- a/spec/values/calculation/clamp.hrx +++ b/spec/values/calculation/clamp.hrx @@ -285,3 +285,13 @@ a {b: clamp(#{c})} a { b: clamp(c); } + +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: ClAmP(1px, 0px, 3px)} + +<===> case_insensitive/output.css +a { + b: 1px; +} diff --git a/spec/values/calculation/cos.hrx b/spec/values/calculation/cos.hrx index fef6f34ded..96524f9b0c 100644 --- a/spec/values/calculation/cos.hrx +++ b/spec/values/calculation/cos.hrx @@ -84,6 +84,27 @@ a { b: cos(2px + var(--c)); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: cOs(1deg)} + +<===> case_insensitive/output.css +a { + b: 0.9998476952; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function cos($arg) {@return $arg} +a {b: cos(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/unit/unknown/input.scss diff --git a/spec/values/calculation/exp.hrx b/spec/values/calculation/exp.hrx index baeea8c370..e8878f3a5b 100644 --- a/spec/values/calculation/exp.hrx +++ b/spec/values/calculation/exp.hrx @@ -54,6 +54,27 @@ a { b: exp(3px - var(--c)); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: ExP(5)} + +<===> case_insensitive/output.css +a { + b: 148.4131591026; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function exp($arg) {@return $arg} +a {b: exp(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/units/unknown/input.scss diff --git a/spec/values/calculation/hypot.hrx b/spec/values/calculation/hypot.hrx index 0129372e7d..d885b3e855 100644 --- a/spec/values/calculation/hypot.hrx +++ b/spec/values/calculation/hypot.hrx @@ -112,6 +112,27 @@ a { b: calc(infinity); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: hYpOt(1, 2)} + +<===> case_insensitive/output.css +a { + b: 2.2360679775; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function hypot($arg1, $arg2) {@return $arg1} +a {b: hypot(1, 2)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/unsimplifiable/input.scss diff --git a/spec/values/calculation/log.hrx b/spec/values/calculation/log.hrx index c0c0b3665e..eeab121d8b 100644 --- a/spec/values/calculation/log.hrx +++ b/spec/values/calculation/log.hrx @@ -104,6 +104,27 @@ a { b: log(2px + var(--c), var(--e)); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: LoG(2)} + +<===> case_insensitive/output.css +a { + b: 0.6931471806; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function log($arg) {@return $arg} +a {b: log(2)} + +<===> overridden/output.css +a { + b: 2; +} + <===> ================================================================================ <===> error/units/unknown/input.scss diff --git a/spec/values/calculation/max.hrx b/spec/values/calculation/max.hrx index 7e9655f24b..f7bd037def 100644 --- a/spec/values/calculation/max.hrx +++ b/spec/values/calculation/max.hrx @@ -333,3 +333,24 @@ More info and automated migrator: https://sass-lang.com/d/slash-div | ^^^^^^^^^^^^^^ ' input.scss 2:6 root stylesheet + +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: mAx(1px)} + +<===> case_insensitive/output.css +a { + b: 1px; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function max($arg1, $arg2) {@return $arg1} +a {b: max(1, 2)} + +<===> overridden/output.css +a { + b: 1; +} diff --git a/spec/values/calculation/min.hrx b/spec/values/calculation/min.hrx index dabf8a52b5..a1c762ff6f 100644 --- a/spec/values/calculation/min.hrx +++ b/spec/values/calculation/min.hrx @@ -333,3 +333,24 @@ More info and automated migrator: https://sass-lang.com/d/slash-div | ^^^^^^^^^^^^^^ ' input.scss 2:6 root stylesheet + +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: MiN(1px)} + +<===> case_insensitive/output.css +a { + b: 1px; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function min($arg1, $arg2) {@return $arg1} +a {b: min(2, 1)} + +<===> overridden/output.css +a { + b: 2; +} diff --git a/spec/values/calculation/mod.hrx b/spec/values/calculation/mod.hrx index 9716440cfd..723f6847cd 100644 --- a/spec/values/calculation/mod.hrx +++ b/spec/values/calculation/mod.hrx @@ -214,6 +214,27 @@ a { b: calc(infinity); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: MoD(7, 3)} + +<===> case_insensitive/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function mod($arg) {@return $arg} +a {b: mod(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/units/real_and_unitless/input.scss diff --git a/spec/values/calculation/pow.hrx b/spec/values/calculation/pow.hrx index 7a9a0931b1..fd5d0ccfbe 100644 --- a/spec/values/calculation/pow.hrx +++ b/spec/values/calculation/pow.hrx @@ -72,6 +72,27 @@ a { b: pow(2px + var(--c), 14px); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: pOw(10, 10)} + +<===> case_insensitive/output.css +a { + b: 10000000000; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function pow($arg) {@return $arg} +a {b: pow(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/units/compatible/input.scss diff --git a/spec/values/calculation/rem.hrx b/spec/values/calculation/rem.hrx index 1d1aef48cb..f92c4afa11 100644 --- a/spec/values/calculation/rem.hrx +++ b/spec/values/calculation/rem.hrx @@ -214,6 +214,27 @@ a { b: calc(-infinity); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: ReM(7, 3)} + +<===> case_insensitive/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function rem($arg) {@return $arg} +a {b: rem(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/units/real_and_unitless/input.scss diff --git a/spec/values/calculation/round/one_argument.hrx b/spec/values/calculation/round/one_argument.hrx index 8f6735ecb9..1d01cad7aa 100644 --- a/spec/values/calculation/round/one_argument.hrx +++ b/spec/values/calculation/round/one_argument.hrx @@ -95,3 +95,24 @@ More info and automated migrator: https://sass-lang.com/d/slash-div | ^^^^^^^^^^^^^^^^ ' input.scss 2:6 root stylesheet + +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: rOuNd(1)} + +<===> case_insensitive/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function round($arg) {@return $arg} +a {b: round(1.1)} + +<===> overridden/output.css +a { + b: 1.1; +} diff --git a/spec/values/calculation/round/two_arguments.hrx b/spec/values/calculation/round/two_arguments.hrx index 3971116e8e..0aa2375185 100644 --- a/spec/values/calculation/round/two_arguments.hrx +++ b/spec/values/calculation/round/two_arguments.hrx @@ -319,3 +319,24 @@ a { a { b: round(1px + 0%, 1px + 0%); } + +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: RoUnD(117, 25)} + +<===> case_insensitive/output.css +a { + b: 125; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function round($arg1, $arg2) {@return $arg1} +a {b: round(1, 2)} + +<===> overridden/output.css +a { + b: 1; +} diff --git a/spec/values/calculation/sign.hrx b/spec/values/calculation/sign.hrx index 4d63e4ea5b..37e91ddab5 100644 --- a/spec/values/calculation/sign.hrx +++ b/spec/values/calculation/sign.hrx @@ -86,6 +86,27 @@ a { b: sign(3px - var(--c)); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: sIgN(3)} + +<===> case_insensitive/output.css +a { + b: 1; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function sign($arg) {@return $arg} +a {b: sign(2)} + +<===> overridden/output.css +a { + b: 2; +} + <===> ================================================================================ <===> error/type/input.scss diff --git a/spec/values/calculation/sin.hrx b/spec/values/calculation/sin.hrx index 8d6fa3a33a..0ad4c34609 100644 --- a/spec/values/calculation/sin.hrx +++ b/spec/values/calculation/sin.hrx @@ -94,6 +94,27 @@ a { b: sin(2px + var(--c)); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: SiN(1deg)} + +<===> case_insensitive/output.css +a { + b: 0.0174524064; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function sin($arg) {@return $arg} +a {b: sin(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/units/unknown/input.scss diff --git a/spec/values/calculation/sqrt.hrx b/spec/values/calculation/sqrt.hrx index 35711212d9..5d62b71c5a 100644 --- a/spec/values/calculation/sqrt.hrx +++ b/spec/values/calculation/sqrt.hrx @@ -44,6 +44,27 @@ a { b: sqrt(3px - var(--c)); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: sQrT(2)} + +<===> case_insensitive/output.css +a { + b: 1.4142135624; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function sqrt($arg) {@return $arg} +a {b: sqrt(2)} + +<===> overridden/output.css +a { + b: 2; +} + <===> ================================================================================ <===> error/units/unknown/input.scss diff --git a/spec/values/calculation/tan.hrx b/spec/values/calculation/tan.hrx index 521ceeb0d4..118e2e490e 100644 --- a/spec/values/calculation/tan.hrx +++ b/spec/values/calculation/tan.hrx @@ -94,6 +94,27 @@ a { b: tan(2px + var(--c)); } +<===> +================================================================================ +<===> case_insensitive/input.scss +a {b: tAn(1deg)} + +<===> case_insensitive/output.css +a { + b: 0.0174550649; +} + +<===> +================================================================================ +<===> overridden/input.scss +@function tan($arg) {@return $arg} +a {b: tan(1)} + +<===> overridden/output.css +a { + b: 1; +} + <===> ================================================================================ <===> error/units/unknown/input.scss From a97dba534f931b566b07dfb3f923bf0b100f7d8b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 1 Sep 2023 13:36:07 -0700 Subject: [PATCH 4/5] Ignore test on libsass --- spec/libsass-closed-issues/issue_246.hrx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/libsass-closed-issues/issue_246.hrx b/spec/libsass-closed-issues/issue_246.hrx index bc807ac61f..4c28857d64 100644 --- a/spec/libsass-closed-issues/issue_246.hrx +++ b/spec/libsass-closed-issues/issue_246.hrx @@ -1,7 +1,7 @@ <===> options.yml --- -:warning_todo: -- sass/libsass#2887 +:ignore_for: +- libsass <===> input.scss $content-width: 960px; From 487b038bab51398d29c74e6410b42c8b6408bc4e Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 12 Sep 2023 18:35:09 -0700 Subject: [PATCH 5/5] Add specs for space-separated lists --- spec/values/calculation/calc/error/space.hrx | 103 ++++++++++++++++++ spec/values/calculation/calc/error/syntax.hrx | 26 ----- spec/values/calculation/calc/no_operator.hrx | 30 ----- spec/values/calculation/calc/parens.hrx | 89 +++++++++++++++ spec/values/calculation/calc/space.hrx | 90 +++++++++++++++ 5 files changed, 282 insertions(+), 56 deletions(-) create mode 100644 spec/values/calculation/calc/error/space.hrx create mode 100644 spec/values/calculation/calc/parens.hrx create mode 100644 spec/values/calculation/calc/space.hrx diff --git a/spec/values/calculation/calc/error/space.hrx b/spec/values/calculation/calc/error/space.hrx new file mode 100644 index 0000000000..8f7b457300 --- /dev/null +++ b/spec/values/calculation/calc/error/space.hrx @@ -0,0 +1,103 @@ +<===> number_number/input.scss +a {b: calc(1 2)} + +<===> number_number/error +Error: Missing math operator. + , +1 | a {b: calc(1 2)} + | ^^^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> number_operation/input.scss +a {b: calc(1 3 + 4)} + +<===> number_operation/error +Error: Missing math operator. + , +1 | a {b: calc(1 3 + 4)} + | ^^^^^^^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> number_paren/input.scss +a {b: calc(1 (3))} + +<===> number_paren/error +Error: Missing math operator. + , +1 | a {b: calc(1 (3))} + | ^^^^^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> number_calc/input.scss +a {b: calc(1 calc(1px + 1%))} + +<===> number_calc/error +Error: Missing math operator. + , +1 | a {b: calc(1 calc(1px + 1%))} + | ^^^^^^^^^^^^^^^^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> operation_operation/input.scss +a {b: calc(1 + 2 3 + 4)} + +<===> operation_operation/error +Error: Missing math operator. + , +1 | a {b: calc(1 + 2 3 + 4)} + | ^^^^^^^^^^^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> string_number_number/input.scss +a {b: calc(c 1 2)} + +<===> string_number_number/error +Error: Missing math operator. + , +1 | a {b: calc(c 1 2)} + | ^^^ + ' + input.scss 1:14 root stylesheet + +<===> +================================================================================ +<===> number_number_string/input.scss +a {b: calc(1 2 c)} + +<===> number_number_string/error +Error: Missing math operator. + , +1 | a {b: calc(1 2 c)} + | ^^^ + ' + input.scss 1:12 root stylesheet + +<===> +================================================================================ +<===> through_variable/input.scss +$c: 1; +$d: 2; +a {b: calc($c $d)} + +<===> through_variable/error +Error: Missing math operator. + , +3 | a {b: calc($c $d)} + | ^^^^^ + ' + input.scss 3:12 root stylesheet diff --git a/spec/values/calculation/calc/error/syntax.hrx b/spec/values/calculation/calc/error/syntax.hrx index 8d803d73cb..f57abb187a 100644 --- a/spec/values/calculation/calc/error/syntax.hrx +++ b/spec/values/calculation/calc/error/syntax.hrx @@ -100,32 +100,6 @@ Error: Expected identifier. ' input.scss 1:13 root stylesheet -<===> -================================================================================ -<===> interpolation/in_parens/input.scss -a {b: calc(1 (#{c}))} - -<===> interpolation/in_parens/error -Error: This expression can't be used in a calculation. - , -1 | a {b: calc(1 (#{c}))} - | ^^^^^^^^ - ' - input.scss 1:12 root stylesheet - -<===> -================================================================================ -<===> interpolation/in_floating_function/input.scss -a {b: calc(1 c(#{d}))} - -<===> interpolation/in_floating_function/error -Error: This expression can't be used in a calculation. - , -1 | a {b: calc(1 c(#{d}))} - | ^^^^^^^^^ - ' - input.scss 1:12 root stylesheet - <===> ================================================================================ <===> interpolation/in_function_arg/input.scss diff --git a/spec/values/calculation/calc/no_operator.hrx b/spec/values/calculation/calc/no_operator.hrx index 5d15fad3ff..458ff83ca8 100644 --- a/spec/values/calculation/calc/no_operator.hrx +++ b/spec/values/calculation/calc/no_operator.hrx @@ -265,36 +265,6 @@ b { c: 3; } -<===> -================================================================================ -<===> parentheses/input.scss -a {b: calc((1px))} - -<===> parentheses/output.css -a { - b: 1px; -} - -<===> -================================================================================ -<===> var/parenthesized/input.scss -a {b: calc((var(--c)))} - -<===> var/parenthesized/output.css -a { - b: calc((var(--c))); -} - -<===> -================================================================================ -<===> var/double_parenthesized/input.scss -a {b: calc(((var(--c))))} - -<===> var/double_parenthesized/output.css -a { - b: calc((var(--c))); -} - <===> ================================================================================ <===> var/bare/input.scss diff --git a/spec/values/calculation/calc/parens.hrx b/spec/values/calculation/calc/parens.hrx new file mode 100644 index 0000000000..cebd45919d --- /dev/null +++ b/spec/values/calculation/calc/parens.hrx @@ -0,0 +1,89 @@ +<===> number/input.scss +a {b: calc((1px))} + +<===> number/output.css +a { + b: 1px; +} + +<===> +================================================================================ +<===> operation/input.scss +a {b: calc((1px + 1%))} + +<===> operation/output.css +a { + b: calc(1px + 1%); +} + +<===> +================================================================================ +<===> calculation/input.scss +a {b: calc((calc(1px + 1%)))} + +<===> calculation/output.css +a { + b: calc(1px + 1%); +} + +<===> +================================================================================ +<===> var/direct/input.scss +a {b: calc((var(--c)))} + +<===> var/direct/output.css +a { + b: calc((var(--c))); +} + +<===> +================================================================================ +<===> var/variable/input.scss +$c: var(--d); +a {b: calc(($c))} + +<===> var/variable/output.css +a { + b: calc((var(--d))); +} + +<===> +================================================================================ +<===> variable/input.scss +$c: unquote("1 + 2"); +a {b: calc(($c))} + +<===> variable/output.css +a { + b: calc((1 + 2)); +} + +<===> +================================================================================ +<===> interpolation/input.scss +a {b: calc((#{"1 + 2"}))} + +<===> interpolation/output.css +a { + b: calc((1 + 2)); +} + +<===> +================================================================================ +<===> identifier/input.scss +a {b: calc((d))} + +<===> identifier/output.css +a { + b: calc((d)); +} + +<===> +================================================================================ +<===> double_preserved/input.scss +a {b: calc(((var(--c))))} + +<===> double_preserved/output.css +a { + b: calc(((var(--c)))); +} diff --git a/spec/values/calculation/calc/space.hrx b/spec/values/calculation/calc/space.hrx new file mode 100644 index 0000000000..714a775582 --- /dev/null +++ b/spec/values/calculation/calc/space.hrx @@ -0,0 +1,90 @@ +<===> var/before/input.scss +a {b: calc(var(--c) 1)} + +<===> var/before/output.css +a { + b: calc(var(--c) 1); +} + +<===> +================================================================================ +<===> var/after/input.scss +a {b: calc(1 var(--c))} + +<===> var/after/output.css +a { + b: calc(1 var(--c)); +} + +<===> +================================================================================ +<===> var/between/input.scss +a {b: calc(1 var(--c) 2)} + +<===> var/between/output.css +a { + b: calc(1 var(--c) 2); +} + +<===> +================================================================================ +<===> variable/before/input.scss +$c: unquote("1 +"); +a {b: calc($c 2)} + +<===> variable/before/output.css +a { + b: calc(1 + 2); +} + +<===> +================================================================================ +<===> variable/after/input.scss +$c: unquote("+ 2"); +a {b: calc(1 $c)} + +<===> variable/after/output.css +a { + b: calc(1 + 2); +} + +<===> +================================================================================ +<===> variable/between/input.scss +$c: unquote("+ 2 +"); +a {b: calc(1 $c 3)} + +<===> variable/between/output.css +a { + b: calc(1 + 2 + 3); +} + +<===> +================================================================================ +<===> interpolation/before/input.scss +a {b: calc(#{"1 +"} 2)} + +<===> interpolation/before/output.css +a { + b: calc(1 + 2); +} + +<===> +================================================================================ +<===> interpolation/after/input.scss +a {b: calc(1 #{"+ 2"})} + +<===> interpolation/after/output.css +a { + b: calc(1 + 2); +} + +<===> +================================================================================ +<===> interpolation/between/input.scss +a {b: calc(1 #{"+ 2 +"} 3)} + +<===> interpolation/between/output.css +a { + b: calc(1 + 2 + 3); +}