Tidy up tests some more!

This commit is contained in:
Vivianne 2024-02-09 20:37:00 -05:00
parent a3ee78b9ec
commit a230eb9f10
4 changed files with 31 additions and 27 deletions

View File

@ -18,14 +18,17 @@
(licensing #f)))
(files (libraries
((directory
"termenv"
((scheme-file "style")
(scheme-file "unix")
(scheme-file "hyperlink")
(scheme-file "screen")
(scheme-file "color")
(scheme-file "hconfig")))
(scheme-file "termenv")))
"termenv"
((scheme-file "style")
(scheme-file "unix")
(scheme-file "hyperlink")
(scheme-file "screen")
(scheme-file "color")
(scheme-file "hconfig")))
(scheme-file "termenv")
(directory
"tests"
((scheme-file "utils")))))
(tests ((directory
"tests"
((scheme-file "test-screen")

View File

@ -1,5 +1,6 @@
(define-module (tests test-screen)
#:use-module (termenv screen)
#:use-module (tests utils)
#:use-module (srfi srfi-64)
#:use-module (rnrs io ports)
#:use-module (scheme base)
@ -7,13 +8,9 @@
(test-begin "test-screen")
(define (output-equal expected)
"Ensures that the output sequence is what is expected"
(define vec (get-output-bytevector (current-output-port)))
(define str (bytevector->string vec (native-transcoder)))
(test-equal str expected))
(verify-output
"\x1b[0m"
(reset (current-output-port)))
(parameterize ((current-output-port (open-output-bytevector)))
#f)
(test-end "test-screen")

View File

@ -1,5 +1,6 @@
(define-module (tests test-style)
#:use-module (termenv style)
#:use-module (tests utils)
#:use-module (srfi srfi-64)
#:use-module (rnrs io ports)
#:use-module (scheme base)
@ -7,18 +8,6 @@
(test-begin "test-style")
(define (verify-output-fn expected proc)
"Ensures that the output sequence is what is expected"
(test-equal
expected
(call-with-output-string
(λ (port)
(parameterize ((current-output-port port))
(proc))))))
(define-syntax-rule (verify-output expected body ...)
(verify-output-fn expected (lambda () body ...)))
(verify-output
"hello there"
(format #t "~a" (make-style "hello there")))

15
tests/utils.scm Normal file
View File

@ -0,0 +1,15 @@
(define-module (tests utils)
#:use-module (srfi srfi-64)
#:export (verify-output))
(define (verify-output-fn expected proc)
"Ensures that the output sequence is what is expected"
(test-equal
expected
(call-with-output-string
(λ (port)
(parameterize ((current-output-port port))
(proc))))))
(define-syntax-rule (verify-output expected body ...)
(verify-output-fn expected (lambda () body ...)))