Browse files

Upgrade to lein2 abnd new version of lexical-context

  • Loading branch information...
1 parent ec2f831 commit ae89f010b4abebe34c8b97129c5c55b27349c48a @fogus committed Sep 26, 2012
Showing with 14 additions and 38 deletions.
  1. +3 −5 project.clj
  2. +11 −1 src/evalive/core.clj
  3. +0 −32 test/evalive/test/gen.clj
View
8 project.clj
@@ -1,9 +1,7 @@
(defproject evalive "1.1.0"
:description "Various eval functions and macros for Clojure"
:dependencies [[org.clojure/clojure "1.5.0-alpha1"]]
- :dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]
- [jline "0.9.94"]
- [swank-clojure "1.4.0"]
- [lein-marginalia "0.8.0-SNAPSHOT"]
- [lein-generative "0.1.4.0-SNAPSHOT"]]
+ :plugins [[lein-swank "1.4.4"]
+ [lein-marginalia "0.8.0-SNAPSHOT"]
+ [lein-generative "0.1.4.0"]]
:generative-path "test/")
View
12 src/evalive/core.clj
@@ -33,7 +33,17 @@
;; # Public API
-(defmacro lexical-context
+(defmacro lexical-context []
+ (let [globals (remove (comp :macro meta val) (ns-publics *ns*))
+ syms (mapcat keys [globals, &env])
+ entries (for [sym syms]
+ [`(quote ~sym) sym])]
+ `(into {}
+ (for [[sym# value#] [~@entries]
+ :when (not (fn? value#))]
+ [sym# value#]))))
+
+(defmacro ^:private old-lexical-context
"When called, `lexical-context` returns a map of symbol -> value of the
current lexical bindings where the call occurred. For example:
View
32 test/evalive/test/gen.clj
@@ -1,32 +0,0 @@
-(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 ae89f01

Please sign in to comment.