mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 13:10:33 +02:00
utils: Support defaults in substitute-keyword-arguments.
* guix/utils.scm (collect-default-args, expand-default-args): New syntax. (substitute-keyword-arguments): Allow default value declarations. * tests/utils.scm (substitute-keyword-arguments): New test.
This commit is contained in:
@@ -123,6 +123,26 @@
|
||||
(default-keyword-arguments '(#:bar 3) '(#:foo 2))
|
||||
(default-keyword-arguments '(#:foo 2 #:bar 3) '(#:bar 6))))
|
||||
|
||||
(test-equal "substitute-keyword-arguments"
|
||||
'((#:foo 3)
|
||||
(#:foo 3)
|
||||
(#:foo 3 #:bar (1 2))
|
||||
(#:bar (1 2) #:foo 3)
|
||||
(#:foo 3))
|
||||
(list (substitute-keyword-arguments '(#:foo 2)
|
||||
((#:foo f) (1+ f)))
|
||||
(substitute-keyword-arguments '()
|
||||
((#:foo f 2) (1+ f)))
|
||||
(substitute-keyword-arguments '(#:foo 2 #:bar (2))
|
||||
((#:foo f) (1+ f))
|
||||
((#:bar b) (cons 1 b)))
|
||||
(substitute-keyword-arguments '(#:foo 2)
|
||||
((#:foo _) 3)
|
||||
((#:bar b '(2)) (cons 1 b)))
|
||||
(substitute-keyword-arguments '(#:foo 2)
|
||||
((#:foo f 1) (1+ f))
|
||||
((#:bar b) (cons 42 b)))))
|
||||
|
||||
(test-assert "filtered-port, file"
|
||||
(let* ((file (search-path %load-path "guix.scm"))
|
||||
(input (open-file file "r0b")))
|
||||
|
||||
Reference in New Issue
Block a user