|
9 | 9 | ;; Helpers for generating non-structural data. |
10 | 10 | ;; If you can't find what you need here, you can define your own helpers. |
11 | 11 |
|
12 | | -(def fn-any? (-> (h/fn any?) |
13 | | - (h/with-test-check-gen gen/any))) |
| 12 | +(def ^{:doc "A model that matches and generates anything."} |
| 13 | + fn-any? (-> (h/fn any?) |
| 14 | + (h/with-test-check-gen gen/any))) |
14 | 15 |
|
15 | | -(def fn-any-simple? (-> (h/fn any?) |
16 | | - (h/with-test-check-gen gen/simple-type))) |
| 16 | +(def ^{:doc "A model that matches anything and generates any scalar type."} |
| 17 | + fn-any-simple? (-> (h/fn any?) |
| 18 | + (h/with-test-check-gen gen/simple-type))) |
17 | 19 |
|
18 | | -(def fn-nil? (-> (h/fn nil?) |
19 | | - (h/with-test-check-gen (gen/return nil)))) |
| 20 | +(def ^{:doc "A model that matches and generates the nil value."} |
| 21 | + fn-nil? (-> (h/fn nil?) |
| 22 | + (h/with-test-check-gen (gen/return nil)))) |
20 | 23 |
|
21 | | -(def fn-boolean? (-> (h/fn boolean?) |
22 | | - (h/with-test-check-gen (gen/elements [false true])))) |
| 24 | +(def ^{:doc "A model that matches and generates booleans."} |
| 25 | + fn-boolean? (-> (h/fn boolean?) |
| 26 | + (h/with-test-check-gen (gen/elements [false true])))) |
23 | 27 |
|
24 | | -(def fn-int? (-> (h/fn int?) |
25 | | - (h/with-test-check-gen gen/nat))) |
| 28 | +(def ^{:doc "A model that matches and generates integers."} |
| 29 | + fn-int? (-> (h/fn int?) |
| 30 | + (h/with-test-check-gen gen/nat))) |
26 | 31 |
|
27 | | -(def fn-double? (-> (h/fn double?) |
28 | | - (h/with-test-check-gen gen/double))) |
| 32 | +(def ^{:doc "A model that matches and generates doubles."} |
| 33 | + fn-double? (-> (h/fn double?) |
| 34 | + (h/with-test-check-gen gen/double))) |
29 | 35 |
|
30 | | -(def fn-number? (-> (h/fn number?) |
31 | | - (h/with-test-check-gen (gen/one-of [gen/nat gen/double])))) |
| 36 | +(def ^{:doc "A model that matches any number and generates intergers and doubles."} |
| 37 | + fn-number? (-> (h/fn number?) |
| 38 | + (h/with-test-check-gen (gen/one-of [gen/nat gen/double])))) |
32 | 39 |
|
33 | | -(def fn-string? (-> (h/fn string?) |
34 | | - (h/with-test-check-gen gen/string-alphanumeric))) |
| 40 | +(def ^{:doc "A model that matches strings and generates alphanumeric strings."} |
| 41 | + fn-string? (-> (h/fn string?) |
| 42 | + (h/with-test-check-gen gen/string-alphanumeric))) |
35 | 43 |
|
36 | | -(def fn-symbol? (-> (h/fn symbol?) |
37 | | - (h/with-test-check-gen gen/symbol))) |
| 44 | +(def ^{:doc "A model that matches and generates symbols."} |
| 45 | + fn-symbol? (-> (h/fn symbol?) |
| 46 | + (h/with-test-check-gen gen/symbol))) |
38 | 47 |
|
39 | | -(def fn-keyword? (-> (h/fn keyword?) |
40 | | - (h/with-test-check-gen gen/keyword))) |
| 48 | +(def ^{:doc "A model that matches and generates keywords."} |
| 49 | + fn-keyword? (-> (h/fn keyword?) |
| 50 | + (h/with-test-check-gen gen/keyword))) |
41 | 51 |
|
42 | | -(def fn-keyword-ns? (-> (h/fn keyword?) |
43 | | - (h/with-test-check-gen gen/keyword-ns))) |
| 52 | +(def ^{:doc "A model that matches keywords and generates keywords with a namespace."} |
| 53 | + fn-keyword-ns? (-> (h/fn keyword?) |
| 54 | + (h/with-test-check-gen gen/keyword-ns))) |
44 | 55 |
|
45 | 56 |
|
46 | 57 |
|
|
54 | 65 | (recur (dec index) (next elements))))))) |
55 | 66 |
|
56 | 67 | ;; TODO: walk on :count-model and :condition-model nodes |
57 | | -(defn postwalk [model visitor] |
| 68 | +(defn ^:no-doc postwalk [model visitor] |
58 | 69 | (let [walk (fn walk [[stack walked-bindings] model path] |
59 | 70 | (let [[[stack walked-bindings] model] |
60 | 71 | (case (:type model) |
|
113 | 124 | :fn (:min-value count-model) |
114 | 125 | nil))))) |
115 | 126 |
|
116 | | -(defn assoc-leaf-distance-visitor |
| 127 | +(defn ^:no-doc assoc-leaf-distance-visitor |
117 | 128 | "Associate an 'distance to leaf' measure to each node of the model. |
118 | 129 | It is used as a hint on which path to choose when running out of budget |
119 | 130 | in a budget-based data generation. It's very useful as well to avoid |
|
154 | 165 | (cond-> model |
155 | 166 | (some? distance) (assoc ::leaf-distance distance)))) |
156 | 167 |
|
157 | | -(defn assoc-min-cost-visitor |
| 168 | +(defn ^:no-doc assoc-min-cost-visitor |
158 | 169 | "Associate an 'minimun cost' measure to each node of the model. |
159 | 170 | It is used as a hint during the budget-based data generation." |
160 | 171 | [model stack path] |
|
0 commit comments