diff --git a/tests/test-ansi.scm b/tests/test-ansi.scm index ccd1ade..3253b31 100644 --- a/tests/test-ansi.scm +++ b/tests/test-ansi.scm @@ -6,7 +6,7 @@ (test-begin "test-ansi") -(define pink-text-then-reset "\x1B[38;2;249;38;114m你好reflow\x1B[0m") +(define pink-text-then-reset "\x1b[38;2;249;38;114m你好reflow\x1b[0m") (test-equal "Text should be forwarded to the port properly" @@ -22,7 +22,6 @@ (test-equal "Current sequence should be #f" #f (cur-seq))))) - (test-equal "Text should contain a bold sequence with only one reset sequence" "\x1b[1mhello\x1b[0m你好" @@ -45,5 +44,33 @@ (display "你好" ansi-port)))) +(test-equal + "Text should contain a bold sequence, reset, and then another bold sequence" + "\x1b[1mhello\x1b[0m你好\x1b[1mworld" + (call-with-output-string + (λ (str-port) + (define-values (ansi-port cur-seq reset restore) + (make-ansi-port-tuple str-port)) + + (display "\x1b[1mhello" ansi-port) + (reset) + (display "你好" ansi-port) + (restore) + (display "world" ansi-port)))) + +(test-equal + "Text should contain a bold sequence, text, then italic sequence, reset and restore" + "\x1b[1mhello\x1b[3m你好\x1b[0mworld! \x1b[1m\x1b[3mit's me!" + (call-with-output-string + (λ (str-port) + (define-values (ansi-port cur-seq reset restore) + (make-ansi-port-tuple str-port)) + + (display "\x1b[1mhello" ansi-port) + (display "\x1b[3m你好" ansi-port) + (reset) + (display "world! " ansi-port) + (restore) + (display "it's me!" ansi-port)))) (test-end "test-ansi")