Permalink
Browse files

Fix nested ->/do

  • Loading branch information...
1 parent fbef25d commit a315f861e04fd33ba5398adf6b5e75579d18ce4c @Chouser Chouser committed Dec 20, 2013
Showing with 15 additions and 3 deletions.
  1. +2 −1 src/lonocloud/synthread.clj
  2. +5 −2 src/lonocloud/synthread/impl.clj
  3. +8 −0 test/lonocloud/synthread/test.clj
@@ -11,9 +11,10 @@
additional constraint that x is marked and checked after each form
in body to confirm that the mark remains."
[x & body]
- (let [val (rand-int Integer/MAX_VALUE)
+ (let [val (gensym "tag-")
do-asserts (gensym "do-asserts-")]
`(let [x# ~x
+ ~val (impl/new-mark x#)
~do-asserts (impl/iobj? x#)]
(-> x#
(impl/mark ~val)
@@ -3,6 +3,9 @@
(defn iobj? [x]
(instance? clojure.lang.IObj x))
+(defn new-mark [x]
+ (or (-> x meta ::mark) (Object.)))
+
(defn assert-mark [x val do-asserts file form-num line do-line]
(when (and do-asserts (not= val (-> x meta ::mark)))
(let [msg (str "Threaded topic was lost on form " (inc form-num)
@@ -16,7 +19,7 @@
(defn mark [x val]
(if (iobj? x)
- (with-meta x {::mark val})
+ (vary-meta x assoc ::mark val)
x))
(defn ^:private map->record [^String typename, data-map]
@@ -114,4 +117,4 @@
(map->record (.getName (class o)) (into {} n))
(meta o)))}))
- )
+ )
@@ -91,6 +91,14 @@
inc
(->is = 21)))
+(deftest test-do-nested
+ (->/do [1 2 3]
+ (conj 4)
+ (->/do
+ (conj 5))
+ (conj 6)
+ (->is = [1 2 3 4 5 6])))
+
(deftest test-first
(->/do (range 4)
(->/first

0 comments on commit a315f86

Please sign in to comment.