parent
5695ee3a52
commit
d21274a62d
2 changed files with 10 additions and 1 deletions
|
|
@ -167,6 +167,9 @@ Everything after that is bound to *command-line-args*."))
|
||||||
(defn load-file* [ctx file]
|
(defn load-file* [ctx file]
|
||||||
(let [s (slurp file)]
|
(let [s (slurp file)]
|
||||||
(sci/eval-string s ctx)))
|
(sci/eval-string s ctx)))
|
||||||
|
|
||||||
|
(defn eval* [ctx form]
|
||||||
|
(sci/eval-string (pr-str form) ctx))
|
||||||
|
|
||||||
(defn start-socket-repl! [address ctx read-next]
|
(defn start-socket-repl! [address ctx read-next]
|
||||||
(let [ctx (update ctx :bindings assoc
|
(let [ctx (update ctx :bindings assoc
|
||||||
|
|
@ -223,7 +226,8 @@ Everything after that is bound to *command-line-args*."))
|
||||||
:bindings (assoc bindings '*command-line-args* command-line-args)
|
:bindings (assoc bindings '*command-line-args* command-line-args)
|
||||||
:env env
|
:env env
|
||||||
:features #{:bb}}
|
:features #{:bb}}
|
||||||
ctx (update ctx :bindings assoc 'load-file #(load-file* ctx %))
|
ctx (update ctx :bindings assoc 'eval #(eval* ctx %)
|
||||||
|
'load-file #(load-file* ctx %))
|
||||||
_preloads (some-> (System/getenv "BABASHKA_PRELOADS") (str/trim) (sci/eval-string ctx))
|
_preloads (some-> (System/getenv "BABASHKA_PRELOADS") (str/trim) (sci/eval-string ctx))
|
||||||
exit-code
|
exit-code
|
||||||
(or
|
(or
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,11 @@
|
||||||
(is (= "120\n" (test-utils/bb nil (format "(load-file \"%s\") (bar (foo 10 30) 3)"
|
(is (= "120\n" (test-utils/bb nil (format "(load-file \"%s\") (bar (foo 10 30) 3)"
|
||||||
(.getPath tmp)))))))
|
(.getPath tmp)))))))
|
||||||
|
|
||||||
|
(deftest eval-test
|
||||||
|
(is (= "120\n" (test-utils/bb nil "(eval '(do (defn foo [x y] (+ x y))
|
||||||
|
(defn bar [x y] (* x y))
|
||||||
|
(bar (foo 10 30) 3)))"))))
|
||||||
|
|
||||||
(deftest preloads-test
|
(deftest preloads-test
|
||||||
;; THIS TEST REQUIRES:
|
;; THIS TEST REQUIRES:
|
||||||
;; export BABASHKA_PRELOADS='(defn __bb__foo [] "foo") (defn __bb__bar [] "bar")'
|
;; export BABASHKA_PRELOADS='(defn __bb__foo [] "foo") (defn __bb__bar [] "bar")'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue