diff options
author | Ludovic Courtès <ludo@gnu.org> | 2009-11-14 16:52:48 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2009-11-14 16:59:25 +0100 |
commit | ee2a69f565032c6699ce6291e48b8624b2da16ba (patch) | |
tree | b5cbb4876f6abf6f1527784f23a6d521ff50b06f | |
parent | 0ee42e27d51cd5af716aa43699a27343738d1ec6 (diff) | |
download | guile-ee2a69f565032c6699ce6291e48b8624b2da16ba.tar.gz |
Add currently failing tests for optargs.
* test-suite/tests/optargs.test (exception:unrecognized-keyword,
exception:extraneous-arguments): New variables.
("define*")["extraneous arguments", "unrecognized keyword", "rest
given before keywords"]: New tests.
-rw-r--r-- | test-suite/tests/optargs.test | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/test-suite/tests/optargs.test b/test-suite/tests/optargs.test index f8459ba0e..05b67e591 100644 --- a/test-suite/tests/optargs.test +++ b/test-suite/tests/optargs.test @@ -22,6 +22,20 @@ #:use-module (system base compile) #:use-module (ice-9 optargs)) +(define exception:unrecognized-keyword + ;; Can be `vm-error' or `misc-error' depending on whether we use the + ;; interpreter or VM: + ;; (vm-error vm-run "Bad keyword argument list: unrecognized keyword" ()) + ;; (misc-error #f "~A ~S" ("unrecognized keyword" (#:y 2)) #f) + (cons #t ".*")) + +(define exception:extraneous-arguments + ;; Can be `vm-error' or `misc-error' depending on whether we use the + ;; interpreter or VM, and depending on the evenness of the number of extra + ;; arguments (!). + (cons #t ".*")) + + (define-syntax c&e (syntax-rules (pass-if pass-if-exception) ((_ (pass-if test-name exp)) @@ -146,4 +160,21 @@ (with-test-prefix/c&e "define*" (pass-if "the whole enchilada" (equal? (foo 1 2) - '(1 2 #f 1 #f #f #f 1 () ())))) + '(1 2 #f 1 #f #f #f 1 () ()))) + + (pass-if-exception "extraneous arguments" + exception:extraneous-arguments + (let ((f (lambda* (#:key x) x))) + (f 1 2 #:x 'x))) + + (pass-if-exception "unrecognized keyword" + exception:unrecognized-keyword + (let ((f (lambda* (#:key x) x))) + (f #:y 'not-recognized))) + + (pass-if "rest given before keywords" + ;; Passing the rest argument before the keyword arguments should not + ;; prevent keyword argument binding. + (let ((f (lambda* (#:key x y z #:rest r) (list x y z r)))) + (equal? (f 1 2 3 #:x 'x #:z 'z) + '(x #f z (1 2 3 #:x x #:z z)))))) |