[#601] Support clojure.java.io/Coercions
This commit is contained in:
parent
b3fbe7e12e
commit
ab5a02ec30
1 changed files with 25 additions and 0 deletions
25
test/babashka/impl/clojure/java/io_test.clj
Normal file
25
test/babashka/impl/clojure/java/io_test.clj
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
(ns babashka.impl.clojure.java.io-test
|
||||
(:require [babashka.test-utils :as test-utils]
|
||||
[clojure.edn :as edn]
|
||||
[clojure.test :as t :refer [deftest is]]))
|
||||
|
||||
(defn bb [& args]
|
||||
(edn/read-string
|
||||
{:readers *data-readers*
|
||||
:eof nil}
|
||||
(apply test-utils/bb nil (map str args))))
|
||||
|
||||
(deftest nio-coercion-test
|
||||
(is (true? (bb "
|
||||
(require '[clojure.java.io :as io])
|
||||
|
||||
(extend-protocol io/Coercions
|
||||
java.nio.file.Path
|
||||
(as-file [this] (.toFile this))
|
||||
(as-url [this] (.. this (toFile) (toURL))))
|
||||
|
||||
(def path (.toPath (io/file \".\")))
|
||||
;; ^ this is a java.nio.file.Path
|
||||
|
||||
(.exists (io/file path)) ;; true
|
||||
"))))
|
||||
Loading…
Reference in a new issue