(require-library locals simple-tests) (import locals simple-tests (only chicken condition-case)) (define-test (local?) (check (local ( (define-syntax xx (syntax-rules () ((_ x) (* x x)))) (define (yy y) 1 2 3 (+ y y)) (define zz 5) (define (uu u . us) #f) (define vv (lambda vs 10 20)) (define (ww . ws) #t) ) (aa (lambda (a) (+ zz (* 2 (xx a))))) ((bb b) 4 5 6 (* zz (* (xx b) (xx b)))) ; procedure (cc (* 2 zz)) ((dd) (or (uu 10 20 30) (ww))) ((ee e) (vv #t #f)) ) (= (aa 2) 13) (= (bb 2) 80) (= cc 10) (dd) (= (ee 100) 20) (not (condition-case (vv) ((exn) #f))) "counter" (local ( (define state 0) ) ((counter-ref) state) ((counter-add!) (set! state (+ state 1))) ((counter-reset!) (set! state 0)) ) (= (counter-ref) 0) (counter-add!) (counter-add!) (= (counter-ref) 2) (counter-reset!) (= (counter-ref) 0) )) (compound-test (LOCAL) (local?) )