test.check

property creating function similar to map as alternative to for-all*

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

As an alternative to the `for-all*` syntax, I suggest using a function signature that looks more like `map` with the predicate as the first arg and the generators as the rest of the args.

For example, these forms would all be equivalent:

(property (comp integer? *) gen/int gen/int gen/int) ;; proposed style

(for-all* [gen/int gen/int gen/int] (comp integer? *)) ;; current style

Activity

Hide
Steve Miner added a comment -

It's easy enough to write for myself. I'll make a patch if you want it.

(defn property 
    ([pred gen] (prop/for-all* [gen] pred))
    ([pred gen1 gen2] (prop/for-all* [gen1 gen2] pred))
    ([pred gen1 gen2 & more] 
        (prop/for-all* (list* gen1 gen2 more) pred)))
Show
Steve Miner added a comment - It's easy enough to write for myself. I'll make a patch if you want it.
(defn property 
    ([pred gen] (prop/for-all* [gen] pred))
    ([pred gen1 gen2] (prop/for-all* [gen1 gen2] pred))
    ([pred gen1 gen2 & more] 
        (prop/for-all* (list* gen1 gen2 more) pred)))
Hide
Gary Fredericks added a comment -

I can't remember having seen this ticket until now, for some reason.

In any case, while I appreciate the monadic harmony with map, I don't think this would add enough value to pay for the increased API surface area. I would be surprised to learn that for-all* itself is even used that much, so I don't think we need two versions of it.

I would be happy to add it to test.chuck if that would be useful to you.

Show
Gary Fredericks added a comment - I can't remember having seen this ticket until now, for some reason. In any case, while I appreciate the monadic harmony with map, I don't think this would add enough value to pay for the increased API surface area. I would be surprised to learn that for-all* itself is even used that much, so I don't think we need two versions of it. I would be happy to add it to test.chuck if that would be useful to you.
Hide
Steve Miner added a comment -

That's OK, I'll roll my own. And thanks for the phrase "monadic harmony" – I'm going to steal that.

Show
Steve Miner added a comment - That's OK, I'll roll my own. And thanks for the phrase "monadic harmony" – I'm going to steal that.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: