我正在阅读来自clojure-doc.org的 clojure & emacs 教程,当按照建议编译测试时,我在 emacs nrepl 中得到以下输出:
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: deftest in this context, compiling:(/home/jakov/dev/PROJECTS/clojure/test2/test/test2/core_test.clj:1)
Compiler.java:6281 clojure.lang.Compiler.analyze
Compiler.java:6223 clojure.lang.Compiler.analyze
Compiler.java:3497 clojure.lang.Compiler$InvokeExpr.parse
Compiler.java:6457 clojure.lang.Compiler.analyzeSeq
Compiler.java:6262 clojure.lang.Compiler.analyze
Compiler.java:6223 clojure.lang.Compiler.analyze
Compiler.java:6515 clojure.lang.Compiler.eval
Compiler.java:6952 clojure.lang.Compiler.load
Compiler.java:6912 clojure.lang.Compiler.loadFile
RT.java:307 clojure.lang.RT$3.invoke
NO_SOURCE_FILE:1 user/eval42
Compiler.java:6511 clojure.lang.Compiler.eval
Compiler.java:6477 clojure.lang.Compiler.eval
core.clj:2797 clojure.core/eval
main.clj:245 clojure.main/repl[fn]
main.clj:266 clojure.main/repl[fn]
main.clj:266 clojure.main/repl
RestFn.java:1096 clojure.lang.RestFn.invoke
interruptible_eval.clj:56 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
AFn.java:159 clojure.lang.AFn.applyToHelper
AFn.java:151 clojure.lang.AFn.applyTo
core.clj:601 clojure.core/apply
core.clj:1771 clojure.core/with-bindings*
RestFn.java:425 clojure.lang.RestFn.invoke
interruptible_eval.clj:41 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:171 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
core.clj:2278 clojure.core/comp[fn]
interruptible_eval.clj:138 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:24 clojure.lang.AFn.run
ThreadPoolExecutor.java:895 java.util.concurrent.ThreadPoolExecutor$Worker.runTask
ThreadPoolExecutor.java:918 java.util.concurrent.ThreadPoolExecutor$Worker.run
Thread.java:662 java.lang.Thread.run
Caused by: java.lang.RuntimeException: Unable to resolve symbol: deftest in this context
Util.java:170 clojure.lang.Util.runtimeException
Compiler.java:6766 clojure.lang.Compiler.resolveIn
Compiler.java:6710 clojure.lang.Compiler.resolve
Compiler.java:6671 clojure.lang.Compiler.analyzeSymbol
Compiler.java:6244 clojure.lang.Compiler.analyze
对我来说,这行似乎在 nrepl 错误输出中至关重要:
Caused by: java.lang.RuntimeException: Unable to resolve symbol: deftest in this context
无论如何,我真的是一个 clojure 和 emacs 菜鸟,我在这里没有太多线索。所有的 emacs slime clojure 东西都安装好leiningen2
了,java 是 oracle java 1.6,emacs 是 emacs 24,当我在项目目录中运行 lein test 时,它没有错误。
谁能帮我?
编辑:
我的 core_test.clj 文件:
(deftest pairs-of-values
(let [args ["--server" "localhost"
"--port" "8080"
"--environment" "production"]]
(is (= {:server "localhost"
:port "8080"
:environment "production"}
(parse-args args)))))
我的 core.clj 文件:
(defn parse-args [args]
{})