Skip to content
Browse files

Added regression for #18

  • Loading branch information...
1 parent 4d77ca4 commit 9ac252a050d2144aea05f662212b5d5164c02637 @fogus committed
Showing with 11 additions and 3 deletions.
  1. +0 −1 src/trammel/core.clj
  2. +11 −2 test/fogus/me/invariant_tests.clj
View
1 src/trammel/core.clj
@@ -143,7 +143,6 @@
(defconstrainedfn ~map-arrow-factory-name
([{:keys ~fields :as m#}]
~invariants
- (println (str "building " m#))
(with-meta
(merge (new ~name ~@(for [e fields] nil)) m#)
{:contract ~chk})))
View
13 test/fogus/me/invariant_tests.clj
@@ -13,7 +13,7 @@
(ns fogus.me.invariant-tests
(:use [trammel.core :only [defconstrainedrecord defconstrainedtype]])
- (:use [clojure.test :only [deftest is]]))
+ (:use [clojure.test :only [deftest is testing]]))
(defconstrainedrecord AllNumbersRecord [a b]
"AllNumbersRecord record fields are expected to hold only numbers."
@@ -29,10 +29,19 @@
"Has a field called g"
[(number? g)])
-(deftest test-record-with-field-f
+(deftest test-record-with-field-g
(is (= 1 (:g (->HasG 1))))
(is (= 42 (:g (assoc (->HasG 1) :g 42)))))
+(defconstrainedrecord HasF [f]
+ "Has a field called f"
+ [(number? f)])
+
+(deftest test-record-with-field-f
+ (testing "regression for https://github.com/fogus/trammel/issues/18"
+ (is (= 1 (:f (->HasF 1))))
+ (is (= 42 (:f (assoc (->HasF 1) :f 42))))))
+
(deftest test-constrained-record-with-vector-spec
(is (= (:a (->AllNumbersRecord 42 108)) 42))
(is (= (:b (->AllNumbersRecord 42 108)) 108))

0 comments on commit 9ac252a

Please sign in to comment.
Something went wrong with that request. Please try again.