]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/monads/monads-tests.factor
scryfall: better moxfield words
[factor.git] / extra / monads / monads-tests.factor
index a7b925ca2fc0cf09619c6ae20b0a43f4b957e933..ca02097401434e528b8b63a0f2713d3cee1cefaa 100644 (file)
@@ -1,4 +1,5 @@
-USING: tools.test math kernel sequences lists promises monads ;
+USING: tools.test math math.functions kernel sequences lists
+promises monads ;
 FROM: monads => do ;
 IN: monads.tests
 
@@ -113,6 +114,22 @@ LAZY: nats-from ( n -- list )
     run-writer
 ] unit-test
 
+{
+    T{ writer
+        { value 1.618033988749895 }
+        { log
+            "Started with five, took square root, added one, divided by two."
+        }
+    }
+} [
+    {
+        [ 5 "Started with five, " <writer> ]
+        [ sqrt "took square root, " <writer> ]
+        [ 1 + "added one, " <writer> ]
+        [ 2 / "divided by two." <writer> ]
+    } do
+] unit-test
+
 { T{ identity f 7 } }
 [
     4 identity-monad return