Skip to content
Browse files

fix escaping of code used by clojure.tools.nrepl.helpers/load-file-co…

…mmand; eliminated escape and string-argument (just use pr-str, of course!)
  • Loading branch information...
1 parent 7f69404 commit 15ba754480374ec951db9ba76bac103dc31064a7 @cemerick cemerick committed Nov 18, 2010
View
4 load-file-test/clojure/tools/nrepl/load_file_sample.clj
@@ -2,4 +2,6 @@
-(defn dfunction [])
+(defn dfunction
+ "Ensure \t that \n the \r various \f escapes \" work \\ as expected \\\""
+ [])
View
10 src/main/clojure/clojure/tools/nrepl/helpers.clj
@@ -11,14 +11,6 @@
clojure.tools.nrepl.helpers
(:import (java.io File StringReader)))
-(defn escape
- [#^String s]
- (.replace s "\"" "\\\""))
-
-(defn string-argument
- [s]
- (str \" (escape s) \"))
-
(defn load-file-command
"Returns a string expression that can be sent to an nREPL session to
load the code in given local file in the remote REPL's environment,
@@ -48,4 +40,4 @@
([code file-path file-name]
(apply format
"(clojure.lang.Compiler/load (java.io.StringReader. %s) %s %s)"
- (map string-argument [code file-path file-name]))))
+ (map pr-str [code file-path file-name]))))
View
8 src/test/clojure/clojure/tools/nrepl/helpers_test.clj
@@ -18,14 +18,6 @@
(use-fixtures :once repl-server-fixture)
-(deftest escape-and-string-argument
- (are [string escaped] (= escaped (helpers/escape string))
- "a" "a"
- "\"a" "\\\"a")
- (are [string arg] (= arg (helpers/string-argument string))
- "a" "\"a\""
- "\"a" "\"\\\"a\""))
-
(def-repl-test load-code-with-debug-info
(repl-receive "\n\n\n(defn function [])")
(is (= {:file "NO_SOURCE_PATH" :line 4}

0 comments on commit 15ba754

Please sign in to comment.
Something went wrong with that request. Please try again.