本文介绍了无法解析符号:在这种情况下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Clojure的新手,在运行单元测试时遇到了一些麻烦.
I'm brand new to Clojure, and I am having a bit of trouble getting unit tests running.
(ns com.bluepojo.scratch
(:require clojure.test))
(defn add-one
([x] (+ x 1))
)
(is (= (add-one 3) 4))
给予:
java.lang.Exception: Unable to resolve symbol: is in this context
我想念什么?
更新:
这有效:
(clojure.test/is (= (add-one 3) 4))
我如何做到这一点,这样就不必在声明之前声明clojure.test?
How do I make it so that I don't have to declare clojure.test before the is?
推荐答案
您对ns宏的使用不太正确,您可以通过多种方法进行修复.我建议其中之一
Your use of the ns macro is not quite correct and you have several options to fix it. I would suggest one of
(ns com.bluepojo.scratch
(:require [clojure.test :as test))
(defn add-one
([x] (+ x 1)))
(test/is (= (add-one 3) 4))
2.使用use
(ns com.bluepojo.scratch
(:use [clojure.test :only [is]]))
(defn add-one
([x] (+ x 1)))
(is (= (add-one 3) 4))
看看这篇文章对此进行了详尽的解释
Take a look at this article which explains this at some length
这篇关于无法解析符号:在这种情况下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!