Skip to content

Commit

Permalink
fix: iterator on empty trace
Browse files Browse the repository at this point in the history
  • Loading branch information
sritchie committed Oct 20, 2023
1 parent 4534e1c commit b6d5a7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/gen/dynamic/trace.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(:require-macros [gen.dynamic.trace]))
#?(:clj
(:import
(clojure.lang Associative IFn IObj IMapIterable Seqable))))
(clojure.lang Associative IFn IObj IMapIterable))))

(defn no-op
([gf args]
Expand Down Expand Up @@ -156,11 +156,9 @@
(valIterator [this]
(.iterator ^Iterable (vals (trace/choices this))))

java.lang.Iterable
Iterable
(iterator [this]
(.iterator
(let [^Seqable choice-map (trace/choices this)]
^Iterable (.seq choice-map))))]))
(.iterator ^Iterable (trace/choices this)))]))

(defn ^:no-doc = [^Trace this that]
(and (instance? Trace that)
Expand Down
3 changes: 3 additions & 0 deletions test/gen/dynamic/trace_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
(is (= :x (trace :addr)))))

(deftest keys
(is (= {} (into {} (dynamic.trace/trace (gen []) [])))
"iterator works on an empty trace")

(is (= #{:addr}
(-> (dynamic.trace/trace (gen []) [])
(dynamic.trace/assoc-subtrace :addr (choice-trace :x))
Expand Down

0 comments on commit b6d5a7e

Please sign in to comment.