Skip to content

Commit a084db6

Browse files
committed
Added the models gen/fn-simple-symbol, gen/fn-qualified-symbol, gen/fn-simple-keyword and gen/fn-qualified-keyword.
1 parent 372422b commit a084db6

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Versions prior to v0.1.0 are considered experimental, their API may change.
99

1010
### Added
1111
- this changelog file.
12+
- the models `gen/fn-simple-symbol`, `gen/fn-qualified-symbol`,
13+
`gen/fn-simple-keyword` and `gen/fn-qualified-keyword`.
14+
15+
### Changed
16+
- the models `gen/fn-symbol`, `gen/fn-keyword` now generate qualified symbols and keywords,
1217

1318
## [0.0.3] - 2020-07-26
1419

src/minimallist/generator.cljc

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,37 @@
3333
fn-double? (-> (h/fn double?)
3434
(h/with-test-check-gen gen/double)))
3535

36-
(def ^{:doc "A model that matches any number and generates intergers and doubles."}
36+
(def ^{:doc "A model that matches any number and generates integers and doubles."}
3737
fn-number? (-> (h/fn number?)
3838
(h/with-test-check-gen (gen/one-of [gen/nat gen/double]))))
3939

4040
(def ^{:doc "A model that matches strings and generates alphanumeric strings."}
4141
fn-string? (-> (h/fn string?)
4242
(h/with-test-check-gen gen/string-alphanumeric)))
4343

44-
(def ^{:doc "A model that matches and generates symbols."}
44+
(def ^{:doc "A model that matches and generates symbols with or without a namespace."}
4545
fn-symbol? (-> (h/fn symbol?)
46-
(h/with-test-check-gen gen/symbol)))
46+
(h/with-test-check-gen (gen/one-of [gen/symbol gen/symbol-ns]))))
4747

48-
(def ^{:doc "A model that matches and generates keywords."}
48+
(def ^{:doc "A model that matches and generates symbols without a namespace."}
49+
fn-simple-symbol? (-> (h/fn simple-symbol?)
50+
(h/with-test-check-gen gen/symbol)))
51+
52+
(def ^{:doc "A model that matches and generates symbols with a namespace."}
53+
fn-qualified-symbol? (-> (h/fn qualified-symbol?)
54+
(h/with-test-check-gen gen/symbol-ns)))
55+
56+
(def ^{:doc "A model that matches and generates keywords with or without a namespace."}
4957
fn-keyword? (-> (h/fn keyword?)
50-
(h/with-test-check-gen gen/keyword)))
58+
(h/with-test-check-gen (gen/one-of [gen/keyword gen/keyword-ns]))))
59+
60+
(def ^{:doc "A model that matches and generates keywords without a namespace."}
61+
fn-simple-keyword? (-> (h/fn simple-keyword?)
62+
(h/with-test-check-gen gen/keyword)))
5163

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)))
64+
(def ^{:doc "A model that matches and generates keywords with a namespace."}
65+
fn-qualified-keyword? (-> (h/fn qualified-keyword?)
66+
(h/with-test-check-gen gen/keyword-ns)))
5567

5668

5769

test/minimallist/generator_test.cljc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
[minimallist.core :refer [valid?]]
66
[minimallist.helper :as h]
77
[minimallist.util :as util]
8-
[minimallist.generator :as mg :refer [gen fn-any? fn-int? fn-string? fn-keyword?]]))
8+
[minimallist.generator :as mg :refer [gen fn-any? fn-int? fn-string?
9+
fn-symbol? fn-simple-symbol? fn-qualified-symbol?
10+
fn-keyword? fn-simple-keyword? fn-qualified-keyword?]]))
911

1012
(defn- path-test-visitor []
1113
;; Testing using side effects.
@@ -338,6 +340,14 @@
338340

339341
(tcg/sample (gen (h/repeat 5 10 fn-int?)))
340342

343+
(tcg/sample (gen fn-symbol?))
344+
(tcg/sample (gen fn-simple-symbol?))
345+
(tcg/sample (gen fn-qualified-symbol?))
346+
347+
(tcg/sample (gen fn-keyword?))
348+
(tcg/sample (gen fn-simple-keyword?))
349+
(tcg/sample (gen fn-qualified-keyword?))
350+
341351
#__)
342352

343353
(deftest gen-test

0 commit comments

Comments
 (0)