@@ -32,6 +32,9 @@ function with_terminfo(fn::Function, tinfo::Base.TermInfo)
32
32
end
33
33
end
34
34
35
+ # When tested as part of the stdlib, the package prefix can start appearing in show methods.
36
+ choppkg (s:: String ) = chopprefix (s, " StyledStrings." )
37
+
35
38
@testset " SimpleColor" begin
36
39
@test SimpleColor (:hey ). value == :hey # no error
37
40
@test SimpleColor (0x01 , 0x02 , 0x03 ). value == (r= 0x01 , g= 0x02 , b= 0x03 )
43
46
@test tryparse (SimpleColor, " !not a color" ) === nothing
44
47
@test parse (SimpleColor, " blue" ) == SimpleColor (:blue )
45
48
@test_throws ArgumentError parse (SimpleColor, " !not a color" )
46
- @test sprint (show, SimpleColor (:blue )) ==
49
+ @test sprint (show, SimpleColor (:blue )) |> choppkg ==
47
50
" SimpleColor(:blue)"
48
- @test sprint (show, SimpleColor (0x123456 )) ==
51
+ @test sprint (show, SimpleColor (0x123456 )) |> choppkg ==
49
52
" SimpleColor(0x123456)"
50
- @test sprint (show, MIME (" text/plain" ), SimpleColor (:blue )) ==
53
+ @test sprint (show, MIME (" text/plain" ), SimpleColor (:blue )) |> choppkg ==
51
54
" SimpleColor(blue)"
52
- @test sprint (show, MIME (" text/plain" ), SimpleColor (:blue ), context = :color => true ) ==
55
+ @test sprint (show, MIME (" text/plain" ), SimpleColor (:blue ), context = :color => true ) |> choppkg ==
53
56
" SimpleColor(\e [34m■\e [39m blue)"
54
57
@test sprint (show, MIME (" text/plain" ), SimpleColor (:blue ), context = (:color => true , :typeinfo => SimpleColor)) ==
55
58
" \e [34m■\e [39m blue"
211
214
StyledStrings. resetfaces! ()
212
215
end
213
216
# Pretty display
214
- @test sprint (show, MIME (" text/plain" ), getface ()) ==
217
+ @test sprint (show, MIME (" text/plain" ), getface ()) |> choppkg ==
215
218
"""
216
219
Face (sample)
217
220
font: monospace
224
227
strikethrough: false
225
228
inverse: false\
226
229
"""
227
- @test sprint (show, MIME (" text/plain" ), getface (), context = :color => true ) ==
230
+ @test sprint (show, MIME (" text/plain" ), getface (), context = :color => true ) |> choppkg ==
228
231
"""
229
232
Face (sample)
230
233
font: monospace
@@ -237,35 +240,35 @@ end
237
240
strikethrough: false
238
241
inverse: false\
239
242
"""
240
- @test sprint (show, MIME (" text/plain" ), FACES. default[:red ], context = :color => true ) ==
243
+ @test sprint (show, MIME (" text/plain" ), FACES. default[:red ], context = :color => true ) |> choppkg ==
241
244
"""
242
245
Face (\e [31msample\e [39m)
243
246
foreground: \e [31m■\e [39m red\
244
247
"""
245
- @test sprint (show, FACES. default[:red ]) ==
248
+ @test sprint (show, FACES. default[:red ]) |> choppkg ==
246
249
" Face(foreground=SimpleColor(:red))"
247
- @test sprint (show, MIME (" text/plain" ), FACES. default[:red ], context = :compact => true ) ==
250
+ @test sprint (show, MIME (" text/plain" ), FACES. default[:red ], context = :compact => true ) |> choppkg ==
248
251
" Face(foreground=SimpleColor(:red))"
249
- @test sprint (show, MIME (" text/plain" ), FACES. default[:red ], context = (:compact => true , :color => true )) ==
252
+ @test sprint (show, MIME (" text/plain" ), FACES. default[:red ], context = (:compact => true , :color => true )) |> choppkg ==
250
253
" Face(\e [31msample\e [39m)"
251
- @test sprint (show, MIME (" text/plain" ), FACES. default[:highlight ], context = :compact => true ) ==
254
+ @test sprint (show, MIME (" text/plain" ), FACES. default[:highlight ], context = :compact => true ) |> choppkg ==
252
255
" Face(inverse=true, inherit=[:emphasis])"
253
256
with_terminfo (vt100) do # Not truecolor capable
254
- @test sprint (show, MIME (" text/plain" ), FACES. default[:region ], context = :color => true ) ==
257
+ @test sprint (show, MIME (" text/plain" ), FACES. default[:region ], context = :color => true ) |> choppkg ==
255
258
"""
256
259
Face (\e [48;5;237msample\e [49m)
257
260
background: \e [38;5;237m■\e [39m #3a3a3a\
258
261
"""
259
262
end
260
263
with_terminfo (fancy_term) do # Truecolor capable
261
- @test sprint (show, MIME (" text/plain" ), FACES. default[:region ], context = :color => true ) ==
264
+ @test sprint (show, MIME (" text/plain" ), FACES. default[:region ], context = :color => true ) |> choppkg ==
262
265
"""
263
266
Face (\e [48;2;58;58;58msample\e [49m)
264
267
background: \e [38;2;58;58;58m■\e [39m #3a3a3a\
265
268
"""
266
269
end
267
270
with_terminfo (vt100) do # Ensure `enter_reverse_mode` exists
268
- @test sprint (show, MIME (" text/plain" ), FACES. default[:highlight ], context = :color => true ) ==
271
+ @test sprint (show, MIME (" text/plain" ), FACES. default[:highlight ], context = :color => true ) |> choppkg ==
269
272
"""
270
273
Face (\e [34m\e [7msample\e [39m\e [27m)
271
274
inverse: true
0 commit comments