Bump sci: namespaces
This commit is contained in:
parent
87accff420
commit
3e0d464bfe
4 changed files with 21 additions and 21 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
|||
Subproject commit 4b4b8f49b51c5c471591fe484bdc80a58dc5f8ea
|
||||
Subproject commit d91bf4bf1b831de58a4980379558aed6ce28a641
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.reader.reader-types :as r]
|
||||
[sci.impl.interpreter :refer [opts->ctx eval-edn-vals]]
|
||||
[sci.impl.interpreter :refer [opts->ctx eval-form]]
|
||||
[sci.impl.parser :as parser]))
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
(println))
|
||||
:read (fn [_request-prompt request-exit]
|
||||
(if (r/peek-char in) ;; if this is nil, we reached EOF
|
||||
(let [v (parser/parse-next in #{:bb})]
|
||||
(let [v (parser/parse-next in #{:bb} {:current (-> sci-ctx :env deref :current-ns)})]
|
||||
(if (or (identical? :repl/quit v)
|
||||
(identical? :repl/exit v)
|
||||
(identical? :edamame.impl.parser/eof v))
|
||||
|
|
@ -32,18 +32,20 @@
|
|||
v))
|
||||
request-exit))
|
||||
:eval (fn [expr]
|
||||
(let [ret (eval-edn-vals (update sci-ctx
|
||||
:env
|
||||
(fn [env]
|
||||
(swap! env assoc
|
||||
'*1 *1
|
||||
'*2 *2
|
||||
'*3 *3
|
||||
'*e *e)
|
||||
env))
|
||||
[expr])]
|
||||
(let [ret (eval-form (update sci-ctx
|
||||
:env
|
||||
(fn [env]
|
||||
(swap! env update-in [:namespaces 'clojure.core]
|
||||
assoc
|
||||
'*1 *1
|
||||
'*2 *2
|
||||
'*3 *3
|
||||
'*e *e)
|
||||
env))
|
||||
expr)]
|
||||
ret))
|
||||
:need-prompt (fn [] true))))
|
||||
:need-prompt (fn [] true)
|
||||
:prompt #(printf "%s=> " (-> sci-ctx :env deref :current-ns)))))
|
||||
|
||||
(defn start-repl! [host+port sci-opts]
|
||||
(let [parts (str/split host+port #":")
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
[clojure.java.shell :as shell]
|
||||
[clojure.string :as str]
|
||||
[sci.core :as sci])
|
||||
(:import [sun.misc Signal]
|
||||
[sun.misc SignalHandler])
|
||||
(:gen-class))
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
|
@ -259,9 +257,9 @@ Everything after that is bound to *command-line-args*."))
|
|||
(let [expr (if file (read-file file) expression)]
|
||||
(if expr
|
||||
(loop [in (read-next *in*)]
|
||||
(let [ctx (update ctx :bindings assoc (with-meta '*in*
|
||||
(when-not stream?
|
||||
{:sci/deref! true})) in)]
|
||||
(let [ctx (update-in ctx [:namespaces 'user] assoc (with-meta '*in*
|
||||
(when-not stream?
|
||||
{:sci/deref! true})) in)]
|
||||
(if (identical? ::EOF in)
|
||||
[nil 0] ;; done streaming
|
||||
(let [res [(let [res (sci/eval-string expr ctx)]
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@
|
|||
(sh "bash" "-c"
|
||||
"lsof -t -i:1666"))))))
|
||||
(is (str/includes? (socket-command '(+ 1 2 3))
|
||||
"bb=> 6"))
|
||||
"user=> 6"))
|
||||
(testing "ctrl-d exits normally, doesn't print nil"
|
||||
(is (str/ends-with? (:out (sh "bash" "-c"
|
||||
(if mac? ;; mac doesn't support -q
|
||||
"echo \"(inc 1336)\" | nc 127.0.0.1 1666"
|
||||
"echo \"(inc 1336)\" | nc -q 1 127.0.0.1 1666")))
|
||||
"1337\nbb=> ")))
|
||||
"1337\nuser=> ")))
|
||||
(testing "*in*"
|
||||
(is (str/includes? (socket-command "*in*")
|
||||
"[1 2 3]")))
|
||||
|
|
|
|||
Loading…
Reference in a new issue