add dynamic var *source-path* to clojure.core
This commit is contained in:
parent
2907e1fb19
commit
f9e883248c
2 changed files with 19 additions and 0 deletions
|
|
@ -27,6 +27,7 @@
|
|||
(def math-context (core-dynamic-var '*math-context*))
|
||||
(def compile-path (core-dynamic-var '*compile-path* *compile-path*))
|
||||
(def compiler-options (core-dynamic-var '*compiler-options*))
|
||||
(def source-path (core-dynamic-var '*source-path*))
|
||||
|
||||
(defn read+string
|
||||
"Added for compatibility. Must be used with
|
||||
|
|
@ -167,6 +168,7 @@
|
|||
'*math-context* math-context
|
||||
'*compiler-options* compiler-options
|
||||
'*compile-path* compile-path
|
||||
'*source-path* source-path
|
||||
'with-precision (sci/copy-var with-precision clojure-core-ns)
|
||||
'-with-precision (sci/copy-var -with-precision clojure-core-ns)
|
||||
;; STM
|
||||
|
|
|
|||
17
test/babashka/impl/clojure/core_test.clj
Normal file
17
test/babashka/impl/clojure/core_test.clj
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(ns babashka.impl.clojure.core-test
|
||||
(:require [babashka.test-utils :as tu]
|
||||
[clojure.test :as t :refer [deftest is testing]]
|
||||
[clojure.tools.reader.edn :as edn]))
|
||||
|
||||
(def bb
|
||||
(comp edn/read-string tu/bb))
|
||||
|
||||
(deftest source-path-test
|
||||
(testing "source path is nil by default"
|
||||
(is (empty? (bb nil "*source-path*"))))
|
||||
(testing "source path can be bound dynamically"
|
||||
(is (= ["some_value.clj" nil]
|
||||
(bb nil (pr-str '(let [x (binding [*source-path* "some_value.clj"]
|
||||
*source-path*)
|
||||
y *source-path*]
|
||||
[x y])))))))
|
||||
Loading…
Reference in a new issue