-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Moved from nrepl/nrepl#260
Expected behaviour
When a test fails in directly in Clojure, I get the following output:
$ clj
Clojure 1.10.3
user=> (require '[clojure.test :refer :all])
nil
user=> (is (= "a" \a))
FAIL in () (NO_SOURCE_FILE:1)
expected: (= "a" \a)
actual: (not (= "a" \a))
false
Actual behavior
When I run the same test through a Cider nREPL, I get the following output, (this is taken from a Calva REPL):
clj꞉sample-project.core-test꞉> (require '[clojure.test :refer :all])
nil
clj꞉sample-project.core-test꞉> (is (= "a" \a))
FAIL in () (form-init17836416246985520428.clj:8)
expected: "a"
actual: (\a)
false
The key difference here is that Clojure shows that the expected result was \a
, but nREPL says the actual result was (\a)
.
This is confusing. It makes it difficult to debug why a test has failed, because it appears like the actual result is a list of \a
, (i.e. '(\a)
), rather that \a
. This also makes it very difficult to copy+paste results into tests expectations.
Steps to reproduce the problem
Evaluate the following two forms in a nREPL:
(require '[clojure.test :refer :all])
(is (= "a" \a))
I see the following in the Calva nREPL log:
<- received
{
id: '80',
out: 'expected: "a"\n',
session: 'd3f9f96c-2c5a-4e89-806d-0b86f1ab9e6b'
}
<- received
{
id: '80',
out: ' actual: (\\a)\n',
session: 'd3f9f96c-2c5a-4e89-806d-0b86f1ab9e6b'
}
Which shows that the string is being produced server-side, and is not being altered by Calva.
Environment & Version information
cider-nrepl version
cider-nrepl 0.27.3
nrepl 0.8.3
Java version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)
Operating system
macOS 12.0.1 (21A559)