diff --git a/spec/core_functions/color/same.hrx b/spec/core_functions/color/same.hrx new file mode 100644 index 000000000..3add2658f --- /dev/null +++ b/spec/core_functions/color/same.hrx @@ -0,0 +1,244 @@ +<===> true/same_space/identical/input.scss +@use 'sass:color'; +a {b: color.same(#abcdef, #abcdef)} + +<===> true/same_space/identical/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/same_space/within_epsilon/input.scss +@use 'sass:color'; +a { + b: color.same( + lab(50.0000000000001 29.9999999999999 -20.0000000000001), + lab(50 30 -20) + ); +} + +<===> true/same_space/within_epsilon/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/same_space/with_alpha/input.scss +@use 'sass:color'; +a {b: color.same(oklch(50% 30% 120deg / 0.3), oklch(50% 30% 120deg / 0.3))} + +<===> true/same_space/with_alpha/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/same_space/out_of_gamut/input.scss +@use 'sass:color'; +a {b: color.same(color(srgb 2.3 -1 42), color(srgb 2.3 -1 42))} + +<===> true/same_space/out_of_gamut/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/same_space/none_and_zero/input.scss +@use 'sass:color'; +a {b: color.same(color(display-p3 0.1 0.3 none), color(display-p3 0.1 0.3 0))} + +<===> true/same_space/none_and_zero/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/same_space/both_none/input.scss +@use 'sass:color'; +a { + b: color.same(color(display-p3 0.1 0.3 none), color(display-p3 0.1 0.3 none)); +} + +<===> true/same_space/both_none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/different_space/no_none/input.scss +@use 'sass:color'; +a {b: color.same(plum, hsl(300, 47.2868217054%, 74.7058823529%))} + +<===> true/different_space/no_none/output.css +a { + b: true; +} + + +<===> +================================================================================ +<===> true/different_space/one_none/input.scss +@use 'sass:color'; +a { + b: color.same( + color(rec2020 0.5 none 0.2), + oklab(44.668866707461% 0.236673642675 0.018728349677) + ); +} + +<===> true/different_space/one_none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/different_space/both_none/input.scss +@use 'sass:color'; +a { + b: color.same( + color(srgb-linear none 0.9 0.8), + rgb(none 243.445228830895 231.114597102735) + ); +} + +<===> true/different_space/both_none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> false/same_space/no_none/input.scss +@use 'sass:color'; +a {b: color.same(#abcdef, #fedcba)} + +<===> false/same_space/no_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/same_space/none_and_nonzero/input.scss +@use 'sass:color'; +a { + b: color.same( + color(prophoto-rgb 0.1 0.2 none), + color(prophoto-rgb 0.1 0.2 0.3) + ); +} + +<===> false/same_space/none_and_nonzero/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/different_space/no_none/input.scss +@use 'sass:color'; +a {b: color.same(color(srgb 0.1 0.2 0.3), color(srgb-linear 0.1 0.2 0.3))} + +<===> false/different_space/no_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/different_space/both_none/input.scss +// This test verifies that none is converted to 0 *before* conversion to XYZ. +@use 'sass:color'; +a { + b: color.same( + color(rec2020 0.5 none 0.2), + color(xyz 0.174805932224126 none 0.058901333881161) + ); +} + +<===> false/different_space/both_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> named/input.scss +@use 'sass:color'; +a {b: color.same($color1: red, $color2: green)} + +<===> named/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> error/too_few_args/input.scss +@use 'sass:color'; +a {b: color.same(plum)} + +<===> error/too_few_args/error +Error: Missing argument $color2. + ,--> input.scss +2 | a {b: color.same(plum)} + | ^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:color +1 | @function same($color1, $color2) { + | ====================== declaration + ' + input.scss 2:7 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +@use 'sass:color'; +a {b: color.same(red, green, blue)} + +<===> error/too_many_args/error +Error: Only 2 arguments allowed, but 3 were passed. + ,--> input.scss +2 | a {b: color.same(red, green, blue)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:color +1 | @function same($color1, $color2) { + | ====================== declaration + ' + input.scss 2:7 root stylesheet + +<===> +================================================================================ +<===> error/type/color1/input.scss +@use 'sass:color'; +a {b: color.same(1, red)} + +<===> error/type/color1/error +Error: $color1: 1 is not a color. + , +2 | a {b: color.same(1, red)} + | ^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:7 root stylesheet + +<===> +================================================================================ +<===> error/type/color2/input.scss +@use 'sass:color'; +a {b: color.same(red, 1)} + +<===> error/type/color2/error +Error: $color2: 1 is not a color. + , +2 | a {b: color.same(red, 1)} + | ^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:7 root stylesheet diff --git a/spec/values/colors/equality.hrx b/spec/values/colors/equality.hrx new file mode 100644 index 000000000..44f1e9b0c --- /dev/null +++ b/spec/values/colors/equality.hrx @@ -0,0 +1,251 @@ +<===> true/legacy/same_space/rgb/no_none/input.scss +a {b: #abcdef == #abcdef} + +<===> true/legacy/same_space/rgb/no_none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/legacy/same_space/rgb/none/input.scss +a {b: rgb(50 none 120) == rgb(50 none 120)} + +<===> true/legacy/same_space/rgb/none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/legacy/same_space/hsl/no_none/input.scss +a {b: hsl(250, 80%, 20%) == hsl(250deg, 80%, 20%)} + +<===> true/legacy/same_space/hsl/no_none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/legacy/same_space/hsl/none/input.scss +a {b: hsl(none 80% 20%) == hsl(none 80% 20%)} + +<===> true/legacy/same_space/hsl/none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/legacy/same_space/hsl/wrapped_hue/input.scss +a {b: hsl(180, 80%, 20%) == hsl(540, 80%, 20%)} + +<===> true/legacy/same_space/hsl/wrapped_hue/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/legacy/same_space/hwb/no_none/input.scss +a {b: hwb(250 30% 20%) == hwb(250deg 30% 20%)} + +<===> true/legacy/same_space/hwb/no_none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/legacy/same_space/hwb/none/input.scss +a {b: hwb(none 30% 20%) == hwb(none 30% 20%)} + +<===> true/legacy/same_space/hwb/none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/legacy/different_space/no_none/input.scss +a {b: purple == hsl(300, 100%, 25.098039215686%)} + +<===> true/legacy/different_space/no_none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/legacy/different_space/none/input.scss +a {b: gray == hsl(none 0% 50.196078431373%)} + +<===> true/legacy/different_space/none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/no_alpha_or_none/input.scss +a {b: lab(66% 50 -100) == lab(66% 50 -100)} + +<===> true/no_alpha_or_none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/alpha/input.scss +a {b: color(prophoto-rgb 0.3 0.4 0.5 / 0.6) == color(prophoto-rgb 0.3 0.4 0.5 / 0.6)} + +<===> true/alpha/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/none/input.scss +a {b: lch(100% 0% none) == lch(100% 0% none)} + +<===> true/none/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> true/within_epsilon/input.scss +a { + b: oklab( + 50.0000000000001 29.9999999999999 -20.0000000000001 / 0.999999999999 + ) == oklab(50 30 -20); +} + +<===> true/within_epsilon/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> false/different_type/input.scss +a {b: red == unquote("red")} + +<===> false/different_type/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/legacy/same_space/rgb/no_none/input.scss +a {b: red == blue} + +<===> false/legacy/same_space/rgb/no_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/legacy/same_space/rgb/one_none/input.scss +a {b: rgb(0 100 200) == rgb(none 100 200)} + +<===> false/legacy/same_space/rgb/one_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/legacy/same_space/hsl/no_none/input.scss +a {b: hsl(50deg 50% 80%) == hsl(51deg 50% 80%)} + +<===> false/legacy/same_space/hsl/no_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/legacy/same_space/hsl/one_none/input.scss +a {b: hsl(0 0% 80%) == hsl(none 0% 80%)} + +<===> false/legacy/same_space/hsl/one_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/legacy/same_space/hwb/no_none/input.scss +a {b: hwb(50deg 20% 30%) == hwb(51deg 20% 30%)} + +<===> false/legacy/same_space/hwb/no_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/legacy/same_space/hwb/one_none/input.scss +a {b: hwb(0 0% 0%) == hwb(none 0% 0%)} + +<===> false/legacy/same_space/hwb/one_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/legacy/different_space/input.scss +a {b: red == hsl(0, 0%, 50%)} + +<===> false/legacy/different_space/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/same_space/no_none/input.scss +a {b: color(prophoto-rgb 0.1 0.2 0.3) == color(prophoto-rgb 0.1 0.2 0.4)} + +<===> false/same_space/no_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/same_space/one_none/input.scss +a {b: oklch(50% 0% none) == oklch(50% 0% 0)} + +<===> false/same_space/one_none/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/same_space/different_alpha/input.scss +a {b: lab(50% 100 -100) == lab(50% 100 -100 / 0.9)} + +<===> false/same_space/different_alpha/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> false/different_space/input.scss +a {b: color(srgb 0 0 0) == color(srgb-linear 0 0 0)} + +<===> false/different_space/output.css +a { + b: false; +}