Permalink
Browse files

an attempt to get with working in 1.3

  • Loading branch information...
1 parent ae99b4c commit 5021e382e309ca031c9648757881e53ad855d26c @slagyr committed Oct 25, 2011
Showing with 73 additions and 32 deletions.
  1. +2 −1 TODO.md
  2. +43 −0 spec/bug.clj
  3. +2 −2 spec/speclj/core_spec.clj
  4. +14 −14 spec/speclj/running_spec.clj
  5. +12 −15 src/speclj/core.clj
View
3 TODO.md
@@ -1,8 +1,9 @@
# Features to add
+* support jav-opts in speclj task
* refactor reporters to composite pattern
* .spec config file: available to plugins
* exceptions during a spec run should not abort the rest of the examples ???
* should-contain that accepts strings/regex, maps, seq
* mocks
-* limelight runner
+* limelight runner
View
43 spec/bug.clj
@@ -0,0 +1,43 @@
+(ns bug)
+
+;(defmacro with []
+; (let [var-name (with-meta 'something {:dynamic true})]
+; `(do
+; (let [with-component# (atom 42)]
+; (declare ~var-name)
+; with-component#))))
+
+;(defmacro with []
+; (let [var-name (with-meta 'something {:dynamic true})]
+; `(do
+; (declare something)
+; (reset-meta! (resolve something) (assoc (meta (resolve something)) :dynamic true))
+; (let [with-component# (atom 42)]
+; with-component#))))
+;
+;(list
+; (def _with_ (with))
+; (def _example_ (fn [] @something))
+; )
+;
+;(with-bindings {#'something _with_}
+;; (prn (ns-publics *ns*)) ; {... something #'bug/something ...}
+;; (prn (ns-resolve *ns* 'something)) ; #'bug/something
+;; (prn @(ns-resolve *ns* 'something)) ; #<Atom@508aeb74: 42>
+;; (prn @@(ns-resolve *ns* 'something)) ; 42
+;; (prn @something) ; 42
+; (_example_)
+; )
+
+(list
+
+ (declare ^:dynamic p)
+; (defn q [] @p)
+ )
+
+;(describe "working"
+; (with foo "bar")
+; (it "works" (= "bar" @foo)))
+
+(binding [p (atom 10)]
+ @p)
View
4 spec/speclj/core_spec.clj
@@ -241,5 +241,5 @@
(it "tag :one :three :four" :filler))
)
-(run-specs :tags ["two"])
-;(run-specs)
+;(run-specs :tags ["two"])
+(run-specs :stacktrace true)
View
28 spec/speclj/running_spec.clj
@@ -13,18 +13,18 @@
(describe "Running"
(with runner (new-standard-runner))
(around [_]
- (println "#'runner: " (meta #'runner))
- (println "(deref #'runner): " (deref #'runner))
- (println "runner: " runner)
- (println "PUBLICS")
- (prn (ns-publics 'speclj.running-spec))
- (doseq [[key val] (ns-publics 'speclj.running-spec)]
- (println key (deref val)))
- (println *ns*)
- (println "runner: " runner)
- (println "(ns-resolve 'speclj.running-spec runner): " (ns-resolve 'speclj.running-spec 'runner))
- (println "deref (ns-resolve 'speclj.running-spec runner): " (deref (ns-resolve 'speclj.running-spec 'runner)))
- (println "@runner: " @runner)
+; (println "#'runner: " (meta #'runner))
+; (println "(deref #'runner): " (deref #'runner))
+; (println "runner: " runner)
+; (println "PUBLICS")
+; (prn (ns-publics 'speclj.running-spec))
+; (doseq [[key val] (ns-publics 'speclj.running-spec)]
+; (println key (deref val)))
+; (println *ns*)
+; (println "runner: " runner)
+; (println "(ns-resolve 'speclj.running-spec runner): " (ns-resolve 'speclj.running-spec 'runner))
+; (println "deref (ns-resolve 'speclj.running-spec runner): " (deref (ns-resolve 'speclj.running-spec 'runner)))
+; (println "@runner: " @runner)
(binding [*runner* @runner
*reporters* [(new-silent-reporter)]
*ns* (the-ns 'speclj.running-spec)]
@@ -42,9 +42,9 @@
(should= "has a pass" (.name (.characteristic result)))
(should-not (fail? result))))
-; (it "tracks one fail"
; (eval
-; '(describe "Dummy"
+ ; (it "tracks one fail"
+ ; '(describe "Dummy"
; (it "has a fail"
; (should= 1 2))))
; (run-and-report *runner* *reporters*)
View
27 src/speclj/core.clj
@@ -1,7 +1,7 @@
(ns speclj.core
(:use
[speclj.running :only (submit-description run-and-report)]
- [speclj.reporting :only (report-message)]
+ [speclj.reporting :only (report-message*)]
[speclj.tags :only (describe-filter)]
[speclj.config :only (active-reporters active-runner default-runner config-mappings default-config)]
[speclj.components]
@@ -18,8 +18,8 @@
Declares a new characteristic (example in rspec)."
[name & body]
(if (seq body)
- `(new-characteristic ~name (fn [] ~@body))
- `(new-characteristic ~name (fn [] (pending)))))
+ `(new-characteristic ~name (fn [] (eval '~(conj body `do))))
+ `(new-characteristic ~name '((pending)))))
(defmacro xit
"Syntactic shortcut to make the characteristic pending."
@@ -47,13 +47,13 @@
"Declares a function that is invoked before each characteristic in the containing describe scope is evaluated. The body
may consist of any forms, presumably ones that perform side effects."
[& body]
- `(new-before (fn [] ~@body)))
+ `(new-before (fn [] (eval '~(conj body `do)))))
(defmacro after
"Declares a function that is invoked after each characteristic in the containing describe scope is evaluated. The body
may consist of any forms, presumably ones that perform side effects."
[& body]
- `(new-after (fn [] ~@body)))
+ `(new-after (fn [] (eval '~(conj body `do)))))
(defmacro around
"Declares a function that will be invoked around each characteristic of the containing describe scope.
@@ -62,7 +62,7 @@
(around [it] (binding [*out* new-out] (it)))
"
[binding & body]
- `(new-around (fn ~binding ~@body)))
+ `(new-around (fn ~binding (eval '~(conj body `do)))))
(defmacro before-all
"Declares a function that is invoked once before any characteristic in the containing describe scope is evaluated. The
@@ -83,11 +83,9 @@
(with meaning 42)
(it \"knows the meaining life\" (should= @meaning (the-meaning-of :life)))"
[name & body]
- (let [var-name (with-meta (symbol name) {:dynamic true})]
- `(do
- (let [with-component# (new-with '~var-name (fn [] ~@body))]
- (declare ~var-name)
- with-component#))))
+ `(do
+ (declare ~(with-meta (symbol name) {:dynamic true}))
+ (new-with '~name (fn [] (apply eval '~body)))))
(defmacro with-all
"Declares a reference-able symbol that will be lazily evaluated once per context. The body may contain any forms,
@@ -97,9 +95,8 @@
(it \"knows the meaining life\" (should= @meaning (the-meaning-of :life)))"
[name & body]
`(do
- (let [with-all-component# (new-with-all '~name (fn [] ~@body))]
- (declare ~(symbol name))
- with-all-component#)))
+ (declare ~(with-meta (symbol name) {:dynamic true}))
+ (new-with-all '~name (fn [] (apply eval '~body)))))
(defn -to-s [thing]
(if (nil? thing) "nil" (str "<" (pr-str thing) ">")))
@@ -227,5 +224,5 @@ are evaluated by evaluation the file as a script. Optional configuration paramt
config (merge (dissoc default-config :runner) config)]
(with-bindings (config-mappings config)
(if-let [filter-msg (describe-filter)]
- (report-message (active-reporters) filter-msg))
+ (report-message* (active-reporters) filter-msg))
(run-and-report (active-runner) (active-reporters))))))

0 comments on commit 5021e38

Please sign in to comment.