Permalink
Browse files

Making Clojure 1.2 compatible.

  • Loading branch information...
1 parent d9ac94e commit 7dd529b1613a22c139af45e927e8a0faf8c8c371 @fogus committed Apr 6, 2012
Showing with 15 additions and 15 deletions.
  1. +4 −2 project.clj
  2. +5 −6 src/trammel/core.clj
  3. +6 −7 test/fogus/me/invariant_tests.clj
View
6 project.clj
@@ -8,7 +8,9 @@
[lein-marginalia "0.7.0"]
[lein-multi "1.1.0"]]
:multi-deps {:all [[thneed "1.0.0-SNAPSHOT"]]
- "1.3" [[org.clojure/clojure "1.3.0"]]
- "1.4" [[org.clojure/clojure "1.4.0-beta1"]]})
+ "1.2" [[org.clojure/clojure "1.2.0"]]
+ "1.2.1" [[org.clojure/clojure "1.2.1"]]
+ "1.3" [[org.clojure/clojure "1.3.0"]]
+ "1.4" [[org.clojure/clojure "1.4.0-beta1"]]})
;; lein multi test
View
11 src/trammel/core.clj
@@ -245,12 +245,12 @@
(with-meta
~(if (seq over)
`(if (= (count ~'overage) ~over-count)
- (new ~classname
+ (new ~nom
~@field-args
~@(for [i (range 0 (count over))]
(list `nth 'overage i)))
(throw (clojure.lang.ArityException. (+ ~arg-count (count ~'overage)) (name '~fn-name))))
- `(new ~classname ~@field-args))
+ `(new ~nom ~@field-args))
{:contract ~chk}))))
@@ -274,13 +274,12 @@
~(build-positional-factory name classname fields invariants chk)
(defconstrainedfn ~map-arrow-factory-name
- ([{:keys ~fields :as kwargs#}]
+ ([{:keys ~fields :as m#}]
~invariants
(with-meta
- (. ~classname ~'create kwargs#)
+ (merge (new ~name ~@(for [e fields] nil)) m#)
{:contract ~chk})))
-
- ~classname)))
+ ~name)))
(defn- apply-contract
[f]
View
13 test/fogus/me/invariant_tests.clj
@@ -12,7 +12,6 @@
;; remove this notice, or any other, from this software.
(ns fogus.me.invariant-tests
- (:import (clojure.lang ArityException))
(:use [trammel.core :only [defconstrainedrecord defconstrainedtype]])
(:use [clojure.test :only [deftest is]]))
@@ -29,8 +28,8 @@
(deftest test-constrained-record-with-vector-spec
(is (= (:a (->AllNumbersRecord 42 108)) 42))
(is (= (:b (->AllNumbersRecord 42 108)) 108))
- (is (thrown? ArityException (->AllNumbersRecord)))
- (is (thrown? ArityException (->AllNumbersRecord 12))))
+ (is (thrown? Exception (->AllNumbersRecord)))
+ (is (thrown? Exception (->AllNumbersRecord 12))))
(defconstrainedtype Bar [a b]
"Bar type fields are expected to hold only numbers."
@@ -39,8 +38,8 @@
(deftest test-constrained-type-with-vector-spec
(is (= (.a (->AllNumbersType 1 2)) 1))
(is (= (.b (->AllNumbersType 1 2)) 2))
- (is (thrown? ArityException (->AllNumbersType)))
- (is (thrown? ArityException (->AllNumbersType 1)))
+ (is (thrown? Exception (->AllNumbersType)))
+ (is (thrown? Exception (->AllNumbersType 1)))
(is (thrown? Error (->AllNumbersType :a :b))))
;; testing default clojure pre/post maps
@@ -54,8 +53,8 @@
(deftest test-constrained-record-with-map-spec
(is (= (:a (->Buzz 42 108)) 42))
(is (= (:b (->Buzz 42 108)) 108))
- (is (thrown? ArityException (->Buzz)))
- (is (thrown? ArityException (->Buzz 12))))
+ (is (thrown? Exception (->Buzz)))
+ (is (thrown? Exception (->Buzz 12))))
; map->* factory

0 comments on commit 7dd529b

Please sign in to comment.