Skip to content

Commit

Permalink
#822: more docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 1, 2022
1 parent 4b7d7cf commit 70fba0c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/sci/impl/namespaces.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,7 @@
;; end IDeref as protocol
;; IAtom / ISwap as protocol
'swap! (new-var 'swap! core-protocols/swap!*)
'compare-and-set! #?(:clj (new-var 'compare-and-set!
core-protocols/compare-and-set!*)
'compare-and-set! #?(:clj (copy-var core-protocols/compare-and-set!* clojure-core-ns {:name 'compare-and-set!})
:cljs (copy-core-var compare-and-set!))
#?@(:cljs ['IReset core-protocols/reset-protocol
'ISwap core-protocols/swap-protocol
Expand Down
12 changes: 9 additions & 3 deletions src/sci/impl/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,15 @@

(def clojure-core-ns (lang/->Namespace 'clojure.core nil))

(def current-file (dynamic-var '*file* nil {:ns clojure-core-ns}))

(def current-ns (dynamic-var '*ns* user-ns {:ns clojure-core-ns}))
(def current-file
(dynamic-var '*file* nil
{:doc "The path of the file being evaluated, as a String.\n\n When there is no file, e.g. in the REPL, the value is not defined."
:ns clojure-core-ns}))

(def current-ns
(dynamic-var '*ns* user-ns
{:ns clojure-core-ns
:doc "A sci.lang.Namespace object representing the current namespace."}))

(defn current-ns-name []
(t/getName @current-ns))
Expand Down
6 changes: 4 additions & 2 deletions test/sci/namespaces_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ bar/bar"}
(doseq [v '[*print-namespace-maps*
*print-dup*
*print-readably*
*1 *2 *3 *e]]
*1 *2 *3 *e
*file* *ns*]]
(is (true? (eval* (str/replace "(string? (:doc (meta #'{{v}})))" "{{v}}" (str v)))) v)))
(testing "regular vars (with possibly alternative impls)"
(doseq [v `[inc
Expand All @@ -337,7 +338,8 @@ bar/bar"}
#?(:clj reset-vals!)
alength
#?(:clj var-get)
#?(:clj var-set)]
#?(:clj var-set)
compare-and-set!]
:when v]
(is (true? (eval* (str/replace "(string? (:doc (meta #'{{v}})))" "{{v}}" (str v)))) v))))

Expand Down

0 comments on commit 70fba0c

Please sign in to comment.