Can this be easily translated to specjl

24 views
Skip to first unread message

Roelof Wobben

unread,
Nov 1, 2014, 5:12:36 AM11/1/14
to spe...@googlegroups.com
Hello,

Im trying to learn clojure and specjl.

So I thought  I try to solve this puzzle and make a specjl test to test my solution.

Write a function which, given a key and map, returns true iff the map contains an entry with that key and its value is nil.

and here is the  clojure.test file I think ;

(true?  (__ :a {:a nil :b 2}))

Could this one be easily be translated to a specjl test file with of course the solution in it.

Do not give me the solution because then I learn nothing

Roelof

Sandro Padin

unread,
Nov 1, 2014, 8:39:53 AM11/1/14
to spe...@googlegroups.com
Roelof,

Your test should be pretty easy to convert to speclj. 

There is a speclj project template that you might find useful. Simply running `lein new speclj my-project-name` will generate a new project with speclj already set up and ready for you to test. You don't need to install anything to run that (lein new) command, leiningen will figure out that speclj is a template and download it on its own.

On a side note, I think you may need a couple more test cases to satisfy the full description of the function. Without giving away the actual answer this is what I see as possible test cases: (there may be more)

"the function":
* should return true if the value of a map at a certain key is nil (you've got this one)
* should return false if the value of a map at a certain key is not nil
* should return false if the map does not contain the key.

Have fun learning Clojure.

Sandro


--
You received this message because you are subscribed to the Google Groups "speclj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to speclj+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roelof Wobben

unread,
Nov 1, 2014, 11:11:49 AM11/1/14
to spe...@googlegroups.com
Thanks,

I quickly read the tutorial but I still do not have a idea how to do it.
Do I need to make 2 seperate test for the input and the output as done in the tutorial.
and do I need to make a test for every input that I want to test.

Roelof


Op zaterdag 1 november 2014 13:39:53 UTC+1 schreef Sandro Padin:
Reply all
Reply to author
Forward
0 new messages