Skip to content

Commit

Permalink
Add specs for hex colors with alpha components
Browse files Browse the repository at this point in the history
This adds specs for both the deprecation behavior and the eventual
post-deprecation behavior.

See sass/sass#2179
  • Loading branch information
nex3 committed Jun 20, 2018
1 parent e7a7a35 commit 456f828
Show file tree
Hide file tree
Showing 15 changed files with 178 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spec/css/color/alpha_hex/deprecation/error
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
DEPRECATION WARNING on line 6, column 15 of /sass/spec/css/color/alpha_hex/deprecation/input.scss:
The value "#AbCd" is currently parsed as a string, but it will be parsed as a
color in a release on or after 19 September 2018.

To continue parsing it as a string, use "unquote('#AbCd')".
To parse it as a color, use "rgba(170, 187, 204, 0.8666666667)".

four-digit: #AbCd;
^^^^^

DEPRECATION WARNING on line 7, column 16 of /sass/spec/css/color/alpha_hex/deprecation/input.scss:
The value "#aBcDeFaB" is currently parsed as a string, but it will be parsed as a
color in a release on or after 19 September 2018.

To continue parsing it as a string, use "unquote('#aBcDeFaB')".
To parse it as a color, use "rgba(171, 205, 239, 0.6705882353)".

eight-digit: #aBcDeFaB;
^^^^^^^^^

DEPRECATION WARNING on line 8, column 28 of /sass/spec/css/color/alpha_hex/deprecation/input.scss:
The value "#abcd" is currently parsed as a string, but it will be parsed as a
color in a release on or after 19 September 2018.

To continue parsing it as a string, use "unquote('#abcd')".
To parse it as a color, use "rgba(170, 187, 204, 0.8666666667)".

