From 554a03a2148139c2623caf9bf39aa89811b34d71 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 6 Oct 2023 14:51:18 -0700 Subject: [PATCH] [Color 4] Add tests for oklab() (#1938) --- .../color/hsl/error/one_arg.hrx | 8 +- .../color/hwb/error/four_args.hrx | 6 +- .../color/hwb/error/one_arg.hrx | 8 +- .../color/hwb/error/three_args.hrx | 6 +- spec/core_functions/color/lab/error.hrx | 6 +- spec/core_functions/color/oklab/README.md | 2 + spec/core_functions/color/oklab/_utils.scss | 27 ++ spec/core_functions/color/oklab/alpha.hrx | 120 ++++++++ spec/core_functions/color/oklab/error.hrx | 259 ++++++++++++++++++ spec/core_functions/color/oklab/no_alpha.hrx | 189 +++++++++++++ spec/core_functions/color/oklab/options.yml | 3 + .../color/oklab/special_functions.hrx | 142 ++++++++++ .../color/rgb/error/one_arg.hrx | 8 +- 13 files changed, 763 insertions(+), 21 deletions(-) create mode 100644 spec/core_functions/color/oklab/README.md create mode 100644 spec/core_functions/color/oklab/_utils.scss create mode 100644 spec/core_functions/color/oklab/alpha.hrx create mode 100644 spec/core_functions/color/oklab/error.hrx create mode 100644 spec/core_functions/color/oklab/no_alpha.hrx create mode 100644 spec/core_functions/color/oklab/options.yml create mode 100644 spec/core_functions/color/oklab/special_functions.hrx diff --git a/spec/core_functions/color/hsl/error/one_arg.hrx b/spec/core_functions/color/hsl/error/one_arg.hrx index b603b431dd..d511c26aa4 100644 --- a/spec/core_functions/color/hsl/error/one_arg.hrx +++ b/spec/core_functions/color/hsl/error/one_arg.hrx @@ -101,7 +101,7 @@ a { } <===> type/hue/error -Error: $channels: Expected hue "foo" to be a number. +Error: $channels: Expected hue channel to be a number, was "foo". , 2 | b: hsl("foo" 100% 50%); | ^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ a { } <===> type/saturation/error -Error: $channels: Expected saturation "foo" to be a number. +Error: $channels: Expected saturation channel to be a number, was "foo". , 2 | b: hsl(0 "foo" 50%); | ^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ a { } <===> type/lightness/error -Error: $channels: Expected lightness "foo" to be a number. +Error: $channels: Expected lightness channel to be a number, was "foo". , 2 | b: hsl(0 100% "foo"); | ^^^^^^^^^^^^^^^^^ @@ -146,7 +146,7 @@ a { } <===> quoted_var_slash/error -Error: $channels: Expected lightness "var(--foo) / 0.4" to be a number. +Error: $channels: Expected lightness channel to be a number, was "var(--foo) / 0.4". , 2 | b: hsl(0 100% "var(--foo) / 0.4"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/spec/core_functions/color/hwb/error/four_args.hrx b/spec/core_functions/color/hwb/error/four_args.hrx index 6600ef2038..3a26596ccb 100644 --- a/spec/core_functions/color/hwb/error/four_args.hrx +++ b/spec/core_functions/color/hwb/error/four_args.hrx @@ -3,7 +3,7 @@ a {b: color.hwb("foo", 30%, 40%, 0.5)} <===> hue/type/error -Error: Expected hue "foo" to be a number. +Error: Expected hue channel to be a number, was "foo". , 2 | a {b: color.hwb("foo", 30%, 40%, 0.5)} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ Error: $hue: var(--c) is not a number. a {b: color.hwb(0, "foo", 40%, 0.5)} <===> whiteness/type/error -Error: Expected whiteness "foo" to be a number. +Error: Expected whiteness channel to be a number, was "foo". , 2 | a {b: color.hwb(0, "foo", 40%, 0.5)} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -135,7 +135,7 @@ Error: $whiteness: var(--c) is not a number. a {b: color.hwb(0, 30%, "foo", 0.5)} <===> blackness/type/error -Error: Expected blackness "foo" to be a number. +Error: Expected blackness channel to be a number, was "foo". , 2 | a {b: color.hwb(0, 30%, "foo", 0.5)} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/spec/core_functions/color/hwb/error/one_arg.hrx b/spec/core_functions/color/hwb/error/one_arg.hrx index 39cf839885..8740f3c491 100644 --- a/spec/core_functions/color/hwb/error/one_arg.hrx +++ b/spec/core_functions/color/hwb/error/one_arg.hrx @@ -87,7 +87,7 @@ Error: $channels: The hwb color space has 3 channels but (0 30% 40% 0.4) has 4. a {b: color.hwb("foo" 30% 40%)} <===> hue/type/error -Error: $channels: Expected hue "foo" to be a number. +Error: $channels: Expected hue channel to be a number, was "foo". , 2 | a {b: color.hwb("foo" 30% 40%)} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -120,7 +120,7 @@ Error: $hue: var(--c) is not a number. a {b: color.hwb(0 "foo" 40%)} <===> whiteness/type/error -Error: $channels: Expected whiteness "foo" to be a number. +Error: $channels: Expected whiteness channel to be a number, was "foo". , 2 | a {b: color.hwb(0 "foo" 40%)} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ Error: $whiteness: var(--c) is not a number. a {b: color.hwb(0 30% "foo")} <===> blackness/type/error -Error: $channels: Expected blackness "foo" to be a number. +Error: $channels: Expected blackness channel to be a number, was "foo". , 2 | a {b: color.hwb(0 30% "foo")} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -367,7 +367,7 @@ Error: Expected numeric channels, got "hwb(0 0 0/var(--c))". a {b: color.hwb(0 30% "var(--foo) / 0.4")} <===> quoted_var_slash/error -Error: $channels: Expected blackness "var(--foo) / 0.4" to be a number. +Error: $channels: Expected blackness channel to be a number, was "var(--foo) / 0.4". , 2 | a {b: color.hwb(0 30% "var(--foo) / 0.4")} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/spec/core_functions/color/hwb/error/three_args.hrx b/spec/core_functions/color/hwb/error/three_args.hrx index 558f605fa9..1d3b955595 100644 --- a/spec/core_functions/color/hwb/error/three_args.hrx +++ b/spec/core_functions/color/hwb/error/three_args.hrx @@ -3,7 +3,7 @@ a {b: color.hwb("foo", 100%, 50%)} <===> hue/type/error -Error: Expected hue "foo" to be a number. +Error: Expected hue channel to be a number, was "foo". , 2 | a {b: color.hwb("foo", 100%, 50%)} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ Error: argument `$hue` of `hwb($hue, $whiteness, $blackness)` must be a number a {b: color.hwb(0, "foo", 50%)} <===> whiteness/type/error -Error: Expected whiteness "foo" to be a number. +Error: Expected whiteness channel to be a number, was "foo". , 2 | a {b: color.hwb(0, "foo", 50%)} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ Error: argument `$whiteness` of `hwb($hue, $whiteness, $blackness)` must be a nu a {b: color.hwb(0, 100%, "foo")} <===> blackness/type/error -Error: Expected blackness "foo" to be a number. +Error: Expected blackness channel to be a number, was "foo". , 2 | a {b: color.hwb(0, 100%, "foo")} | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/spec/core_functions/color/lab/error.hrx b/spec/core_functions/color/lab/error.hrx index 8ef5bf1f08..27363ac64a 100644 --- a/spec/core_functions/color/lab/error.hrx +++ b/spec/core_functions/color/lab/error.hrx @@ -68,7 +68,7 @@ Error: $alpha: Expected 0.4px to have unit "%" or no units. a {b: lab(c 2 3)} <===> type/lightness/error -Error: $channels: Expected lightness c to be a number. +Error: $channels: Expected lightness channel to be a number, was c. , 1 | a {b: lab(c 2 3)} | ^^^^^^^^^^ @@ -81,7 +81,7 @@ Error: $channels: Expected lightness c to be a number. a {b: lab(1% c 3)} <===> type/a/error -Error: $channels: Expected a c to be a number. +Error: $channels: Expected a channel to be a number, was c. , 1 | a {b: lab(1% c 3)} | ^^^^^^^^^^^ @@ -94,7 +94,7 @@ Error: $channels: Expected a c to be a number. a {b: lab(1% 2 c)} <===> type/b/error -Error: $channels: Expected b c to be a number. +Error: $channels: Expected b channel to be a number, was c. , 1 | a {b: lab(1% 2 c)} | ^^^^^^^^^^^ diff --git a/spec/core_functions/color/oklab/README.md b/spec/core_functions/color/oklab/README.md new file mode 100644 index 0000000000..5117c908e1 --- /dev/null +++ b/spec/core_functions/color/oklab/README.md @@ -0,0 +1,2 @@ +Some of the same behavior tested for `lab()` applies to this function as well, +but for terseness' sake isn't tested explicitly. diff --git a/spec/core_functions/color/oklab/_utils.scss b/spec/core_functions/color/oklab/_utils.scss new file mode 100644 index 0000000000..106fe41df4 --- /dev/null +++ b/spec/core_functions/color/oklab/_utils.scss @@ -0,0 +1,27 @@ +@use 'sass:color'; +@use 'sass:list'; +@use 'sass:meta'; + +@function -real-channel($color, $channel) { + @if color.is-missing($color, $channel) { + @return none; + } @else { + @return color.channel($color, $channel); + } +} + +@mixin inspect($color) { + a { + value: $color; + @if meta.type-of($color) == string { + type: string; + } @else { + channels: list.slash( + -real-channel($color, 'lightness') + -real-channel($color, 'a') + -real-channel($color, 'b'), + -real-channel($color, 'alpha') + ); + } + } +} diff --git a/spec/core_functions/color/oklab/alpha.hrx b/spec/core_functions/color/oklab/alpha.hrx new file mode 100644 index 0000000000..4f245830d1 --- /dev/null +++ b/spec/core_functions/color/oklab/alpha.hrx @@ -0,0 +1,120 @@ +<===> transparent/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(0 255 127 / 0)); + +<===> transparent/output.css +a { + value: oklab(0% 255 127 / 0); + channels: 0% 255 127 / 0; +} + +<===> +================================================================================ +<===> opaque/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 3 / 1)); + +<===> opaque/output.css +a { + value: oklab(1% 2 3); + channels: 1% 2 3 / 1; +} + +<===> +================================================================================ +<===> partial/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 3 / 0.4)); + +<===> partial/output.css +a { + value: oklab(1% 2 3 / 0.4); + channels: 1% 2 3 / 0.4; +} + +<===> +================================================================================ +<===> percent/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 3 / 40%)); + +<===> percent/output.css +a { + value: oklab(1% 2 3 / 0.4); + channels: 1% 2 3 / 0.4; +} + +<===> +================================================================================ +<===> named/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab($channels: 1% 2 3 / 0.4)); + +<===> named/output.css +a { + value: oklab(1% 2 3 / 0.4); + channels: 1% 2 3 / 0.4; +} + +<===> +================================================================================ +<===> slash_list/input.scss +@use "sass:list"; +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(list.slash(1% 2 3, 0.4))); + +<===> slash_list/output.css +a { + value: oklab(1% 2 3 / 0.4); + channels: 1% 2 3 / 0.4; +} + +<===> +================================================================================ +<===> none/slash/b/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 none / 0.4)); + +<===> none/slash/b/output.css +a { + value: oklab(1% 2 none / 0.4); + channels: 1% 2 none / 0.4; +} + +<===> +================================================================================ +<===> none/slash/alpha/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 3 / none)); + +<===> none/slash/alpha/output.css +a { + value: oklab(1% 2 3 / none); + channels: 1% 2 3 / none; +} + +<===> +================================================================================ +<===> none/slash_list/b/input.scss +@use 'sass:list'; +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(list.slash(1% 2 none, 0.4))); + +<===> none/slash_list/b/output.css +a { + value: oklab(1% 2 none / 0.4); + channels: 1% 2 none / 0.4; +} + +<===> +================================================================================ +<===> none/slash_list/alpha/input.scss +@use 'sass:list'; +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(list.slash(1% 2 3, none))); + +<===> none/slash_list/alpha/output.css +a { + value: oklab(1% 2 3 / none); + channels: 1% 2 3 / none; +} diff --git a/spec/core_functions/color/oklab/error.hrx b/spec/core_functions/color/oklab/error.hrx new file mode 100644 index 0000000000..b39e25c0d2 --- /dev/null +++ b/spec/core_functions/color/oklab/error.hrx @@ -0,0 +1,259 @@ +<===> unit/lightness/input.scss +a {b: oklab(1px 2 3)} + +<===> unit/lightness/error +Error: $lightness: Expected 1px to have unit "%" or no units. + , +1 | a {b: oklab(1px 2 3)} + | ^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> unit/a/input.scss +a {b: oklab(1% 2px 3)} + +<===> unit/a/error +Error: $a: Expected 2px to have unit "%" or no units. + , +1 | a {b: oklab(1% 2px 3)} + | ^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> unit/b/input.scss +a {b: oklab(1% 2 3px)} + +<===> unit/b/error +Error: $b: Expected 3px to have unit "%" or no units. + , +1 | a {b: oklab(1% 2 3px)} + | ^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> unit/alpha/slash/input.scss +a {b: oklab(1% 2 3/0.4px)} + +<===> unit/alpha/slash/error +Error: $alpha: Expected 0.4px to have unit "%" or no units. + , +1 | a {b: oklab(1% 2 3/0.4px)} + | ^^^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> unit/alpha/slash_list/input.scss +@use 'sass:list'; +a {b: oklab(list.slash(1% 2 3, 0.4px))} + +<===> unit/alpha/slash_list/error +Error: $alpha: Expected 0.4px to have unit "%" or no units. + , +2 | a {b: oklab(list.slash(1% 2 3, 0.4px))} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:7 root stylesheet + +<===> +================================================================================ +<===> type/lightness/input.scss +a {b: oklab(c 2 3)} + +<===> type/lightness/error +Error: $channels: Expected lightness channel to be a number, was c. + , +1 | a {b: oklab(c 2 3)} + | ^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> type/a/input.scss +a {b: oklab(1% c 3)} + +<===> type/a/error +Error: $channels: Expected a channel to be a number, was c. + , +1 | a {b: oklab(1% c 3)} + | ^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> type/b/input.scss +a {b: oklab(1% 2 c)} + +<===> type/b/error +Error: $channels: Expected b channel to be a number, was c. + , +1 | a {b: oklab(1% 2 c)} + | ^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> type/alpha/slash_list/input.scss +@use 'sass:list'; +a {b: oklab(list.slash(1% 2 3, c))} + +<===> type/alpha/slash_list/error +Error: $channels: c is not a number. + , +2 | a {b: oklab(list.slash(1% 2 3, c))} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:7 root stylesheet + +<===> +================================================================================ +<===> list/bracketed/input.scss +a {b: oklab([1% 2 3])} + +<===> list/bracketed/error +Error: $channels: Expected an unbracketed list, was [1% 2 3] + , +1 | a {b: oklab([1% 2 3])} + | ^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> list/comma/input.scss +a {b: oklab((1%, 2, 3))} + +<===> list/comma/error +Error: $channels: Expected a space- or slash-separated list, was (1%, 2, 3) + , +1 | a {b: oklab((1%, 2, 3))} + | ^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> list/slash/three/input.scss +@use 'sass:list'; +a {b: oklab(list.slash(1%, 2, 3))} + +<===> list/slash/three/error +Error: $channels: Only 2 slash-separated elements allowed, but 3 were passed. + , +2 | a {b: oklab(list.slash(1%, 2, 3))} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:7 root stylesheet + +<===> +================================================================================ +<===> list/slash/one/input.scss +@use 'sass:list'; +$single-arg-slash-separated: list.append((), 1% 2 3, $separator: slash); +a {b: oklab($single-arg-slash-separated)} + +<===> list/slash/one/error +Error: $channels: Only 2 slash-separated elements allowed, but 1 was passed. + , +3 | a {b: oklab($single-arg-slash-separated)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 3:7 root stylesheet + +<===> +================================================================================ +<===> list/empty/input.scss +a {b: oklab(())} + +<===> list/empty/error +Error: $channels: Color component list may not be empty. + , +1 | a {b: oklab(())} + | ^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> list/empty_space/input.scss +@use 'sass:list'; +$empty-space: list.join((), (), $separator: space); +a {b: oklab(())} + +<===> list/empty_space/error +Error: $channels: Color component list may not be empty. + , +3 | a {b: oklab(())} + | ^^^^^^^^^ + ' + input.scss 3:7 root stylesheet + +<===> +================================================================================ +<===> list/too_few_channels/input.scss +a {b: oklab(1% 2)} + +<===> list/too_few_channels/error +Error: $channels: The oklab color space has 3 channels but (1% 2) has 2. + , +1 | a {b: oklab(1% 2)} + | ^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> list/too_many_channels/input.scss +a {b: oklab(1% 2 3 0.4)} + +<===> list/too_many_channels/error +Error: $channels: The oklab color space has 3 channels but (1% 2 3 0.4) has 4. + , +1 | a {b: oklab(1% 2 3 0.4)} + | ^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> too_few_args/input.scss +a {b: oklab()} + +<===> too_few_args/error +Error: Missing argument $channels. + ,--> input.scss +1 | a {b: oklab()} + | ^^^^^^^ invocation + ' + ,--> sass:color +1 | @function oklab($channels) { + | ================ declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> too_many_args/input.scss +a {b: oklab(1%, 2, 3, 0.4)} + +<===> too_many_args/error +Error: Only 1 argument allowed, but 4 were passed. + ,--> input.scss +1 | a {b: oklab(1%, 2, 3, 0.4)} + | ^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:color +1 | @function oklab($channels) { + | ================ declaration + ' + input.scss 1:7 root stylesheet diff --git a/spec/core_functions/color/oklab/no_alpha.hrx b/spec/core_functions/color/oklab/no_alpha.hrx new file mode 100644 index 0000000000..89c41fc681 --- /dev/null +++ b/spec/core_functions/color/oklab/no_alpha.hrx @@ -0,0 +1,189 @@ +<===> unitless/ab/in_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 -3)); + +<===> unitless/ab/in_range/output.css +a { + value: oklab(1% 2 -3); + channels: 1% 2 -3 / 1; +} + +<===> +================================================================================ +<===> unitless/ab/above_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 126 300)); + +<===> unitless/ab/above_range/output.css +a { + value: oklab(1% 126 300); + channels: 1% 126 300 / 1; +} + +<===> +================================================================================ +<===> unitless/ab/below_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% -126 -300)); + +<===> unitless/ab/below_range/output.css +a { + value: oklab(1% -126 -300); + channels: 1% -126 -300 / 1; +} + +<===> +================================================================================ +<===> unitless/lightness/in_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(0.1 2 -3)); + +<===> unitless/lightness/in_range/output.css +a { + value: oklab(10% 2 -3); + channels: 10% 2 -3 / 1; +} + +<===> +================================================================================ +<===> unitless/lightness/above_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1.1 2 3)); + +<===> unitless/lightness/above_range/output.css +a { + value: oklab(100% 2 3); + channels: 100% 2 3 / 1; +} + +<===> +================================================================================ +<===> unitless/lightness/below_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(-0.1 2 3)); + +<===> unitless/lightness/below_range/output.css +a { + value: oklab(0% 2 3); + channels: 0% 2 3 / 1; +} + +<===> +================================================================================ +<===> percent/ab/in_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2% -3%)); + +<===> percent/ab/in_range/output.css +a { + value: oklab(1% 0.008 -0.012); + channels: 1% 0.008 -0.012 / 1; +} + +<===> +================================================================================ +<===> percent/ab/above_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 101% 150%)); + +<===> percent/ab/above_range/output.css +a { + value: oklab(1% 0.404 0.6); + channels: 1% 0.404 0.6 / 1; +} + +<===> +================================================================================ +<===> percent/ab/below_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% -101% -150%)); + +<===> percent/ab/below_range/output.css +a { + value: oklab(1% -0.404 -0.6); + channels: 1% -0.404 -0.6 / 1; +} + +<===> +================================================================================ +<===> percent/lightness/in_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2% -3%)); + +<===> percent/lightness/in_range/output.css +a { + value: oklab(1% 0.008 -0.012); + channels: 1% 0.008 -0.012 / 1; +} + +<===> +================================================================================ +<===> percent/lightness/above_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(110% 2 3)); + +<===> percent/lightness/above_range/output.css +a { + value: oklab(100% 2 3); + channels: 100% 2 3 / 1; +} + +<===> +================================================================================ +<===> percent/lightness/below_range/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(-1% 2 3)); + +<===> percent/lightness/below_range/output.css +a { + value: oklab(0% 2 3); + channels: 0% 2 3 / 1; +} + +<===> +================================================================================ +<===> none/lightness/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(none 2 3)); + +<===> none/lightness/output.css +a { + value: oklab(none 2 3); + channels: none 2 3 / 1; +} + +<===> +================================================================================ +<===> none/a/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% none 3)); + +<===> none/a/output.css +a { + value: oklab(1% none 3); + channels: 1% none 3 / 1; +} + +<===> +================================================================================ +<===> none/b/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 none)); + +<===> none/b/output.css +a { + value: oklab(1% 2 none); + channels: 1% 2 none / 1; +} + +<===> +================================================================================ +<===> named/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab($channels: 1% 2 3)); + +<===> named/output.css +a { + value: oklab(1% 2 3); + channels: 1% 2 3 / 1; +} diff --git a/spec/core_functions/color/oklab/options.yml b/spec/core_functions/color/oklab/options.yml new file mode 100644 index 0000000000..99ecec7ed1 --- /dev/null +++ b/spec/core_functions/color/oklab/options.yml @@ -0,0 +1,3 @@ +--- +:ignore_for: +- libsass diff --git a/spec/core_functions/color/oklab/special_functions.hrx b/spec/core_functions/color/oklab/special_functions.hrx new file mode 100644 index 0000000000..089f5057ff --- /dev/null +++ b/spec/core_functions/color/oklab/special_functions.hrx @@ -0,0 +1,142 @@ +<===> calculation/arg_1/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(calc(1px + 1%) 2 3)); + +<===> calculation/arg_1/output.css +a { + value: oklab(calc(1px + 1%) 2 3); + type: string; +} + +<===> +================================================================================ +<===> calculation/arg_2/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% calc(1px + 1%) 3)); + +<===> calculation/arg_2/output.css +a { + value: oklab(1% calc(1px + 1%) 3); + type: string; +} + +<===> +================================================================================ +<===> calculation/arg_3/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 calc(1px + 1%))); + +<===> calculation/arg_3/output.css +a { + value: oklab(1% 2 calc(1px + 1%)); + type: string; +} + +<===> +================================================================================ +<===> calculation/arg_4/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 3 / calc(1px + 1%))); + +<===> calculation/arg_4/output.css +a { + value: oklab(1% 2 3/calc(1px + 1%)); + type: string; +} + +<===> +================================================================================ +<===> var/arg_1/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(var(--foo) 2 3)); + +<===> var/arg_1/output.css +a { + value: oklab(var(--foo) 2 3); + type: string; +} + +<===> +================================================================================ +<===> var/arg_2/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% var(--foo) 3)); + +<===> var/arg_2/output.css +a { + value: oklab(1% var(--foo) 3); + type: string; +} + +<===> +================================================================================ +<===> var/arg_3/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 var(--foo))); + +<===> var/arg_3/output.css +a { + value: oklab(1% 2 var(--foo)); + type: string; +} + +<===> +================================================================================ +<===> var/arg_4/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% 2 3 / var(--foo))); + +<===> var/arg_4/output.css +a { + value: oklab(1% 2 3/var(--foo)); + type: string; +} + +<===> +================================================================================ +<===> multi_argument_var/1_of_2/input.scss +// var() is substituted before parsing, so it may contain multiple arguments. +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(var(--foo) 2)); + +<===> multi_argument_var/1_of_2/output.css +a { + value: oklab(var(--foo) 2); + type: string; +} + +<===> +================================================================================ +<===> multi_argument_var/2_of_2/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(1% var(--foo))); + +<===> multi_argument_var/2_of_2/output.css +a { + value: oklab(1% var(--foo)); + type: string; +} + +<===> +================================================================================ +<===> multi_argument_var/1_of_1/no_alpha/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(var(--foo))); + +<===> multi_argument_var/1_of_1/no_alpha/output.css +a { + value: oklab(var(--foo)); + type: string; +} + +<===> +================================================================================ +<===> multi_argument_var/1_of_1/alpha/input.scss +@use 'core_functions/color/oklab/utils'; +@include utils.inspect(oklab(var(--foo) / 0.4)); + +<===> multi_argument_var/1_of_1/alpha/output.css +a { + value: oklab(var(--foo)/0.4); + type: string; +} diff --git a/spec/core_functions/color/rgb/error/one_arg.hrx b/spec/core_functions/color/rgb/error/one_arg.hrx index b16f12e29e..59b4b91a47 100644 --- a/spec/core_functions/color/rgb/error/one_arg.hrx +++ b/spec/core_functions/color/rgb/error/one_arg.hrx @@ -101,7 +101,7 @@ a { } <===> type/red/error -Error: $channels: Expected red "foo" to be a number. +Error: $channels: Expected red channel to be a number, was "foo". , 2 | b: rgb("foo" 2 3); | ^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ a { } <===> type/green/error -Error: $channels: Expected green "foo" to be a number. +Error: $channels: Expected green channel to be a number, was "foo". , 2 | b: rgb(1 "foo" 3); | ^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ a { } <===> type/blue/error -Error: $channels: Expected blue "foo" to be a number. +Error: $channels: Expected blue channel to be a number, was "foo". , 2 | b: rgb(1 2 "foo"); | ^^^^^^^^^^^^^^ @@ -146,7 +146,7 @@ a { } <===> quoted_var_slash/error -Error: $channels: Expected blue "var(--foo) / 0.4" to be a number. +Error: $channels: Expected blue channel to be a number, was "var(--foo) / 0.4". , 2 | b: rgb(1 2 "var(--foo) / 0.4"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^