Skip to content

Commit

Permalink
Upgrading to clj 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
fogus committed Jun 2, 2012
1 parent ed8e586 commit e8e2106
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(defproject evalive "1.1.0"
:description "Various eval functions and macros for Clojure"
:dependencies [[org.clojure/clojure "1.3.0"]]
:dependencies [[org.clojure/clojure "1.4.0"]]
:dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]
[jline "0.9.94"]
[swank-clojure "1.4.0"]
Expand Down
32 changes: 32 additions & 0 deletions test/evalive/test/gen.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(ns evalive.test.gen
(:use [evalive.core :only (lexical-context evil destro wtfn)] :reload-all)
(:use clojure.test.generative)
(:require [clojure.test.generative.generators :as gen]))

(defn integer
"Distribution of integers biased towards the small, but
including all longs."
[]
(gen/one-of #(gen/uniform -1 32) gen/byte gen/short gen/int gen/long))

(defn longable?
[n]
(try
(long n)
true
(catch Exception _)))

(defspec integer-commutative-laws
(partial map identity)
[^{:tag `integer} a ^{:tag `integer} b]
(if (longable? (+' a b))
(assert (= (+ a b) (+ b a)
(+' a b) (+' b a)
(unchecked-add a b) (unchecked-add b a)))
(assert (= (+' a b) (+' b a))))
(if (longable? (*' a b))
(assert (= (* a b) (* b a)
(*' a b) (*' b a)
(unchecked-multiply a b) (unchecked-multiply b a)))
(assert (= (*' a b) (*' b a)))))

0 comments on commit e8e2106

Please sign in to comment.