Skip to content

Commit

Permalink
Protocol test
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 10, 2020
1 parent db4c1d0 commit 76dd775
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/babashka/impl/classes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@
:methods [borkdude.graal.LockFix] ;; support for locking

:fields [clojure.lang.PersistentQueue]
:instance-checks [clojure.lang.Cycle
:instance-checks [clojure.lang.Cons
clojure.lang.Cycle
clojure.lang.IObj
clojure.lang.IFn
clojure.lang.IPending
Expand Down
11 changes: 7 additions & 4 deletions test/babashka/protocols_test.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(ns babashka.protocols-test
(:require [babashka.test-utils :refer [bb]]
[clojure.edn :as edn]
[clojure.test :as t :refer [deftest is]]))

(deftest safe-datafy
(is (bb
"
(is (apply = 100000 (map count (edn/read-string (bb nil "
(ns safe-datafy
(:require [clojure.core.protocols :as p]
[clojure.datafy :as df]))
Expand All @@ -17,6 +17,8 @@
(vary-meta merge (meta s) {:nextjournal.seq/truncated? true})))
(extend-protocol p/Datafiable
clojure.lang.Cons
(df/datafy [s] (infinite-sequence-chunking s))
clojure.lang.LazySeq
(df/datafy [s] (infinite-sequence-chunking s))
clojure.lang.Iterate
Expand All @@ -35,5 +37,6 @@
(vary-meta (fn [m] (merge (dissoc m :clojure.datafy/class :clojure.datafy/obj)
(meta x)))))))
[(safe-datafy (range))
(safe-datafy (repeat 1))]")))
[(doall (safe-datafy (range)))
(doall (safe-datafy (repeat 1)))
(doall (safe-datafy (cons -1 (range))))]"))))))

0 comments on commit 76dd775

Please sign in to comment.