diff options
Diffstat (limited to '')
-rw-r--r-- | tests/test-module-tree/README.md | 2 | ||||
-rw-r--r-- | tests/unit/util/io.scm | 36 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/test-module-tree/README.md b/tests/test-module-tree/README.md index 07cdca5d..4af3b5a9 100644 --- a/tests/test-module-tree/README.md +++ b/tests/test-module-tree/README.md @@ -2,3 +2,5 @@ Test module tree ================ This directory contains test data, primarily for the module-introspection. + +Changing any of these files requires a full re-run of all tests. diff --git a/tests/unit/util/io.scm b/tests/unit/util/io.scm new file mode 100644 index 00000000..f06fb3bd --- /dev/null +++ b/tests/unit/util/io.scm @@ -0,0 +1,36 @@ +(define-module (test io) + :use-module (srfi srfi-64) + :use-module (srfi srfi-64 test-error) + :use-module (srfi srfi-88) + :use-module (hnh util io)) + +(test-equal "read-lines" + '("Test module tree" + "================" + "" + "This directory contains test data, primarily for the module-introspection." + "" + "Changing any of these files requires a full re-run of all tests.") + (call-with-input-file "tests/test-module-tree/README.md" + read-lines)) + +;;; TODO how do you even unit test these? +;;; TODO with-atomic-output-to-file +;;; TODO call-with-tmpfile + +;;; This is technically implementation dependant, since the +;;; string definition of a newline is unspecified by RnRs. +(test-group "displayln" + (test-equal "Hello\n" + (with-output-to-string + (lambda () (displayln "Hello")))) + (test-equal "World\n" + (call-with-output-string + (lambda (p) (displayln "World" p))))) + +(test-group "->port" + (test-assert (port? (->port (current-input-port)))) + (test-assert (port? (->port "Hello, World"))) + (test-error 'misc-error (->port 1))) + +'((hnh util io)) |