@@ -342,28 +342,34 @@ end
342
342
# Interpolation
343
343
let annotatedstring = GlobalRef (StyledMarkup, :annotatedstring )
344
344
AnnotatedString = GlobalRef (StyledMarkup, :AnnotatedString )
345
+ annotatedstring_optimize! = GlobalRef (StyledMarkup, :annotatedstring_optimize! )
346
+ chain = GlobalRef (StyledMarkup, :|> )
345
347
Pair = GlobalRef (StyledMarkup, :Pair )
346
348
Symbol = GlobalRef (StyledMarkup, :Symbol )
347
349
Any = GlobalRef (StyledMarkup, :Any )
348
- @test :($ annotatedstring (val)) == @macroexpand styled " $val"
349
- @test :($ annotatedstring (" a" , val)) == @macroexpand styled " a$val"
350
- @test :($ annotatedstring (" a" , val, " b" )) == @macroexpand styled " a$(val)b"
350
+ @test :($ chain ( $ annotatedstring (val), $ annotatedstring_optimize! )) == @macroexpand styled " $val"
351
+ @test :($ chain ( $ annotatedstring (" a" , val), $ annotatedstring_optimize! )) == @macroexpand styled " a$val"
352
+ @test :($ chain ( $ annotatedstring (" a" , val, " b" ), $ annotatedstring_optimize! )) == @macroexpand styled " a$(val)b"
351
353
# @test :($annotatedstring(StyledStrings.AnnotatedString(string(val), $(Pair{Symbol, Any}(:face, :style))))) ==
352
354
# @macroexpand styled"{style:$val}"
353
- @test :($ annotatedstring ($ AnnotatedString (
354
- " val" , [($ (1 : 3 ), $ Pair {$Symbol, $Any} (:face , face))]))) ==
355
+ @test :($ chain ($ annotatedstring ($ AnnotatedString (
356
+ " val" , [($ (1 : 3 ), $ Pair {$Symbol, $Any} (:face , face))])),
357
+ $ annotatedstring_optimize!)) ==
355
358
@macroexpand styled " {$face:val}"
356
- @test :($ annotatedstring ($ AnnotatedString (
357
- " val" , [($ (1 : 3 ), $ Pair {$Symbol, $Any} (key, " val" ))]))) ==
359
+ @test :($ chain ($ annotatedstring ($ AnnotatedString (
360
+ " val" , [($ (1 : 3 ), $ Pair {$Symbol, $Any} (key, " val" ))])),
361
+ $ annotatedstring_optimize!)) ==
358
362
@macroexpand styled " {$key=val:val}"
359
- @test :($ annotatedstring ($ AnnotatedString (
360
- " val" , [($ (1 : 3 ), $ Pair {$Symbol, $Any} (key, val))]))) ==
363
+ @test :($ chain ($ annotatedstring ($ AnnotatedString (
364
+ " val" , [($ (1 : 3 ), $ Pair {$Symbol, $Any} (key, val))])),
365
+ $ annotatedstring_optimize!)) ==
361
366
@macroexpand styled " {$key=$val:val}"
362
367
# @test :($annotatedstring($AnnotatedString(
363
368
# string(val), $Pair{$Symbol, $Any}(key, val)))) ==
364
369
# @macroexpand styled"{$key=$val:$val}"
365
- @test :($ annotatedstring ($ AnnotatedString (
366
- " val" , [($ (1 : 3 ), $ Pair {$Symbol, $Any} (:face , $ (Face)(foreground = color)))]))) ==
370
+ @test :($ chain ($ annotatedstring ($ AnnotatedString (
371
+ " val" , [($ (1 : 3 ), $ Pair {$Symbol, $Any} (:face , $ (Face)(foreground = color)))])),
372
+ $ annotatedstring_optimize!)) ==
367
373
@macroexpand styled " {(foreground=$color):val}"
368
374
end
369
375
421
427
showerror (aio, err)
422
428
end
423
429
errstr = read (seekstart (aio), AnnotatedString)
424
- sort! (annotations (errstr), by= first) # Remove when julialang/julia/#53800 is merged.
425
430
@test errstr ==
426
431
styled " MalformedStylingMacro\n \
427
432
{error:│} Incomplete annotation declaration:\n \
0 commit comments