diff options
| author | Cosmin Stejerean <cosmin@offbytwo.com> | 2010-10-25 14:54:56 -0400 |
|---|---|---|
| committer | Cosmin Stejerean <cosmin@offbytwo.com> | 2010-10-25 14:54:56 -0400 |
| commit | d9822fc889b77d5cabd29319765fd3a3260c61ac (patch) | |
| tree | 052d632dd166fc68a94160bfd16216b5da70f604 /test | |
| parent | d81122371248ee9042a2c6f0dc204208e018c986 (diff) | |
#465 make with-local-vars dynamic
Diffstat (limited to 'test')
| -rw-r--r-- | test/clojure/test_clojure/vars.clj | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/clojure/test_clojure/vars.clj b/test/clojure/test_clojure/vars.clj index 5b25321c..c377236a 100644 --- a/test/clojure/test_clojure/vars.clj +++ b/test/clojure/test_clojure/vars.clj @@ -25,10 +25,18 @@ (eval `(binding [a 4] a)) 4 ; regression in Clojure SVN r1370 )) -; with-local-vars var-get var-set alter-var-root [var? (predicates.clj)] +; var-get var-set alter-var-root [var? (predicates.clj)] ; with-in-str with-out-str ; with-open -; with-precision + +(deftest test-with-local-vars + (let [factorial (fn [x] + (with-local-vars [acc 1, cnt x] + (while (> @cnt 0) + (var-set acc (* @acc @cnt)) + (var-set cnt (dec @cnt))) + @acc))] + (is (= (factorial 5) 120)))) (deftest test-with-precision (are [x y] (= x y) |
