Skip to content
Browse files

Testing with c.contracts v0.0.2-SNAP

  • Loading branch information...
1 parent f33a33e commit 4d77ca4492561854c9bf991425470e9b3b9d41e9 @fogus committed
Showing with 14 additions and 5 deletions.
  1. +1 −1 project.clj
  2. +11 −3 src/trammel/core.clj
  3. +2 −1 test/fogus/me/invariant_tests.clj
View
2 project.clj
@@ -1,7 +1,7 @@
(defproject trammel "0.8.0-SNAPSHOT"
:description "A library providing contracts programming for Clojure."
:dependencies [[org.clojure/clojure "1.4.0"]
- [org.clojure/core.contracts "0.0.1"]]
+ [org.clojure/core.contracts "0.0.2-SNAPSHOT"]]
:dev-dependencies [[lein-clojars "0.8.0"]
[jline "0.9.94"]
[swank-clojure "1.4.2"]
View
14 src/trammel/core.clj
@@ -74,7 +74,6 @@
`(defconstrainedfn ~fn-name
[~@field-args ~@(if (seq over) '[& overage] [])]
~invariants
- (println (str "build-a " '~field-args))
(with-meta
~(if (seq over)
`(if (= (count ~'overage) ~over-count)
@@ -94,7 +93,6 @@
(macroexpand '(trammel.core/defconstrainedfn ->HasF [g]
[(number? g)]
- (println (str "build-a " (quote (g))))
(with-meta (new HasF g)
{:contract (clojure.core.contracts/contract chk-HasF
"Has a field called f"
@@ -112,6 +110,15 @@
[(number? g)])
(->HasG 1)
+
+ (def ass (:original (meta assoc)))
+ (ass (->HasG 1) :g 2)
+
+ (assoc (->HasG 1) :g 2)
+
+ (meta assoc)
+
+
)
(defmacro defconstrainedrecord
@@ -151,7 +158,8 @@
(if-let [contract (and m (-> m meta :contract))]
((partial contract identity) (apply f m args))
(apply f m args)))
- {:hooked true})))
+ {:hooked true
+ :original f})))
(when *assert*
(alter-var-root (var assoc) apply-contract)
View
3 test/fogus/me/invariant_tests.clj
@@ -30,7 +30,8 @@
[(number? g)])
(deftest test-record-with-field-f
- (is (= 1 (:g (->HasG 1)))))
+ (is (= 1 (:g (->HasG 1))))
+ (is (= 42 (:g (assoc (->HasG 1) :g 42)))))
(deftest test-constrained-record-with-vector-spec
(is (= (:a (->AllNumbersRecord 42 108)) 42))

0 comments on commit 4d77ca4

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