Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/scicloj/kindly/v4/api.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
[value m]
(if (instance? clojure.lang.IObj value)
(vary-meta value merge m)
(attach-meta-to-value [value] m)))
(attach-meta-to-value
[value]
(update m :kindly/options assoc :wrapped-value true))))

(defn attach-kind-to-value
[value kind]
Expand Down
8 changes: 8 additions & 0 deletions test/scicloj/kindly/v4/api_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
{:b 2})))

(deftest options-test
(is (get-in (meta (kindly/attach-meta-to-value 4 {:kindly/kind :code}))
[:kindly/options :wrapped-value])
"wrapped values should have annotations in metadata")

(is (not= (meta (kindly/attach-meta-to-value 4 {:kindly/kind :code}))
(meta (kindly/attach-meta-to-value [4] {:kindly/kind :code})))
"wrapped values should be distinguishable from single-element vectors")

(kindly/set-options! {:foo "bar"})
(is (= "bar" (-> (kindly/get-options) :foo))
"setting options should work")
Expand Down