utils: Fix default-keyword-arguments.

* guix/utils.scm (default-keyword-arguments): Properly test for present
keywords.
* tests/utils.scm (default-keyword-arguments): New test.
This commit is contained in:
Eric Bavier 2016-09-01 08:20:25 -05:00
parent fb29e737d4
commit 347df60158
No known key found for this signature in database
GPG Key ID: 1EBBD204781F962C
2 changed files with 13 additions and 1 deletions

View File

@ -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))))
(()

View File

@ -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")))