Read complex numbers where both parts are inexact decimals
[bpt/guile.git] / test-suite / tests / optargs.test
1 ;;;; optargs.test --- test suite for optional arg processing -*- scheme -*-
2 ;;;; Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> --- June 2001
3 ;;;;
4 ;;;; Copyright (C) 2001, 2006 Free Software Foundation, Inc.
5 ;;;;
6 ;;;; This library is free software; you can redistribute it and/or
7 ;;;; modify it under the terms of the GNU Lesser General Public
8 ;;;; License as published by the Free Software Foundation; either
9 ;;;; version 3 of the License, or (at your option) any later version.
10 ;;;;
11 ;;;; This library is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;;;; Lesser General Public License for more details.
15 ;;;;
16 ;;;; You should have received a copy of the GNU Lesser General Public
17 ;;;; License along with this library; if not, write to the Free Software
18 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 (define-module (test-suite test-optargs)
21 :use-module (test-suite lib)
22 :use-module (ice-9 optargs))
23
24 (with-test-prefix "optional argument processing"
25 (pass-if "local defines work with optional arguments"
26 (eval '(begin
27 (define* (test-1 #:optional (x 0))
28 (define d 1) ; local define
29 #t)
30 (false-if-exception (test-1)))
31 (interaction-environment))))
32
33 ;;;
34 ;;; let-keywords
35 ;;;
36
37 (with-test-prefix "let-keywords"
38
39 ;; in guile 1.6.4 and earlier, an empty binding list only used `begin',
40 ;; which caused apparently internal defines to "leak" out into the
41 ;; encompasing environment
42 (pass-if-exception "empty bindings internal defines leaking out"
43 exception:unbound-var
44 (let ((rest '()))
45 (let-keywords rest #f ()
46 (define localvar #f)
47 #f)
48 localvar))
49
50 (pass-if "one key"
51 (let-keywords '(#:foo 123) #f (foo)
52 (= foo 123))))
53
54 ;;;
55 ;;; let-keywords*
56 ;;;
57
58 (with-test-prefix "let-keywords*"
59
60 ;; in guile 1.6.4 and earlier, an empty binding list only used `begin',
61 ;; which caused apparently internal defines to "leak" out into the
62 ;; encompasing environment
63 (pass-if-exception "empty bindings internal defines leaking out"
64 exception:unbound-var
65 (let ((rest '()))
66 (let-keywords* rest #f ()
67 (define localvar #f)
68 #f)
69 localvar))
70
71 (pass-if "one key"
72 (let-keywords* '(#:foo 123) #f (foo)
73 (= foo 123))))
74
75 ;;;
76 ;;; let-optional
77 ;;;
78
79 (with-test-prefix "let-optional"
80
81 ;; in guile 1.6.4 and earlier, an empty binding list only used `begin',
82 ;; which caused apparently internal defines to "leak" out into the
83 ;; encompasing environment
84 (pass-if-exception "empty bindings internal defines leaking out"
85 exception:unbound-var
86 (let ((rest '()))
87 (let-optional rest ()
88 (define localvar #f)
89 #f)
90 localvar))
91
92 (pass-if "one var"
93 (let ((rest '(123)))
94 (let-optional rest ((foo 999))
95 (= foo 123)))))
96
97 ;;;
98 ;;; let-optional*
99 ;;;
100
101 (with-test-prefix "let-optional*"
102
103 ;; in guile 1.6.4 and earlier, an empty binding list only used `begin',
104 ;; which caused apparently internal defines to "leak" out into the
105 ;; encompasing environment
106 (pass-if-exception "empty bindings internal defines leaking out"
107 exception:unbound-var
108 (let ((rest '()))
109 (let-optional* rest ()
110 (define localvar #f)
111 #f)
112 localvar))
113
114 (pass-if "one var"
115 (let ((rest '(123)))
116 (let-optional* rest ((foo 999))
117 (= foo 123)))))