-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add test and followup for StyledStringsExt
#302
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" # FIXME: workaround for unregistered StyledStrings | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
|
||
# FIXME: Once StyledStrings v1 is registered, remove the following and the `Pkg` dependency | ||
if isdefined(Base, :get_extension) | ||
import Pkg | ||
if VERSION < v"1.11" | ||
Pkg.add(url="https://github.com/JuliaLang/StyledStrings.jl", rev="julia1-compat") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how long There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't anticipate deleting the branch at any point, it will just become abandoned at some stage. |
||
else | ||
Pkg.add("StyledStrings") | ||
end | ||
end | ||
|
||
using ColorTypes | ||
using ColorTypes.FixedPointNumbers | ||
using Test | ||
|
@@ -7,6 +18,19 @@ using Test | |
using Documenter | ||
doctest(ColorTypes, manual = false) | ||
|
||
@testset "StyledStringsExt" begin | ||
if isdefined(Base, :get_extension) | ||
import StyledStrings | ||
try | ||
simplecolor = convert(StyledStrings.SimpleColor, ARGB(1, 0.6, 0, 0.4)) | ||
@test simplecolor === StyledStrings.SimpleColor(0xff, 0x99, 0x00) | ||
catch | ||
@test_broken convert(StyledStrings.SimpleColor, ARGB(1, 0.6, 0, 0.4)) | ||
end | ||
@test_throws Exception convert(StyledStrings.SimpleColor, HSV(0, 0, 0)) | ||
end | ||
end | ||
|
||
# if the test below fails, please extend the list of types at the call to | ||
# make_alpha in types.jl (this is the price of making that list explicit) | ||
ctypes = union(setdiff(ColorTypes.parametric3, (XRGB, RGBX)), (Gray,)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed in the close future, but currently
StyledStrings
is unregistered and it should be v1 for the time being.We are touching the internals of
StyledStrings
, so we run the risk of incompatibility. And that can't be prevented by the"1"
cap anyway.(In other words, if we follow the principle, we need to specify the patch version here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI,
SimpleColor
is part of the public API in the 1.11 stdlib version, so the conversion implemented here shouldn't break in any 1.x version of StyledStrings.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What constitutes a breaking change is ambiguous. If
SimpleColor
added a feature to have an alpha component, it would not break the code, but it would go against the user's intuition.That is just an example.
StyledStrings
is community owned, although you are the lead developer. I don't believe anything bad will happen, but there is no guarantee how it will turn out.For example, CI could cease to function effectively even though no one has done anything wrong.