Skip to content

Commit

Permalink
runtime tests - conditional, amb
Browse files Browse the repository at this point in the history
  • Loading branch information
leonoel committed Jan 25, 2024
1 parent 63a6f49 commit 332d441
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/hyperfiddle/electric/impl/runtime_test.cljc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns hyperfiddle.electric.impl.runtime-test
(:require [missionary.core :as m]
[hyperfiddle.incseq :as i]
[hyperfiddle.electric-de :as e]
#?(:clj [hyperfiddle.electric.impl.lang-de2 :as l])
[hyperfiddle.electric.impl.runtime-de :as r]
Expand All @@ -24,11 +23,27 @@

(tests
(def !x (atom :foo))
(on-diff! rcf/tap (root-frame (::l/join (i/fixed (m/watch !x)))))
(on-diff! rcf/tap (root-frame (e/watch !x)))
% := {:degree 1, :permutation {}, :grow 1, :shrink 0, :change {0 :foo}, :freeze #{}}
(reset! !x :bar)
% := {:degree 1, :permutation {}, :grow 0, :shrink 0, :change {0 :bar}, :freeze #{}})

(tests
(def !x (atom false))
(on-diff! rcf/tap
(root-frame (if (e/watch !x) "foo" "bar")))
% := {:degree 1, :permutation {}, :grow 1, :shrink 0, :change {0 "bar"}, :freeze #{0}}
(swap! !x not)
% := {:degree 2, :permutation {0 1, 1 0}, :grow 1, :shrink 1, :change {0 "foo"}, :freeze #{0}})

(tests
(def !bar (atom :bar))
(on-diff! rcf/tap
(root-frame (e/amb :foo (e/watch !bar) :baz)))
% := {:degree 3, :permutation {}, :grow 3, :shrink 0, :change {0 :foo, 1 :bar, 2 :baz}, :freeze #{0 2}}
(reset! !bar :BAR)
% := {:degree 3, :permutation {}, :grow 0, :shrink 0, :change {1 :BAR}, :freeze #{}})

(tests
(def !n (atom 10))
(def !fizz (atom "Fizz"))
Expand Down

0 comments on commit 332d441

Please sign in to comment.