diff options
| author | Eric Bavier <bavier@member.fsf.org> | 2016-09-20 15:41:31 -0500 |
|---|---|---|
| committer | Eric Bavier <bavier@member.fsf.org> | 2016-10-07 07:42:05 -0500 |
| commit | b8b129ebd8d017c957094f3d977a1c452d7d450f (patch) | |
| tree | 5fa5860e6e7725c1cffae5da6b282ef82bb09e07 /tests | |
| parent | 347df60158a11abbc9b84ac36cd113362d7e09e0 (diff) | |
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.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/utils.scm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm index 960928c842f..bcfaa14faac 100644 --- a/tests/utils.scm +++ b/tests/utils.scm | |||
| @@ -123,6 +123,26 @@ | |||
| 123 | (default-keyword-arguments '(#:bar 3) '(#:foo 2)) | 123 | (default-keyword-arguments '(#:bar 3) '(#:foo 2)) |
| 124 | (default-keyword-arguments '(#:foo 2 #:bar 3) '(#:bar 6)))) | 124 | (default-keyword-arguments '(#:foo 2 #:bar 3) '(#:bar 6)))) |
| 125 | 125 | ||
| 126 | (test-equal "substitute-keyword-arguments" | ||
| 127 | '((#:foo 3) | ||
| 128 | (#:foo 3) | ||
| 129 | (#:foo 3 #:bar (1 2)) | ||
| 130 | (#:bar (1 2) #:foo 3) | ||
| 131 | (#:foo 3)) | ||
| 132 | (list (substitute-keyword-arguments '(#:foo 2) | ||
| 133 | ((#:foo f) (1+ f))) | ||
| 134 | (substitute-keyword-arguments '() | ||
| 135 | ((#:foo f 2) (1+ f))) | ||
| 136 | (substitute-keyword-arguments '(#:foo 2 #:bar (2)) | ||
| 137 | ((#:foo f) (1+ f)) | ||
| 138 | ((#:bar b) (cons 1 b))) | ||
| 139 | (substitute-keyword-arguments '(#:foo 2) | ||
| 140 | ((#:foo _) 3) | ||
| 141 | ((#:bar b '(2)) (cons 1 b))) | ||
| 142 | (substitute-keyword-arguments '(#:foo 2) | ||
| 143 | ((#:foo f 1) (1+ f)) | ||
| 144 | ((#:bar b) (cons 42 b))))) | ||
| 145 | |||
| 126 | (test-assert "filtered-port, file" | 146 | (test-assert "filtered-port, file" |
| 127 | (let* ((file (search-path %load-path "guix.scm")) | 147 | (let* ((file (search-path %load-path "guix.scm")) |
| 128 | (input (open-file file "r0b"))) | 148 | (input (open-file file "r0b"))) |
