|
3 | 3 | using Test |
4 | 4 |
|
5 | 5 | using StyledStrings: StyledStrings, Legacy, SimpleColor, FACES, Face, |
6 | | - @styled_str, styled, StyledMarkup, eachregion, getface, addface!, loadface!, resetfaces!, |
| 6 | + @styled_str, styled, StyledMarkup, getface, addface!, loadface!, resetfaces!, |
7 | 7 | AnnotatedString, AnnotatedChar, AnnotatedIOBuffer, annotations |
8 | 8 | using .StyledMarkup: MalformedStylingMacro |
9 | 9 |
|
|
35 | 35 | # When tested as part of the stdlib, the package prefix can start appearing in show methods. |
36 | 36 | choppkg(s::String) = chopprefix(s, "StyledStrings.") |
37 | 37 |
|
38 | | -@testset "Eachregion" begin |
39 | | - annregions(str::String, annots::Vector{<:Tuple{UnitRange{Int}, Symbol, <:Any}}) = |
40 | | - [(s, Tuple.(a)) for (s, a) in eachregion(AnnotatedString(str, annots))] |
41 | | - # Regions that do/don't extend to the left/right edges |
42 | | - @test annregions(" abc ", [(2:4, :face, :bold)]) == |
43 | | - [(" ", []), |
44 | | - ("abc", [(:face, :bold)]), |
45 | | - (" ", [])] |
46 | | - @test annregions(" x ", [(2:2, :face, :bold)]) == |
47 | | - [(" ", []), |
48 | | - ("x", [(:face, :bold)]), |
49 | | - (" ", [])] |
50 | | - @test annregions(" x", [(2:2, :face, :bold)]) == |
51 | | - [(" ", []), |
52 | | - ("x", [(:face, :bold)])] |
53 | | - @test annregions("x ", [(1:1, :face, :bold)]) == |
54 | | - [("x", [(:face, :bold)]), |
55 | | - (" ", [])] |
56 | | - @test annregions("x", [(1:1, :face, :bold)]) == |
57 | | - [("x", [(:face, :bold)])] |
58 | | - # Overlapping/nested regions |
59 | | - @test annregions(" abc ", [(2:4, :face, :bold), (3:3, :face, :italic)]) == |
60 | | - [(" ", []), |
61 | | - ("a", [(:face, :bold)]), |
62 | | - ("b", [(:face, :bold), (:face, :italic)]), |
63 | | - ("c", [(:face, :bold)]), |
64 | | - (" ", [])] |
65 | | - @test annregions("abc-xyz", [(1:7, :face, :bold), (1:3, :face, :green), (4:4, :face, :yellow), (4:7, :face, :italic)]) == |
66 | | - [("abc", [(:face, :bold), (:face, :green)]), |
67 | | - ("-", [(:face, :bold), (:face, :yellow), (:face, :italic)]), |
68 | | - ("xyz", [(:face, :bold), (:face, :italic)])] |
69 | | - # Preserving annotation order |
70 | | - @test annregions("abcd", [(1:3, :face, :red), (2:2, :face, :yellow), (2:3, :face, :green), (2:4, :face, :blue)]) == |
71 | | - [("a", [(:face, :red)]), |
72 | | - ("b", [(:face, :red), (:face, :yellow), (:face, :green), (:face, :blue)]), |
73 | | - ("c", [(:face, :red), (:face, :green), (:face, :blue)]), |
74 | | - ("d", [(:face, :blue)])] |
75 | | - @test annregions("abcd", [(2:4, :face, :blue), (1:3, :face, :red), (2:3, :face, :green), (2:2, :face, :yellow)]) == |
76 | | - [("a", [(:face, :red)]), |
77 | | - ("b", [(:face, :blue), (:face, :red), (:face, :green), (:face, :yellow)]), |
78 | | - ("c", [(:face, :blue), (:face, :red), (:face, :green)]), |
79 | | - ("d", [(:face, :blue)])] |
80 | | - # Region starting after a character spanning multiple codepoints. |
81 | | - @test annregions("𝟏x", [(1:4, :face, :red)]) == |
82 | | - [("𝟏", [(:face, :red)]), |
83 | | - ("x", [])] |
84 | | -end |
85 | | - |
86 | 38 | @testset "SimpleColor" begin |
87 | 39 | @test SimpleColor(:hey).value == :hey # no error |
88 | 40 | @test SimpleColor(0x01, 0x02, 0x03).value == (r=0x01, g=0x02, b=0x03) |
|
0 commit comments