all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 1/2] utils: Fix default-keyword-arguments.
@ 2016-09-20 21:29 Eric Bavier
  2016-09-20 21:29 ` [PATCH 2/2] utils: Support defaults in substitute-keyword-arguments Eric Bavier
  2016-09-24  2:16 ` [PATCH 1/2] utils: Fix default-keyword-arguments Ludovic Courtès
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Bavier @ 2016-09-20 21:29 UTC (permalink / raw)
  To: guix-devel; +Cc: Eric Bavier

From: Eric Bavier <bavier@member.fsf.org>

* guix/utils.scm (default-keyword-arguments): Properly test for present
keywords.
* tests/utils.scm (default-keyword-arguments): New test.
---
 guix/utils.scm  |  2 +-
 tests/utils.scm | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/guix/utils.scm b/guix/utils.scm
index c68094c..ded3114 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -369,7 +369,7 @@ keywords not already present in ARGS."
     (match defaults
       ((kw value rest ...)
        (loop rest
-             (if (assoc-ref kw args)
+             (if (memq kw args)
                  args
                  (cons* kw value args))))
       (()
diff --git a/tests/utils.scm b/tests/utils.scm
index 6590ed9..960928c 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -111,6 +111,18 @@
         (ensure-keyword-arguments '(#:foo 2) '(#:bar 3))
         (ensure-keyword-arguments '(#:foo 2) '(#:bar 3 #:foo 42))))
 
+(test-equal "default-keyword-arguments"
+  '((#:foo 2)
+    (#:foo 2)
+    (#:foo 2 #:bar 3)
+    (#:foo 2 #:bar 3)
+    (#:foo 2 #:bar 3))
+  (list (default-keyword-arguments '() '(#:foo 2))
+        (default-keyword-arguments '(#:foo 2) '(#:foo 4))
+        (default-keyword-arguments '() '(#:bar 3 #:foo 2))
+        (default-keyword-arguments '(#:bar 3) '(#:foo 2))
+        (default-keyword-arguments '(#:foo 2 #:bar 3) '(#:bar 6))))
+
 (test-assert "filtered-port, file"
   (let* ((file  (search-path %load-path "guix.scm"))
          (input (open-file file "r0b")))
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-30 20:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-20 21:29 [PATCH 1/2] utils: Fix default-keyword-arguments Eric Bavier
2016-09-20 21:29 ` [PATCH 2/2] utils: Support defaults in substitute-keyword-arguments Eric Bavier
2016-09-24  2:21   ` Ludovic Courtès
2016-09-26  4:08     ` Eric Bavier
2016-09-30 20:24       ` Ludovic Courtès
2016-09-24  2:16 ` [PATCH 1/2] utils: Fix default-keyword-arguments Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.