#clojure logs

2008-05-20

11:42ozzileeDoes clojure have a test suite?
11:51rhickeyno
11:55ozzileeOk. 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:31ozzileeOddity: (peek [1 2 3 4]) is 4, (peek (seq [1 2 3 4])) is an error.
12:32ozzileeWhat's expected behavior there?
12:33rhickeypeek is a function of lists, vectors and queues, not seqs
12:34ozzileeseqs are the most general of the four, correct?
12:35rhickeynot sure what you mean by general
12:36ozzileeSuperclass maybe? Are lists, vectors and queues all seqs?
12:37rhickeyno - 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:38ozzileeSomething like an iterator then?
12:38rhickeynot quite - iterators ar estateful and single-pass
12:39rhickeyhttp://n01se.net/paste/HTx
12:44jteoiterators. ugh.
12:45ozzileeSo should (peek (seq '(1 2 3 4))) work? Ideally, I mean. It works currently.
12:51rhickeyIt 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:54ozzileeOk. I'll write tests for the behavior as-is.
12:54rhickeywhat are you testing in that case?
12:58ozzilee(= (peek (seq '(1 2 3 4)) 1))
12:59ozzileerather, (test/= "peek (seq list)" (peek (seq '(1 2 3 4))) 1)
12:59ozzileefor vectors: (test/exception "peek (seq vector)" (peek (seq [1 2 3 4])))
13:02rhickeybut 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:10ozzileeI see your point. I'll consider the behavior unspecified then.
13:11ozzileeCan I consider it specified that (peek {1 2}) is an exception?
13:14ozzileeI suppose not.
13:27ozzilee(pop []) is documented as throwing an exception (on the website), it actually throws an Error. Which is correct?
13:28ozzileeOr should I just take note and post to the list and stop bugging you? :-)
14:08rhickeyI 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:09ozzileeI agree, I'm not going to test (peek <map>).
14:41ozzileeDId you get my message about (pop []) ?
14:56rhickey(pop []) now throws IllegalStateException, all other usage of IllegalAccessError have been removed as well
14:57ozzileeGood deal.
15:37ozzilee(keys {}) returns nil. I assume that's proper, seeing as there is no empty Sequence. Correct?
15:39rhickeyall functions that return seqs either return a seq with items or no seq - nil
15:41ozzileeOk, just making certain. Thanks.