chibi-scheme/lib/chibi/shell-test.sld
2022-07-01 22:39:27 +09:00

39 lines
1.3 KiB
Scheme

(define-library (chibi shell-test)
(import (scheme base) (chibi shell) (chibi test))
(export run-tests)
(begin
(define (run-tests)
(test-begin "(chibi shell)")
(test "hello\n"
(shell->string (echo "hello")))
(test "world\n"
(shell->string (echo "world")))
(test "HELLO\n"
(shell->string
,(shell-pipe
'(echo "hello")
'(tr "a-z" "A-Z"))))
(test "OLLEH\n"
(shell->string
,(shell-pipe
'(echo "hello")
'(tr "a-z" "A-Z")
'rev)))
(test "OLLEH\n"
(shell->string (echo "hello") (tr "a-z" "A-Z") rev))
(test "pass\n"
(shell->string ,(shell-if 'true '(echo "pass") '(echo "fail"))))
(test "fail\n"
(shell->string ,(shell-if 'false '(echo "pass") '(echo "fail"))))
(test "hello\nworld\n"
(shell->string ,(shell-do '(echo "hello") '(echo "world"))))
(test "hello\n"
(shell->string
,(shell-and 'true '(echo "hello") 'false '(echo "world"))))
(test "hello\n"
(shell->string
,(shell-or 'false '(echo "hello") '(echo "world"))))
(test "hello\n"
(shell->string (or false (echo "hello") (echo "world"))))
(test-end))))