#clojure log - May 20 2008

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

11:42 ozzilee: Does clojure have a test suite?

11:51 rhickey: no

11:55 ozzilee: Ok. I'm playing around with a test library and some clojure tests, just wanted to make sure I wasn't completely wasting my time.

12:31 Oddity: (peek [1 2 3 4]) is 4, (peek (seq [1 2 3 4])) is an error.

12:32 What's expected behavior there?

12:33 rhickey: peek is a function of lists, vectors and queues, not seqs

12:34 ozzilee: seqs are the most general of the four, correct?

12:35 rhickey: not sure what you mean by general

12:36 ozzilee: Superclass maybe? Are lists, vectors and queues all seqs?

12:37 rhickey: no - seq is something that can be obtained on a collection - a sequential view. Some collections are their own seqs (lists) but others are not (vectors/maps)

12:38 ozzilee: Something like an iterator then?

12:38 rhickey: not quite - iterators ar estateful and single-pass

12:39 http://n01se.net/paste/HTx

12:44 jteo: iterators. ugh.

12:45 ozzilee: So should (peek (seq '(1 2 3 4))) work? Ideally, I mean. It works currently.

12:51 rhickey: It works, but implies no more about whether the result of seq should support peek than (peek (identity '(1 2 3 4))) implies about the result of identity

12:54 ozzilee: Ok. I'll write tests for the behavior as-is.

12:54 rhickey: what are you testing in that case?

12:58 ozzilee: (= (peek (seq '(1 2 3 4)) 1))

12:59 rather, (test/= "peek (seq list)" (peek (seq '(1 2 3 4))) 1)

12:59 for vectors: (test/exception "peek (seq vector)" (peek (seq [1 2 3 4])))

13:02 rhickey: but what is the logical test? tests should have a basis, i.e. that lists/vectors support peek. But in this case you are passing the return value of seq, which is not guaranteed to support peek. Such a test has no logical basis, it only serves to freeze current behavior, which is subject to change, i.e. if lists are no longer their own seqs (it's not guaranteed that they will be), which has nothing to do with peek

13:10 ozzilee: I see your point. I'll consider the behavior unspecified then.

13:11 Can I consider it specified that (peek {1 2}) is an exception?

13:14 I suppose not.

13:27 (pop []) is documented as throwing an exception (on the website), it actually throws an Error. Which is correct?

13:28 Or should I just take note and post to the list and stop bugging you? :-)

14:06 * rhickey was out at lunch

14:08 rhickey: I think the focus. being a dynamic language, should be to test that things that ought to work do. Things that don't work might be made to work as an enhancement at some point

14:09 ozzilee: I agree, I'm not going to test (peek <map>).

14:41 DId you get my message about (pop []) ?

14:56 rhickey: (pop []) now throws IllegalStateException, all other usage of IllegalAccessError have been removed as well

14:57 ozzilee: Good deal.

15:37 (keys {}) returns nil. I assume that's proper, seeing as there is no empty Sequence. Correct?

15:39 rhickey: all functions that return seqs either return a seq with items or no seq - nil

15:41 ozzilee: Ok, just making certain. Thanks.

Logging service provided by n01se.net