Re: defining tests for an api to be called by the implementations

2011-08-15 Thread Alan Malloy
On Aug 15, 10:16 pm, Kevin Livingston wrote: > I am working on an api that has an interface and two distinct > implementations lets call them: foo and bar. > > I have a testing routine with a bunch of functions that each call a > function to get a clean instance of an implementation, initializes i

defining tests for an api to be called by the implementations

2011-08-15 Thread Kevin Livingston
I am working on an api that has an interface and two distinct implementations lets call them: foo and bar. I have a testing routine with a bunch of functions that each call a function to get a clean instance of an implementation, initializes it with some data and then interrogate it. with the exc

Re: Clojure-CLR, CLASSPATH, clojure.load.path and Cygwin

2011-08-15 Thread Ken Wesson
On Mon, Aug 15, 2011 at 11:13 AM, mrwizard82d1 wrote: > I understand that the 1.3 beta plans to add an environment variable > named clojure.load.path to provide a "CLASSPATH" mechanism for Clojure > on the CLR. > > Although I use Windows, I have installed cygwin because I prefer the > Unix tool se

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Mark Rathwell
Wow, forget everything I said, this has nothing to do with macro expansion. Looks more like inside a function you can only def something in the same namespace as the function: user> (defn ff [] (in-ns 'foo.core2) (def anything5 10)) #'user/ff user> anything5 Var user/anything5 is unbound.  [Thr

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Mark Rathwell
You are correct, I must have messed something up in my expansions. >From the below, however, it looks like a var is being declared just by having the macro called, but not bound to the value: user> (defmacro foo [name & body] `(def ~name ~(identity `(fn [] ~@body #'user/foo user> (foo xx (in-n

Re: Trouble embedding clojurescript in server application

2011-08-15 Thread deduktion
I can confirm the problem. Same java (ubuntu) version here. To reproduce the problem please try: 1. Create a new Noir project as described at https://github.com/ibdknox/noir : lein plugin install lein-noir 1.1.0 lein noir new my-website cd my-website lein run Check localho

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Alan Malloy
I either disagree or don't understand. The deftest macro doesn't touch your &body arg; it's expanded as-is. For example, (let [x 'foo] `(inc ~x)) doesn't result in foo getting qualified, and most macros behave the same way. On Aug 15, 4:36 pm, Mark Rathwell wrote: > Just to be clear, it is namesp

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Mark Rathwell
Just to be clear, it is namespace resolved because of syntax quote: (defmacro deftest [name & body] (when *load-tests* `(def ~(vary-meta name assoc :test `(fn [] ~@body)) (fn [] (test-var (var ~name)) On Mon, Aug 15, 2011 at 7:23 PM, Alan Malloy wrote: > Is it? That's neat

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Alan Malloy
Is it? That's neat; I guess I've never thought about how the compiler treats def. Thanks for the explanation. On Aug 15, 3:03 pm, Mark Rathwell wrote: > deftest is a macro.  Macros are expanded at compile time.  So, in this > case, at compile time, a function called namespace2 is def'd with meta

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Mark Rathwell
deftest is a macro. Macros are expanded at compile time. So, in this case, at compile time, a function called namespace2 is def'd with meta data :test set to the body of your deftest. All of that body is namespace resolved in macro expansion, before in-ns is ever executed (which happens when you

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Richard Rattigan
I'm finding that namespaces don't seem to behave as I expect intuitively, or according to the reference. It's quite possible I'm in the wrong here though, as I'm just kicking clojure's tires at this point. Here is the relevant doc: http://clojure.org/special_forms (def symbol init?) Creates and i

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Richard Rattigan
Okay, that makes sense - although it does seem potentially confusing. Thanks! On Aug 15, 1:42 pm, Alan Malloy wrote: > On Aug 15, 6:16 am, Richard  Rattigan wrote: > > > > > > > > > > > I don't understand why this test would fail - can anyone explain why? > > > (ns learn.clojure.test.core > >  

Re: is my understanding correct for function "identity"?

2011-08-15 Thread Ken Wesson
On Sun, Aug 14, 2011 at 6:08 AM, Mats Rauhala wrote: > Another function in the same way is 'const :: a -> b -> a' (on haskell, > but easy to make in clojure if it doesn't exist) which > disregards the second argument and always returns the first. The functions returned by "constantly" in Clojure

Re: Trouble embedding clojurescript in server application

2011-08-15 Thread kjeldahl
I've been exchanging emails and software packages back and forth with ibdknox who has been trying to help, and the whole thing is really weird. I've done my tests on two different computers (both running Ubuntu Natty 11.04 x64), and I get the exact same error on both. ibdknox is testing on his side

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Alan Malloy
On Aug 15, 6:16 am, Richard Rattigan wrote: > I don't understand why this test would fail - can anyone explain why? > > (ns learn.clojure.test.core >   (:use [clojure.test])) > (deftest namespaces >   (in-ns 'my.new.namespace) >   (is (= "my.new.namespace" (str *ns*))) >   (is (= `anything 'my.ne

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Alf Kristian Støyle
Thanks. Submitted an issue to Jira, and I guess I will just see how it goes. http://dev.clojure.org/jira/browse/CLJ-828 Cheers Alf On Mon, Aug 15, 2011 at 16:26, Armando Blancas wrote: >> I think a function should generally return the same types for >> different input. A seq and a Java array

Clojure-CLR, CLASSPATH, clojure.load.path and Cygwin

2011-08-15 Thread mrwizard82d1
I understand that the 1.3 beta plans to add an environment variable named clojure.load.path to provide a "CLASSPATH" mechanism for Clojure on the CLR. Although I use Windows, I have installed cygwin because I prefer the Unix tool set to that provided by Windows. Although a Windows console allows o

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Armando Blancas
> I think a function should generally return the same types for > different input. A seq and a Java array are two very different things > even though Clojure often lets us pass both to the same functions. It > seemed like a small fix, but I guess not everyone agrees. That's clearly a bug; they for

syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Richard Rattigan
I don't understand why this test would fail - can anyone explain why? (ns learn.clojure.test.core (:use [clojure.test])) (deftest namespaces (in-ns 'my.new.namespace) (is (= "my.new.namespace" (str *ns*))) (is (= `anything 'my.new.namespace/anything))) expected: (= (quote learn.clojure.te

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Phillip Garland
On Aug 10, 2011 1:16 PM, "Alf Kristian Støyle" wrote: > I think I found a small bug in clojure.core/bases. Extending the > existing unit test reveals it: > > (deftest test-bases > (are [x y] (= x y) > (bases java.lang.Math) > (list java.lang.Object) > (bases java.lang.Integer) > (list java.lang.Nu

Re: is my understanding correct for function "identity"?

2011-08-15 Thread Mats Rauhala
Another function in the same way is 'const :: a -> b -> a' (on haskell, but easy to make in clojure if it doesn't exist) which disregards the second argument and always returns the first. This example is in haskell, but let's say that you're creating a histogram, meaning that you go through a list

Re: ClojureScript mailing list?

2011-08-15 Thread Alan D. Salewski
On Thu, Jul 28, 2011 at 12:36:08PM -0500, Devin Walters spake thus: > I don't think there has been a significant enough influx of mail on the list > to warrant the creation of a new, separate list. There are so many > similarities between the two that I think we'd run into situations where > peo

Re: Exception calling nth on Sets

2011-08-15 Thread Despite
I should have done a comparison to original Clojure first. In Clojure, rand-nth on an empty vector does throw an exception, as Meikel says. As does any use of nth with a bad index and no not-found parameter. So that seems to be a bug. But, nth on a set never works in Clojure, throwing "java.lan

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 15. August 2011 11:25:33 UTC+2 schrieb Alf: > > I think a function should generally return the same types for > different input. A seq and a Java array are two very different things > even though Clojure often lets us pass both to the same functions. It > seemed like a small fix, bu

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Alf Kristian Støyle
I think a function should generally return the same types for different input. A seq and a Java array are two very different things even though Clojure often lets us pass both to the same functions. It seemed like a small fix, but I guess not everyone agrees. Like a wrote, I think this is small bu