Permalink
Browse files

Added in-place fn test of contract application

  • Loading branch information...
fogus committed Jan 15, 2013
1 parent eb49584 commit 514d50775ce6ca66d8d649c3a22dee6582c6cc6b
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/test/clojure/clojure/core/contracts_tests.clj
@@ -39,5 +39,24 @@
(is (= 10 ((partial doubler-contract-full-and-isolated-fn #(* 2 %)) 5)))
(is (thrown? Error ((partial doubler-contract-full-and-isolated-fn #(* 3 (+ %1 %2))) 2 3)))))
+(deftest test-contract-arity1
+ (let [doubler-contract-arity1
+ (contract doubler
+ "Test"
+ [x] [(pos? x) => (= (* 2 x) %)])]
+
+ (is (= 10 ((partial doubler-contract-arity1 #(* 2 %)) 5)))
+ (is (= 10 ((partial doubler-contract-arity1 #(* 2 %)) 5)))
+ (is (thrown? Error ((partial doubler-contract-arity1 #(* 3 %)) 5)))
+ (is (thrown? Error ((partial doubler-contract-arity1 #(* 2 %)) -5)))))
+
+(deftest contract-arity1-and-isolated-fn
+ (let [doubler-contract-arity1-and-isolated-fn
+ (contract doubler
+ "Test"
+ [x] [pos? => (= (* 2 x) %)])]
+
+ ))
+
(deftest test-regressions
(defer "regression testing"))

0 comments on commit 514d507

Please sign in to comment.