four-digit-type: type-of(#abcd);
^^^^^

DEPRECATION WARNING on line 9, column 29 of /sass/spec/css/color/alpha_hex/deprecation/input.scss:
The value "#ABCDEFAB" is currently parsed as a string, but it will be parsed as a
color in a release on or after 19 September 2018.

To continue parsing it as a string, use "unquote('#ABCDEFAB')".
To parse it as a color, use "rgba(171, 205, 239, 0.6705882353)".

eight-digit-type: type-of(#ABCDEFAB);
^^^^^^^^^
7 changes: 7 additions & 0 deletions spec/css/color/alpha_hex/deprecation/error-libsass
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DEPRECATION WARNING on line 8, column 33 of /sass/spec/css/color/alpha_hex/deprecation/input.scss:
The value "#abcd" is currently parsed as a string, but it will be parsed as a color in
future versions of Sass. Use "unquote('#abcd')" to continue parsing it as a string.

DEPRECATION WARNING on line 9, column 38 of /sass/spec/css/color/alpha_hex/deprecation/input.scss:
The value "#ABCDEFAB" is currently parsed as a string, but it will be parsed as a color in
future versions of Sass. Use "unquote('#ABCDEFAB')" to continue parsing it as a string.
6 changes: 6 additions & 0 deletions spec/css/color/alpha_hex/deprecation/expected_output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
a {
four-digit: #AbCd;
eight-digit: #aBcDeFaB;
four-digit-type: string;
eight-digit-type: string;
}
10 changes: 10 additions & 0 deletions spec/css/color/alpha_hex/deprecation/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This spec tests the intermediate behavior of Sass implementations that have
// deprecated parsing tokens as unquoted strings when they're ambiguous between
// IDs or hex RGBA colors. These implementations should continue to parse those
// tokens as strings, but should emit a warning.
a {
four-digit: #AbCd;
eight-digit: #aBcDeFaB;
four-digit-type: type-of(#abcd);
eight-digit-type: type-of(#ABCDEFAB);
}
3 changes: 3 additions & 0 deletions spec/css/color/alpha_hex/deprecation/options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
:ignore_for:
- ruby-sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
a {
four-digit: #0123;
eight-digit: #98765432;
four-digit-red: 0;
four-digit-green: 17;
four-digit-blue: 34;
four-digit-alpha: 0.2;
eight-digit-red: 152;
eight-digit-green: 118;
eight-digit-blue: 84;
eight-digit-alpha: 0.19608;
}
12 changes: 12 additions & 0 deletions spec/css/color/alpha_hex/initial_digit/expected_output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
a {
four-digit: #0123;
eight-digit: #98765432;
four-digit-red: 0;
four-digit-green: 17;
four-digit-blue: 34;
four-digit-alpha: 0.2;
eight-digit-red: 152;
eight-digit-green: 118;
eight-digit-blue: 84;
eight-digit-alpha: 0.1960784314;
}
15 changes: 15 additions & 0 deletions spec/css/color/alpha_hex/initial_digit/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
a {
four-digit: #0123;
eight-digit: #98765432;

// Verify that the color channels are set correctly.
four-digit-red: red(#0123);
four-digit-green: green(#0123);
four-digit-blue: blue(#0123);
four-digit-alpha: alpha(#0123);

eight-digit-red: red(#98765432);
eight-digit-green: green(#98765432);
eight-digit-blue: blue(#98765432);
eight-digit-alpha: alpha(#98765432);
}
4 changes: 4 additions & 0 deletions spec/css/color/alpha_hex/initial_digit/options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
:start_version: '3.6'
:todo:
- libsass
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
a {
four-digit: #AbCd;
eight-digit: #aBcDeF12;
four-digit-red: 170;
four-digit-green: 187;
four-digit-blue: 204;
four-digit-alpha: 0.86667;
eight-digit-red: 171;
eight-digit-green: 205;
eight-digit-blue: 239;
eight-digit-alpha: 0.07059;
}
12 changes: 12 additions & 0 deletions spec/css/color/alpha_hex/initial_letter/expected_output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
a {
four-digit: #AbCd;
eight-digit: #aBcDeF12;
four-digit-red: 170;
four-digit-green: 187;
four-digit-blue: 204;
four-digit-alpha: 0.8666666666;
eight-digit-red: 171;
eight-digit-green: 205;
eight-digit-blue: 239;
eight-digit-alpha: 0.0705882353;
}
15 changes: 15 additions & 0 deletions spec/css/color/alpha_hex/initial_letter/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
a {
four-digit: #AbCd;
eight-digit: #aBcDeF12;

// Verify that the color channels are set correctly.
four-digit-red: red(#abcd);
four-digit-green: green(#abcd);
four-digit-blue: blue(#abcd);
four-digit-alpha: alpha(#abcd);

eight-digit-red: red(#ABCDEF12);
eight-digit-green: green(#ABCDEF12);
eight-digit-blue: blue(#ABCDEF12);
eight-digit-alpha: alpha(#ABCDEF12);
}
5 changes: 5 additions & 0 deletions spec/css/color/alpha_hex/initial_letter/options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
:start_version: '3.6'
:todo:
- dart-sass
- libsass
10 changes: 10 additions & 0 deletions spec/css/id_values/expected_output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
a {
two-letters: #ab;
five-letters: #abcde;
seven-letters: #abcdefa;
nine-letters: #abcdefabc;
three-letters-not-hex: #axc;
four-letters-not-hex: #axcd;
six-letters-not-hex: #abcxde;
eight-letters-not-hex: #abcxdefa;
}
16 changes: 16 additions & 0 deletions spec/css/id_values/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// The CSS nav-up property and its siblings allow ID tokens in their values, so
// Sass parses any tokens that start with a "#" followed by an identifier as an
// ID if it can't be parsed as a color.
a {
// These IDs are the wrong number of letters to be a hex color.
two-letters: #ab;
five-letters: #abcde;
seven-letters: #abcdefa;
nine-letters: #abcdefabc;

// These IDs contain letters outside the hexadecimal gamut.
three-letters-not-hex: #axc;
four-letters-not-hex: #axcd;
six-letters-not-hex: #abcxde;
eight-letters-not-hex: #abcxdefa;
}

0 comments on commit 456f828

Please sign in to comment.