Testing for laziness seems simple:
(defn lazy? [coll]
  (= (type coll) clojure.lang.LazySeq))

"For instance if you know a particular sequence could be particularly
large or expensive in certain situations, you may want your tests to
assert that it is not getting evaluated prematurely.."

That's what lazy seqs exists for. You get something that doesn't
evaluated prematurely... Or am I missing your point?

On Jan 18, 5:22 am, Nick Brown <nwbr...@gmail.com> wrote:
> Hi, I'm wondering if there is a good way to test if a given sequence
> is lazy, and if so, how much of it has been evaluated.  I know the
> fact that it is lazy should be transparent, but I'm thinking in the
> context of unit testing knowing that could be valuable.  For instance
> if you know a particular sequence could be particularly large or
> expensive in certain situations, you may want your tests to assert
> that it is not getting evaluated prematurely.
>
> I suppose I could hack the generator function to cause a side effect
> that I could test for, but is there an easier way?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to