@@ -5,7 +5,7 @@ using Test
55using StyledStrings: StyledStrings, Legacy, SimpleColor, FACES, Face,
66 @styled_str , styled, StyledMarkup, getface, addface!, loadface!, resetfaces!
77using . StyledMarkup: MalformedStylingMacro
8- using Base: AnnotatedString, AnnotatedChar, AnnotatedIOBuffer
8+ using Base: AnnotatedString, AnnotatedChar, AnnotatedIOBuffer, annotations
99
1010# For output testing
1111
388388 @test_throws MalformedStylingMacro styled (" {(weight=invalid):}" )
389389 @test_throws MalformedStylingMacro styled (" {(slant=invalid):}" )
390390 @test_throws MalformedStylingMacro styled (" {(invalid=):}" )
391+ # Test the error printing too
392+ aio = AnnotatedIOBuffer ()
393+ try
394+ styled (" {" )
395+ catch err
396+ showerror (aio, err)
397+ end
398+ errstr = read (seekstart (aio), AnnotatedString)
399+ Base. annotatedstring_optimize! (errstr) # Remove when julialang/julia/#53801 is merged.
400+ filter! (((region, _),) -> ! isempty (region),
401+ annotations (errstr))
402+ sort! (annotations (errstr), by= first) # Remove when julialang/julia/#53800 is merged.
403+ @test errstr ==
404+ styled " MalformedStylingMacro\n \
405+ {error:│} Incomplete annotation declaration:\n \
406+ {error:│} {bright_green:\"\{\" }\n \
407+ {error:│} {info:╰─╴starts here}\n \
408+ {error:┕} {light,italic:1 issue}\n "
391409end
392410
393411@testset " AnnotatedIOBuffer" begin
0 commit comments