change to arg-meta, fix byte->boolean + added test

This commit is contained in:
Jude Payne 2023-05-10 22:13:00 +01:00
parent bdb0409889
commit 338304cd5c
6 changed files with 20 additions and 3 deletions

View file

@ -29,7 +29,7 @@
(String. bytes))
(defn bytes->boolean [^"[B" bytes]
(boolean bytes))
(= "true" (String. bytes)))
(defn get-string [m k]
(-> (get m k)
@ -142,7 +142,7 @@
name-sym (if vmeta
(with-meta name-sym vmeta)
name-sym)
metadata? (get-maybe-boolean var "read-meta?")]
metadata? (get-maybe-boolean var "arg-meta")]
(when metadata?
(swap! vars-with-metadata update (:pod-id pod) #(conj (set %) sym)))
[name-sym

View file

@ -137,7 +137,9 @@
"code" "(defn read-other-tag [x] [x x])"
"meta" "{:doc \"unread\"}"}
{"name" "round-trip-meta"
"read-meta?" "true"}
"arg-meta" "true"}
{"name" "dont-round-trip-meta"
"arg-meta" "false"}
{"name" "-local-date-time"}
{"name" "transit-stuff"
"code" "
@ -244,6 +246,14 @@
"id" id
"value" "#my/other-tag[1]"})
pod.test-pod/round-trip-meta
(write out
{"status" ["done"]
"id" id
"value"
(case format
:transit+json (transit-json-write-meta (first args))
(write-fn (first args)))})
pod.test-pod/dont-round-trip-meta
(write out
{"status" ["done"]
"id" id

View file

@ -94,6 +94,11 @@
(= {:my-meta 3} (meta (first (pod.test-pod/round-trip-meta [(with-meta [3] {:my-meta 3})]))))
true))
(def dont-round-trip-meta
(if (= "transit+json" fmt)
(= nil (meta (pod.test-pod/dont-round-trip-meta (with-meta [2] {:my-meta 2}))))
true))
(require '[pod.test-pod.only-code :as only-code])
(def should-be-1 (only-code/foo))
@ -128,6 +133,7 @@
assoc-string-array
round-trip-meta
round-trip-meta-nested
dont-round-trip-meta
should-be-1
add-sync-meta
error-meta

BIN
test/.DS_Store vendored Normal file

Binary file not shown.

BIN
test/babashka/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -36,6 +36,7 @@
true ;; roundtrip string array
true ;; roundtrip metadata
true ;; roundtrip metadata nested
true ;; dont roundtrip metadata (when arg-meta "false"/ absent)
1
"add the arguments"
nil