aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-10-08 23:35:08 +0200
committerLudovic Courtès <ludo@gnu.org>2014-10-08 23:35:20 +0200
commit405a9d4ec9806993a6453f0dfba78fc65d5e7993 (patch)
tree83096b186be61f0a0daca3b808ab2aeb58bfb352 /tests
parent2e1bafb03438757c7cc34c16230b00623507ff84 (diff)
downloadpatches-405a9d4ec9806993a6453f0dfba78fc65d5e7993.tar
patches-405a9d4ec9806993a6453f0dfba78fc65d5e7993.tar.gz
monads: Add 'mbegin'.
* guix/monads.scm (mbegin): New macro. * tests/monads.scm ("mbegin"): New test. * doc/guix.texi (The Store Monad): Document it.
Diffstat (limited to 'tests')
-rw-r--r--tests/monads.scm17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/monads.scm b/tests/monads.scm
index 5514c8386c..6e3dd00f72 100644
--- a/tests/monads.scm
+++ b/tests/monads.scm
@@ -32,7 +32,7 @@
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-64))
-;; Test the (guix store) module.
+;; Test the (guix monads) module.
(define %store
(open-connection-for-tests))
@@ -99,6 +99,21 @@
%monads
%monad-run))
+(test-assert "mbegin"
+ (every (lambda (monad run)
+ (with-monad monad
+ (let* ((been-there? #f)
+ (number (mbegin monad
+ (return 1)
+ (begin
+ (set! been-there? #t)
+ (return 2))
+ (return 3))))
+ (and (= (run number) 3)
+ been-there?))))
+ %monads
+ %monad-run))
+
(test-assert "mlet* + text-file + package-file"
(run-with-store %store
(mlet* %store-monad ((guile (package-file %bootstrap-guile "bin/guile"))