Browse files

Test that the record expr is only eval'd once

  • Loading branch information...
1 parent 3e5a645 commit a9cd7d995a47b961124893108546fac507b1e56c @amalloy amalloy committed Nov 2, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 test/useful/datatypes_test.clj
View
8 test/useful/datatypes_test.clj
@@ -16,4 +16,10 @@
r (Test. 1 2 3 m {})]
(is (= m (meta (assoc-record r :b 10))))))
(testing "Inline typehinting"
- (is (= second (assoc-record ^Test (assoc init :b 5) :c 4))))))
+ (is (= second (assoc-record ^Test (assoc init :b 5) :c 4))))
+
+ (testing "Don't eval more than once"
+ (let [times-evaled (atom 0)
+ r (Test. 1 2 3)]
+ (assoc-record ^Test (do (swap! times-evaled inc) r) :a :x :b :y :c :z)
+ (is (= 1 @times-evaled))))))

0 comments on commit a9cd7d9

Please sign in to comment.