Skip to content

Commit

Permalink
Fix non passing cljs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeoffrey committed Jun 30, 2022
1 parent bf6acad commit 060a8f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
:modules {:main {:entries [user]}}}
:test {:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "^hyperfiddle.(photon-[^dom]|core-async).*$"
:ns-regexp "^hyperfiddle.(photon-[^dom]|core-async|zero).*$"
:build-options {:cache-level :off}
:modules {:main {:entries [hyperfiddle.photon hyperfiddle.photon-test #_hyperfiddle.missionary-test hyperfiddle.core-async-test]}}
:modules {:main {:entries [hyperfiddle.zero hyperfiddle.photon hyperfiddle.photon-test #_hyperfiddle.missionary-test hyperfiddle.core-async-test]}}
:dev {:closure-defines {hyperfiddle.logger/LEVEL "debug"}}
:compiler-options {:warnings {:redef-in-file false}}}
:browser-test {:target :karma
:output-to "out/karma-tests.js"
:ns-regexp "^hyperfiddle.(photon-[^dom]|core-async).*$"
:ns-regexp "^hyperfiddle.(photon-[^dom]|core-async|zero).*$"
:build-options {:cache-level :off}
:modules {:main {:entries [hyperfiddle.photon hyperfiddle.photon-test #_hyperfiddle.missionary-test hyperfiddle.core-async-test]}}
:modules {:main {:entries [hyperfiddle.zero hyperfiddle.photon hyperfiddle.photon-test #_hyperfiddle.missionary-test hyperfiddle.core-async-test]}}
:dev {:closure-defines {hyperfiddle.logger/LEVEL "debug"}}
:compiler-options {:warnings {:redef-in-file false}}}}}
11 changes: 6 additions & 5 deletions src/hyperfiddle/photon_ui.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
(tests
(def !event (atom nil))
(def !input (atom 0))
(with (p/run (semicontroller :switch/set (new (m/watch !input))
(p/fn [input]
(! input)
(p/watch !event))))
(let [dispose (p/run (semicontroller :switch/set (new (m/watch !input))
(p/fn [input]
(! input)
(p/watch !event))))]
% := 0
(swap! !input inc)
% := 1
Expand All @@ -166,7 +166,8 @@
(rcf/set-timeout! 1200) ;; rcf issue, extend timeout
(reset! !event {:switch/set true})
(swap! !input inc)
% := 3))
% := 3
(dispose)))

(defmacro merge-events [& events]
`(->> (p/fn [] (apply merge ~@events))
Expand Down
9 changes: 6 additions & 3 deletions src/hyperfiddle/zero.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,20 @@ return nothing (you return nil) but in flows nothing is different than nil." [t]

(tests
"logical clock"
(with (p/run (! clock)) [% % %] := [::tick ::tick ::tick]))
(let [dispose (p/run (! clock))]
[% % %] := [::tick ::tick ::tick]
(dispose)))

(defn system-time-ms [_] #?(:clj (System/currentTimeMillis) :cljs (js/Date.now)))

(p/def time #_"ms since Jan 1 1970" (new (m/latest system-time-ms <clock)))

(tests
"millisecond time as a stable test"
(with (p/run (! time))
(let [dispose (p/run (! time))]
[% % %] := [_ _ _]
(map int? *1) := [true true true]))
(map int? *1) := [true true true]
(dispose)))

(comment
; This ticker will skew and therefore is not useful other than as an example
Expand Down

0 comments on commit 060a8f6

Please sign in to comment.