18 |
;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
19 |
;;;; Boston, MA 02111-1307 USA |
;;;; Boston, MA 02111-1307 USA |
20 |
|
|
21 |
(use-modules (test-suite lib)) |
(define-module (test-suite test-dynamic-scope) |
22 |
|
:use-module (test-suite lib)) |
23 |
|
|
24 |
|
|
25 |
|
(define exception:duplicate-binding |
26 |
|
(cons 'misc-error "^duplicate bindings")) |
27 |
|
(define exception:bad-binding |
28 |
|
(cons 'misc-error "^bad bindings")) |
29 |
|
|
30 |
(define global-a 0) |
(define global-a 0) |
31 |
(define (fetch-global-a) global-a) |
(define (fetch-global-a) global-a) |
42 |
(= global-a 0))) |
(= global-a 0))) |
43 |
|
|
44 |
(pass-if-exception "duplicate @binds" |
(pass-if-exception "duplicate @binds" |
45 |
(cons 'misc-error "^duplicate bindings") |
exception:duplicate-binding |
46 |
(@bind ((a 1) (a 2)) (+ a a))) |
(eval '(@bind ((a 1) (a 2)) (+ a a)) |
47 |
|
(interaction-environment))) |
48 |
|
|
49 |
(pass-if-exception "@bind missing expression" |
(pass-if-exception "@bind missing expression" |
50 |
(cons 'misc-error "^missing or extra expression") |
exception:missing-expression |
51 |
(@bind ((global-a 1)))) |
(eval '(@bind ((global-a 1))) |
52 |
|
(interaction-environment))) |
53 |
|
|
54 |
(pass-if-exception "@bind bad bindings" |
(pass-if-exception "@bind bad bindings" |
55 |
(cons 'misc-error "^bad bindings") |
exception:bad-binding |
56 |
(@bind (a) #f)) |
(eval '(@bind (a) #f) |
57 |
|
(interaction-environment))) |
58 |
|
|
59 |
(pass-if-exception "@bind bad bindings" |
(pass-if-exception "@bind bad bindings" |
60 |
(cons 'misc-error "^bad bindings") |
exception:bad-binding |
61 |
(@bind ((a)) #f)) |
(eval '(@bind ((a)) #f) |
62 |
|
(interaction-environment))) |
63 |
|
|
64 |
(pass-if "@bind and dynamic-wind" |
(pass-if "@bind and dynamic-wind" |
65 |
(letrec ((co-routine #f) |
(letrec ((co-routine #f) |