diff options
Diffstat (limited to 'test-suite/tests/peval.test')
-rw-r--r-- | test-suite/tests/peval.test | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/test-suite/tests/peval.test b/test-suite/tests/peval.test index 2c1c609b8..7cc5a31ab 100644 --- a/test-suite/tests/peval.test +++ b/test-suite/tests/peval.test @@ -1,7 +1,7 @@ ;;;; tree-il.test --- test suite for compiling tree-il -*- scheme -*- ;;;; Andy Wingo <wingo@pobox.com> --- May 2009 ;;;; -;;;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. +;;;; Copyright (C) 2009-2014 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -410,6 +410,90 @@ (const 7)) (pass-if-peval + ;; Higher order with optional argument (default uses earlier argument). + ;; <http://bugs.gnu.org/17634> + ((lambda* (f x #:optional (y (+ 3 (car x)))) + (+ y (f (* (car x) (cadr x))))) + (lambda (x) + (+ x 1)) + '(2 3)) + (const 12)) + + (pass-if-peval + ;; Higher order with optional arguments + ;; (default uses earlier optional argument). + ((lambda* (f x #:optional (y (+ 3 (car x))) (z (+ (cadr x) y))) + (+ y z (f (* (car x) (cadr x))))) + (lambda (x) + (+ x 1)) + '(2 3)) + (const 20)) + + (pass-if-peval + ;; Higher order with optional arguments (one caller-supplied value, + ;; one default that uses earlier optional argument). + ((lambda* (f x #:optional (y (+ 3 (car x))) (z (+ (cadr x) y))) + (+ y z (f (* (car x) (cadr x))))) + (lambda (x) + (+ x 1)) + '(2 3) + -3) + (const 4)) + + (pass-if-peval + ;; Higher order with optional arguments (caller-supplied values). + ((lambda* (f x #:optional (y (+ 3 (car x))) (z (+ (cadr x) y))) + (+ y z (f (* (car x) (cadr x))))) + (lambda (x) + (+ x 1)) + '(2 3) + -3 + 17) + (const 21)) + + (pass-if-peval + ;; Higher order with optional and rest arguments (one + ;; caller-supplied value, one default that uses earlier optional + ;; argument). + ((lambda* (f x #:optional (y (+ 3 (car x))) (z (+ (cadr x) y)) + #:rest r) + (list r (+ y z (f (* (car x) (cadr x)))))) + (lambda (x) + (+ x 1)) + '(2 3) + -3) + (primcall list (const ()) (const 4))) + + (pass-if-peval + ;; Higher order with optional and rest arguments + ;; (caller-supplied values for optionals). + ((lambda* (f x #:optional (y (+ 3 (car x))) (z (+ (cadr x) y)) + #:rest r) + (list r (+ y z (f (* (car x) (cadr x)))))) + (lambda (x) + (+ x 1)) + '(2 3) + -3 + 17) + (primcall list (const ()) (const 21))) + + (pass-if-peval + ;; Higher order with optional and rest arguments + ;; (caller-supplied values for optionals and rest). + ((lambda* (f x #:optional (y (+ 3 (car x))) (z (+ (cadr x) y)) + #:rest r) + (list r (+ y z (f (* (car x) (cadr x)))))) + (lambda (x) + (+ x 1)) + '(2 3) + -3 + 17 + 8 + 3) + (let (r) (_) ((primcall list (const 8) (const 3))) + (primcall list (lexical r _) (const 21)))) + + (pass-if-peval ;; Higher order with optional argument (caller-supplied value). ((lambda* (f x #:optional (y 0)) (+ y (f (* (car x) (cadr x))))) |