Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Color 4] Add tests for color equality with same() and == #1984

Merged
merged 2 commits into from
May 9, 2024

Conversation

nex3
Copy link
Contributor

@nex3 nex3 commented May 3, 2024

[skip dart-sass]

Copy link
Member

@Goodwine Goodwine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I have a couple of questions due to my lack of understanding on how hex colors are parsed 😅

@@ -0,0 +1,251 @@
<===> true/legacy/same_space/rgb/no_none/input.scss
a {b: #abcdef == #abcdef}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Sass parses #abc, does it internally store it as if it parsed #aabbcc?

Currently #abc == #aabbccff returns true, per the spec changes this will now return false, or no?

And if it now returns false, is this covered by the false/legacy/same_space/rgb/one_none test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All colors are stored as four floating-point numbers (the three color space channels and the alpha channel) as well as the color space name. #abc, #aabbcc, #aabbccff, and rgb(170 187 255) all share the same internal representation, and so are mutually == to one another. We test this in the tests for color parsing and constructor functions; here we can safely assume that the internal representations are the same, and that we only need to verify checks for that expected representation.

@@ -0,0 +1,244 @@
<===> true/same_space/identical/input.scss
@use 'sass:color';
a {b: color.same(#abcdef, #abcdef)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, is color.same(#abc, #abcf) covered by true/same_space/none_and_zero or by true/different_space/no_none/input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#abcf isn't a color. Do you mean #abcdef? Those would be different colors, so they'd be under false/.

Copy link
Member

@Goodwine Goodwine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to select "Approve" 😅

@nex3 nex3 merged commit c20c741 into feature.color-4 May 9, 2024
12 checks passed
@nex3 nex3 deleted the color-same branch May 9, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants