~ruther/guix-local

347df60158a11abbc9b84ac36cd113362d7e09e0 — Eric Bavier 9 years ago fb29e73
utils: Fix default-keyword-arguments.

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

M guix/utils.scm
M tests/utils.scm
M guix/utils.scm => guix/utils.scm +1 -1
@@ 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))))
      (()

M tests/utils.scm => tests/utils.scm +12 -0
@@ 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")))