test.check

Namespace reorganization

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Currently test.check (and simple-check) use three separate namespaces: core, generators and properties. Bronsa has suggested renaming test.check.core to simply test.check. This has me wondering if the entire public API should be exported from just the 'test.check' namespace. This would mean users only need to import one namespace. Thoughts?

[1] https://github.com/clojure/test.check/commit/a2f270ae8e6fa99f337eaff6fbb2051a66dac392#commitcomment-5303415

Activity

Hide
Bruce Adams added a comment -

I agree, this is lower priority than its current "Major".

Show
Bruce Adams added a comment - I agree, this is lower priority than its current "Major".
Hide
Reid Draper added a comment -

Currently I'm thinking this is pretty low priority, given the other issues on the repo. Any disagreement?

Show
Reid Draper added a comment - Currently I'm thinking this is pretty low priority, given the other issues on the repo. Any disagreement?
Hide
Chas Emerick added a comment -

+1 to making the properties bits available in clojure.test.check. I've never been a fan of using load to separate namespaces into different files; var immigration is another option that could work.

I agree with Bruce that keeping the generators namespace separate is desirable.

Show
Chas Emerick added a comment - +1 to making the properties bits available in clojure.test.check. I've never been a fan of using load to separate namespaces into different files; var immigration is another option that could work. I agree with Bruce that keeping the generators namespace separate is desirable.
Hide
Bruce Adams added a comment -

Merging core and properties is fine, but I like having the generators in a separate namespace.

The complex part of my uses of test.check have been building generators. Having a clear name space for generators helps make my code easier to read. Here are some trivially small examples from my code:

(ns whatever.generators
  (:require (clojure.test.check [generators :as gen])))

(def gen-non-blank-string
  (gen/such-that #(not-empty (.trim %)) gen/string))

(defn gen-nil-or
  [generator]
  (gen/one-of [(gen/return nil) generator]))

(defn gen-set
  [generator]
  (gen/fmap set (gen/vector generator)))
Show
Bruce Adams added a comment - Merging core and properties is fine, but I like having the generators in a separate namespace. The complex part of my uses of test.check have been building generators. Having a clear name space for generators helps make my code easier to read. Here are some trivially small examples from my code:
(ns whatever.generators
  (:require (clojure.test.check [generators :as gen])))

(def gen-non-blank-string
  (gen/such-that #(not-empty (.trim %)) gen/string))

(defn gen-nil-or
  [generator]
  (gen/one-of [(gen/return nil) generator]))

(defn gen-set
  [generator]
  (gen/fmap set (gen/vector generator)))
Hide
Nicola Mometto added a comment -

Put the ns decl in the main file and then simply clojure.core/load the different files.

Show
Nicola Mometto added a comment - Put the ns decl in the main file and then simply clojure.core/load the different files.
Hide
Reid Draper added a comment -

I'd still like to keep them as separate files, if we do this. Any easy way to do that? Just declare the same namespace in each file?

Show
Reid Draper added a comment - I'd still like to keep them as separate files, if we do this. Any easy way to do that? Just declare the same namespace in each file?
Hide
Peter Taoussanis added a comment -

+1 I'd definitely welcome merging the namespaces. Even merged, the lot would be < 1000 loc - and the core namespace isn't much use w/o the other two.

Show
Peter Taoussanis added a comment - +1 I'd definitely welcome merging the namespaces. Even merged, the lot would be < 1000 loc - and the core namespace isn't much use w/o the other two.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: