Skip to content

Commit

Permalink
Add tests for color.to-gamut() (#1980)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Apr 24, 2024
1 parent 1760404 commit 71c13cf
Show file tree
Hide file tree
Showing 25 changed files with 999 additions and 6 deletions.
63 changes: 63 additions & 0 deletions spec/core_functions/color/to_gamut/a98_rgb.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<===> clip/in_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(a98-rgb 0.2 0.5 0.8), $method: clip)}

<===> clip/in_gamut/output.css
a {
b: color(a98-rgb 0.2 0.5 0.8);
}

<===>
================================================================================
<===> clip/out_of_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(a98-rgb 1.5 0.5 0.8), $method: clip)}

<===> clip/out_of_gamut/output.css
a {
b: color(a98-rgb 1 0.5 0.8);
}

<===>
================================================================================
<===> local_minde/in_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(a98-rgb 0.2 0.5 0.8), $method: local-minde)}

<===> local_minde/in_gamut/output.css
a {
b: color(a98-rgb 0.2 0.5 0.8);
}

<===>
================================================================================
<===> local_minde/out_of_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(a98-rgb 1.1 0.5 0.8), $method: local-minde)}

<===> local_minde/out_of_gamut/output.css
a {
b: color(a98-rgb 1 0.5850609654 0.8001989835);
}

<===>
================================================================================
<===> local_minde/to_white/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(a98-rgb 0.8 1.1 1.4), $method: local-minde)}

<===> local_minde/to_white/output.css
a {
b: color(a98-rgb 1 1 1);
}

<===>
================================================================================
<===> local_minde/to_black/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(a98-rgb 0 -0.05 -0.05), $method: local-minde)}

<===> local_minde/to_black/output.css
a {
b: color(a98-rgb 0 0 0);
}
63 changes: 63 additions & 0 deletions spec/core_functions/color/to_gamut/display_p3.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<===> clip/in_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(display-p3 0.2 0.5 0.8), $method: clip)}

<===> clip/in_gamut/output.css
a {
b: color(display-p3 0.2 0.5 0.8);
}

<===>
================================================================================
<===> clip/out_of_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(display-p3 1.5 0.5 0.8), $method: clip)}

<===> clip/out_of_gamut/output.css
a {
b: color(display-p3 1 0.5 0.8);
}

<===>
================================================================================
<===> local_minde/in_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(display-p3 0.2 0.5 0.8), $method: local-minde)}

<===> local_minde/in_gamut/output.css
a {
b: color(display-p3 0.2 0.5 0.8);
}

<===>
================================================================================
<===> local_minde/out_of_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(display-p3 1.5 0.5 0.8), $method: local-minde)}

<===> local_minde/out_of_gamut/output.css
a {
b: color(display-p3 1 0.9080382844 0.9302909848);
}

<===>
================================================================================
<===> local_minde/to_white/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(display-p3 0.8 1.1 1.4), $method: local-minde)}

<===> local_minde/to_white/output.css
a {
b: color(display-p3 1 1 1);
}

<===>
================================================================================
<===> local_minde/to_black/input.scss
@use 'sass:color';
a {b: color.to-gamut(color(display-p3 0 -0.05 -0.05), $method: local-minde)}

<===> local_minde/to_black/output.css
a {
b: color(display-p3 0 0 0);
}
163 changes: 163 additions & 0 deletions spec/core_functions/color/to_gamut/error.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<===> color/type/input.scss
@use 'sass:color';
a {b: color.to-gamut(c, $method: local-minde)}

<===> color/type/error
Error: $color: c is not a color.
,
2 | a {b: color.to-gamut(c, $method: local-minde)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> space/type/input.scss
@use 'sass:color';
a {b: color.to-gamut(pink, $space: red, $method: local-minde)}

<===> space/type/error
Error: $space: red is not a string.
,
2 | a {b: color.to-gamut(pink, $space: red, $method: local-minde)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> space/unknown/input.scss
@use 'sass:color';
a {b: color.to-gamut(pink, $space: c, $method: local-minde)}

<===> space/unknown/error
Error: $space: Unknown color space "c".
,
2 | a {b: color.to-gamut(pink, $space: c, $method: local-minde)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> space/quoted/input.scss
@use 'sass:color';
a {b: color.to-gamut(pink, $space: "rgb", $method: local-minde)}

<===> space/quoted/error
Error: $space: Expected "rgb" to be an unquoted string.
,
2 | a {b: color.to-gamut(pink, $space: "rgb", $method: local-minde)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> method/type/input.scss
@use 'sass:color';
a {b: color.to-gamut(pink, $method: 1)}

<===> method/type/error
Error: $method: 1 is not a string.
,
2 | a {b: color.to-gamut(pink, $method: 1)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> method/unknown/input.scss
@use 'sass:color';
a {b: color.to-gamut(pink, $method: c)}

<===> method/unknown/error
Error: Unknown gamut map method "c".
,
2 | a {b: color.to-gamut(pink, $method: c)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> method/quoted/input.scss
@use 'sass:color';
a {b: color.to-gamut(pink, $method: "clip")}

<===> method/quoted/error
Error: $method: Expected "clip" to be an unquoted string.
,
2 | a {b: color.to-gamut(pink, $method: "clip")}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> method/absent/input.scss
@use 'sass:color';
a {b: color.to-gamut(pink)}

<===> method/absent/error
Error: $method: color.to-gamut() requires a $method argument for forwards-compatibility with changes in the CSS spec. Suggestion:

$method: local-minde
,
2 | a {b: color.to-gamut(pink)}
| ^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> method/null/input.scss
@use 'sass:color';
a {b: color.to-gamut(pink, $method: null)}

<===> method/null/error
Error: $method: color.to-gamut() requires a $method argument for forwards-compatibility with changes in the CSS spec. Suggestion:

$method: local-minde
,
2 | a {b: color.to-gamut(pink, $method: null)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> too_few_args/input.scss
@use 'sass:color';
a {b: color.to-gamut()}

<===> too_few_args/error
Error: Missing argument $color.
,--> input.scss
2 | a {b: color.to-gamut()}
| ^^^^^^^^^^^^^^^^ invocation
'
,--> sass:color
1 | @function to-gamut($color, $space: null, $method: null) {
| ============================================= declaration
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> too_many_args/input.scss
@use 'sass:color';
a {b: color.to-gamut(red, rgb, clip, c)}

<===> too_many_args/error
Error: Only 3 arguments allowed, but 4 were passed.
,--> input.scss
2 | a {b: color.to-gamut(red, rgb, clip, c)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation
'
,--> sass:color
1 | @function to-gamut($color, $space: null, $method: null) {
| ============================================= declaration
'
input.scss 2:7 root stylesheet
83 changes: 83 additions & 0 deletions spec/core_functions/color/to_gamut/hsl.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<===> clip/in_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(hsl(70deg 50% 50%), $method: clip)}

<===> clip/in_gamut/output.css
a {
b: hsl(70, 50%, 50%);
}

<===>
================================================================================
<===> clip/out_of_gamut/input.scss
@use 'sass:color';
a {
b: color.to-gamut(
color.change(hsl(70deg 50% 50%), $saturation: 200%),
$method: clip
);
}

<===> clip/out_of_gamut/output.css
a {
b: hsl(70, 100%, 50%);
}

<===>
================================================================================
<===> local_minde/in_gamut/input.scss
@use 'sass:color';
a {b: color.to-gamut(hsl(70deg 50% 50%), $method: local-minde)}

<===> local_minde/in_gamut/output.css
a {
b: hsl(70, 50%, 50%);
}

<===>
================================================================================
<===> local_minde/out_of_gamut/input.scss
@use 'sass:color';
a {
b: color.to-gamut(
color.change(hsl(70deg 50% 50%), $saturation: 107%),
$method: local-minde
);
}

<===> local_minde/out_of_gamut/output.css
a {
b: hsl(73.5850781672, 100%, 67.4750294398%);
}

<===>
================================================================================
<===> local_minde/to_white/input.scss
@use 'sass:color';
a {
b: color.to-gamut(
color.change(hsl(70deg 50% 50%), $saturation: 120%),
$method: local-minde
);
}

<===> local_minde/to_white/output.css
a {
b: hsl(none 0% 100%);
}

<===>
================================================================================
<===> local_minde/to_black/input.scss
@use 'sass:color';
a {
b: color.to-gamut(
color.change(hsl(70deg 100% 50%), $lightness: -1%),
$method: local-minde
);
}

<===> local_minde/to_black/output.css
a {
b: hsl(none 0% 0%);
}
Loading

0 comments on commit 71c13cf

Please sign in to comment.