gnu: youtube-viewer: Refer to youtube-dl.
[jackhill/guix/guix.git] / tests / monads.scm
index 5529a61..18bf411 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,6 +20,7 @@
   #:use-module (guix tests)
   #:use-module (guix store)
   #:use-module (guix monads)
+  #:use-module (guix grafts)
   #:use-module (guix derivations)
   #:use-module (guix packages)
   #:use-module (gnu packages)
@@ -36,6 +37,9 @@
 (define %store
   (open-connection-for-tests))
 
+;; Globally disable grafts because they can trigger early builds.
+(%graft? #f)
+
 (define %monads
   (list %identity-monad %store-monad %state-monad))
 
 
 (test-assert "lift"
   (every (lambda (monad run)
-           (let ((f (lift1 1+ monad)))
+           (let ((f (lift1 1+ monad))
+                 (g (apply lift1 1+ (list monad))))
              (with-monad monad
                (let ((number (random 777)))
                  (= (run (>>= (return number) f))
+                    (run (>>= (return number) g))
                     (1+ number))))))
          %monads
          %monad-run))
 
+(test-assert ">>= with more than two arguments"
+  (every (lambda (monad run)
+           (let ((1+ (lift1 1+ monad))
+                 (2* (lift1 (cut * 2 <>) monad)))
+             (with-monad monad
+               (let ((number (random 777)))
+                 (= (run (>>= (return number)
+                              1+ 1+ 1+
+                              2* 2* 2*))
+                    (* 8 (+ number 3)))))))
+         %monads
+         %monad-run))
+
 (test-assert "mbegin"
   (every (lambda (monad run)
            (with-monad monad
      '())))
 
 (test-end "monads")
-
-\f
-(exit (= (test-runner-fail-count (test-runner-current)) 0))