aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-18 23:18:12 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-18 23:18:12 +0100
commitf509c70b6064c631c0de1c26ca4272d143188383 (patch)
treebac224d98f006faba5feb7149193b485fc06ea67 /tests
parentSimplified (monad state) modify. (diff)
downloadscheme-monad-f509c70b6064c631c0de1c26ca4272d143188383.tar.gz
scheme-monad-f509c70b6064c631c0de1c26ca4272d143188383.tar.xz
Rewrote writer monad.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test.scm26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test.scm b/tests/test.scm
index 6ce798e..562c736 100755
--- a/tests/test.scm
+++ b/tests/test.scm
@@ -51,3 +51,29 @@
(test-end "state-test")
+
+(test-begin "writer-test")
+
+(use-modules (monad writer))
+
+(test-equal '(10 "HelloWorld")
+ (run-writer
+ (do (w "Hello")
+ (w "World")
+ (return-writer 10))))
+
+(test-equal '(10 "HelloWorld")
+ (run-writer
+ (do "Hello" "World"
+ (return-writer 10))))
+
+(test-equal '(3 "Applied + to (1 2) ⇒ 3\n")
+ (run-writer (with-writer + 1 2)))
+
+(test-equal '(10 "Hello, World")
+ (run-writer
+ (do (string-append "Hello" ", ")
+ "World"
+ (return-writer 10))))
+
+(test-end "writer-test")