Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve symbol: is in this context

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))

gives:

java.lang.Exception: Unable to resolve symbol: is in this context

What am I missing?

Update:

This works:

(clojure.test/is (= (add-one 3) 4))

How do I make it so that I don't have to declare clojure.test before the is?

like image 379
Josiah Kiehl Avatar asked Dec 16 '10 04:12

Josiah Kiehl


Video Answer


1 Answers

Your use of the ns macro is not quite correct and you have several options to fix it. I would suggest one of

1. Alias clojure.test to something shorter

(ns com.bluepojo.scratch
  (:require [clojure.test :as test))

(defn add-one
  ([x] (+ x 1)))

(test/is (= (add-one 3) 4))

2. Use 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

like image 131
Jonas Avatar answered Oct 11 '22 15:10

Jonas