From 14e4dda82b282ef3a4cbdf2f26b3d52be9afcd90 Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 30 May 2024 08:40:37 -0400 Subject: [PATCH] make `*source-path*` bind to the same var as `*file*` --- CHANGELOG.md | 2 +- src/babashka/impl/clojure/core.clj | 3 +-- test/babashka/impl/clojure/core_test.clj | 17 ----------------- 3 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 test/babashka/impl/clojure/core_test.clj diff --git a/CHANGELOG.md b/CHANGELOG.md index b6db111d..9769e745 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ A preview of the next release can be installed from - Partially Fix [#1695](https://github.com/babashka/babashka/issues/1695): make `*command-line-args*` value available in the REPL ([@bobisageek](https://github.com/bobisageek)) - Fix [#1686](https://github.com/babashka/babashka/issues/1686): do not fetch dependencies/invoke java for `version`, `help`, and `describe` options ([@bobisageek](https://github.com/bobisageek)) - [#1696](https://github.com/babashka/babashka/issues/1696): add `clojure.lang.DynamicClassLoader` constructors ([@bobisageek](https://github.com/bobisageek)) -- [#1696](https://github.com/babashka/babashka/issues/1696): add `clojure.core/*source-path*` (unused) ([@bobisageek](https://github.com/bobisageek)) +- [#1696](https://github.com/babashka/babashka/issues/1696): add `clojure.core/*source-path*` (points to the same sci var as `*file*`) ([@bobisageek](https://github.com/bobisageek)) - [#1696](https://github.com/babashka/babashka/issues/1696): add `clojure.main/with-read-known` ([@bobisageek](https://github.com/bobisageek)) - [#1696](https://github.com/babashka/babashka/issues/1696): add `clojure.core.server/repl-read` ([@bobisageek](https://github.com/bobisageek)) diff --git a/src/babashka/impl/clojure/core.clj b/src/babashka/impl/clojure/core.clj index 2aaf2e09..fb39383d 100644 --- a/src/babashka/impl/clojure/core.clj +++ b/src/babashka/impl/clojure/core.clj @@ -27,7 +27,6 @@ (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 @@ -168,7 +167,7 @@ '*math-context* math-context '*compiler-options* compiler-options '*compile-path* compile-path - '*source-path* source-path + '*source-path* sci/file 'with-precision (sci/copy-var with-precision clojure-core-ns) '-with-precision (sci/copy-var -with-precision clojure-core-ns) ;; STM diff --git a/test/babashka/impl/clojure/core_test.clj b/test/babashka/impl/clojure/core_test.clj deleted file mode 100644 index 010b8ce2..00000000 --- a/test/babashka/impl/clojure/core_test.clj +++ /dev/null @@ -1,17 +0,0 @@ -(ns babashka.impl.clojure.core-test - (:require [babashka.test-utils :as tu] - [clojure.edn :as edn] - [clojure.test :as t :refer [deftest is testing]])) - -(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]))))))) \ No newline at end of file