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