Bogdanp / rackcheck

A property-based testing library for Racket.
28 stars 7 forks source link

Expose prop-name as property-name #9

Closed lemastero closed 2 years ago

lemastero commented 2 years ago

In some cases it is useful to use prop-name, for example if we have property:

(define-property prop-list-map-composition
  ([xs (gen:list gen:natural)])
  (let ([f (lambda (n) (* 3 (add1 n)))]
          [g (lambda (n) (/ n 2))])
      (check-equal? (map f (map g xs)) (map (compose f g) xs))))

and we want to run it as racketunit test-case providing the same name. Currently prop struct is not exposed. If we have prop-name lets say as property-name, we could define helper:

(define (test-property prop)
  (test-case (symbol->string (property-name prop))
  (check-property prop)))

and now:

(test-property prop-list-map-composition))

This PR attempt to achieve this. WDYT @Bogdanp

Bogdanp commented 2 years ago

Thank you!

lemastero commented 2 years ago

Thank you for building this very nice library, insights on review & your time 🙇