From dd64bb8e1815f99d56b2b890b1713ebc2bc36588 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Sat, 25 Sep 2004 22:19:39 +0000 Subject: [PATCH] (let-keywords, let-keywords*, let-optional, let-optional*): Add tests of internal defines when no bindings. --- test-suite/tests/optargs.test | 91 ++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/test-suite/tests/optargs.test b/test-suite/tests/optargs.test index 4f356b020..9c0a5dd45 100644 --- a/test-suite/tests/optargs.test +++ b/test-suite/tests/optargs.test @@ -18,8 +18,9 @@ ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;;; Boston, MA 02111-1307 USA -(use-modules (test-suite lib) - (ice-9 optargs)) +(define-module (test-suite test-optargs) + :use-module (test-suite lib) + :use-module (ice-9 optargs)) (with-test-prefix "optional argument processing" (define* (test-1 #:optional (x 0)) @@ -27,3 +28,89 @@ #t) (pass-if "local defines work with optional arguments" (false-if-exception (test-1)))) + +;;; +;;; let-keywords +;;; + +(with-test-prefix "let-keywords" + + ;; in guile 1.6.4 and earlier, an empty binding list only used `begin', + ;; which caused apparently internal defines to "leak" out into the + ;; encompasing environment + (pass-if-exception "empty bindings internal defines leaking out" + exception:unbound-var + (let ((rest '())) + (let-keywords rest #f () + (define localvar #f) + #f) + localvar)) + + (pass-if "one key" + (let-keywords '(#:foo 123) #f (foo) + (= foo 123)))) + +;;; +;;; let-keywords* +;;; + +(with-test-prefix "let-keywords*" + + ;; in guile 1.6.4 and earlier, an empty binding list only used `begin', + ;; which caused apparently internal defines to "leak" out into the + ;; encompasing environment + (pass-if-exception "empty bindings internal defines leaking out" + exception:unbound-var + (let ((rest '())) + (let-keywords* rest #f () + (define localvar #f) + #f) + localvar)) + + (pass-if "one key" + (let-keywords* '(#:foo 123) #f (foo) + (= foo 123)))) + +;;; +;;; let-optional +;;; + +(with-test-prefix "let-optional" + + ;; in guile 1.6.4 and earlier, an empty binding list only used `begin', + ;; which caused apparently internal defines to "leak" out into the + ;; encompasing environment + (pass-if-exception "empty bindings internal defines leaking out" + exception:unbound-var + (let ((rest '())) + (let-optional rest () + (define localvar #f) + #f) + localvar)) + + (pass-if "one var" + (let ((rest '(123))) + (let-optional rest ((foo 999)) + (= foo 123))))) + +;;; +;;; let-optional* +;;; + +(with-test-prefix "let-optional*" + + ;; in guile 1.6.4 and earlier, an empty binding list only used `begin', + ;; which caused apparently internal defines to "leak" out into the + ;; encompasing environment + (pass-if-exception "empty bindings internal defines leaking out" + exception:unbound-var + (let ((rest '())) + (let-optional* rest () + (define localvar #f) + #f) + localvar)) + + (pass-if "one var" + (let ((rest '(123))) + (let-optional* rest ((foo 999)) + (= foo 123)))))