Permalink
Browse files

found bug where we were ignoring manually given closure keys...fixed …

…and added corresponding unit test
  • Loading branch information...
1 parent 599d5bb commit 9559b2d696afb934aa7c2d69818a72259777ed25 @vegashacker committed May 13, 2009
Showing with 15 additions and 2 deletions.
  1. +2 −2 closures.scm
  2. +13 −0 unit-test.ss
View
@@ -20,8 +20,8 @@
((_ (req-identifier) body ...)
(let ((key (make-closure-key)))
(body-as-closure-key (req-identifier key) body ...)))
- ((_ (req-identifier key-identifier) body ...)
- (let ((key-identifier (make-closure-key)))
+ ((_ (req-identifier key-expr) body ...)
+ (let ((key-identifier key-expr))
(add-closure! #:key key-identifier
(lambda (req-identifier)
;; first cleanup after itself
View
@@ -25,6 +25,19 @@
(test-equal? "closures are usable only once"
(num-closures-in-memory)
0)
+
+ ;; now test manual closure keys
+ (test-equal? "just made a manual key'd closure"
+ (begin (set! clos-key "some-key-i-made-up")
+ (body-as-closure-key (req clos-key) "cool")
+ (num-closures-in-memory))
+ 1)
+ (test-equal? "call the manual closure"
+ (call-closure clos-key 'dummy-req)
+ "cool")
+ (test-equal? "make sure manual closures clean up too"
+ (num-closures-in-memory)
+ 0)
)))

0 comments on commit 9559b2d

Please sign in to comment.