                    [reagent.ratom :refer [run! reaction]]
                    [reagent.debug :refer [dbg]])
   (:require [cemerick.cljs.test :as t]
-            [reagent.ratom :as rv]))
+            [reagent.ratom :as rv]
+            [reagent.core :as r]))
 
 ;; this repeats all the atom tests but using cursors instead
 

      (is (= @res (+ 2 @a)))
      (is (= @b-changed 1))
      (is (= @c-changed 0))
             
      (reset! a -1)
      (is (= @res (+ 2 @a)))
      (is (= @b-changed 2))
      (is (= @c-changed 0))
      (is (= @a-base {:test {:unsubscribe -1 :value 42}}))
             
      (reset! a 2)
      (is (= @res (+ 10 @a)))
      (is (<= 2 @b-changed 3))
      (is (= @c-changed 1))
      (is (= @a-base {:test {:unsubscribe 2 :value 42}}))
             
      (reset! a 3)
      (is (= @res (+ 10 @a)))
      (is (<= 2 @b-changed 3))
      (is (= @c-changed 2))
      (is (= @a-base {:test {:unsubscribe 3 :value 42}}))
             
      (reset! a 3)
      (is (= @res (+ 10 @a)))
      (is (<= 2 @b-changed 3))
      (is (= @c-changed 2))
      (is (= @a-base {:test {:unsubscribe 3 :value 42}}))
             
      (reset! a -1)
      (is (= @res (+ 2 @a)))
      (is (= @a-base {:test {:unsubscribe -1 :value 42}}))

    (let [!x-base (rv/atom {:a {:b 0 :c {:d 0}}})
          !x (rv/cursor [:a :c :d] !x-base)
          !co (rv/make-reaction #(inc @!x) :auto-run true)]
      (is (= 1 @!co) "CO has correct value on first deref")
      (swap! !x inc)
      (is (= 2 @!co) "CO auto-updates")
      (is (= {:a {:b 0 :c {:d 1}}} @!x-base))
      (dispose !co))
