Skip to content

Commit

Permalink
Port load-file-test
Browse files Browse the repository at this point in the history
  • Loading branch information
dmiller committed Oct 5, 2014
1 parent 1a87ef3 commit 8f0b76f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
7 changes: 7 additions & 0 deletions load-file-test/clojure/tools/nrepl/load_file_sample.clj
@@ -0,0 +1,7 @@
(ns clojure.tools.nrepl.load-file-sample)



(defn dfunction
"Ensure \t that \n the \r various \f escapes \" work \\ as expected \\\""
[])
60 changes: 60 additions & 0 deletions test/clojure/tools/nrepl/load_file_test.clj
@@ -0,0 +1,60 @@
(ns ^{:author "Chas Emerick"}
clojure.tools.nrepl.load-file-test
(:import [System.IO Path]) ;;; (java.io File)
(:use [clojure.tools.nrepl-test :only (def-repl-test repl-server-fixture
project-base-dir)]
clojure.test)
(:require [clojure.tools.nrepl :as nrepl]))

(use-fixtures :each repl-server-fixture)

(def-repl-test load-code-with-debug-info
(doall (nrepl/message timeout-session
{:op "load-file" :file "\n\n\n(defn function [])"}))
(is (contains?
; different versions of Clojure use different default :file metadata
#{[{:file "NO_SOURCE_PATH" :line 4}]
[{:file "NO_SOURCE_FILE" :line 4}]}
(repl-values timeout-session
(nrepl/code
(-> #'function
meta
(select-keys [:file :line]))))))

(doall (nrepl/message timeout-session {:op "load-file"
:file "\n\n\n\n\n\n\n\n\n(defn afunction [])"
:file-path "path/from/source/root.clj"
:file-name "root.clj"}))
(is (= [{:file "path/from/source/root.clj" :line 10}]
(repl-values timeout-session
(nrepl/code
(-> #'afunction
meta
(select-keys [:file :line])))))))

(def-repl-test load-file-with-debug-info
(doall
(nrepl/message timeout-session
{:op "load-file"
:file (slurp (Path/Combine (str project-base-dir) "load-file-test/clojure/tools/nrepl/load_file_sample.clj")) ;;; File. + added Path.Combine
:file-path "clojure/tools/nrepl/load_file_sample.clj"
:file-name "load_file_sample.clj"}))
(is (= [{:file "clojure/tools/nrepl/load_file_sample.clj" :line 5}]
(repl-values timeout-session
(nrepl/code
(-> #'clojure.tools.nrepl.load-file-sample/dfunction
meta
(select-keys [:file :line])))))))

(def-repl-test load-file-with-print-vars
(set! *print-length* 3)
(set! *print-level* 3)
(doall
(nrepl/message session {:op "load-file"
:file "(def a (+ 1 (+ 2 (+ 3 (+ 4 (+ 5 6))))))
(def b 2) (def c 3) (def ^{:internal true} d 4)"
:file-path "path/from/source/root.clj"
:file-name "root.clj"}))

(is (= [4]
(repl-values session (nrepl/code d)))))

0 comments on commit 8f0b76f

Please sign in to comment.