Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 \\\"" | ||
[]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))))) |