Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jul 23, 2024
1 parent eaf222a commit 70d3ee0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/sci/impl/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,14 @@

(defn map-fn [children-count]
(if (<= children-count 16)
array-map hash-map))
#?(:clj #(let [^objects arr (into-array %&)]
(clojure.lang.PersistentArrayMap/createWithCheck arr))
:cljs #(PersistentArrayMap.createWithCheck (into-array %&))
:default array-map)
#?(:clj #(let [^objects arr (into-array %&)]
(clojure.lang.PersistentHashMap/createWithCheck arr))
:cljs #(PersistentHashMap.createWithCheck (into-array %&))
:default hash-map)))

(defn return-map [ctx the-map analyzed-children]
(let [mf (map-fn (count analyzed-children))]
Expand Down
3 changes: 2 additions & 1 deletion test/sci/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
:d #{*in* (inc *in*)}
:e {:a *in*}}))))
(testing "duplicate keys"
(is (thrown-with-msg? Exception #"Duplicate key" (sci/eval-string "(let [a 1 b 1] #{a b})"))))
(is (thrown-with-msg? Exception #"Duplicate key" (sci/eval-string "(let [a 1 b 1] #{a b})")))
(is (thrown-with-msg? Exception #"Duplicate key" (sci/eval-string "(let [a 1 b 1] {a 1 b 2})"))))
(testing "quoting"
(is (= {:a '*in*} (eval* 1 (str "'{:a *in*}"))))
(is (= '#{1 2 3 *in*} (eval* 4 "'#{1 2 3 *in*}")))
Expand Down

0 comments on commit 70d3ee0

Please sign in to comment.