Commits

Meikel Brandmeyer  committed dc234ef

Add max-elems option to data structure generators

  • Participants
  • Parent commits 7a4ccfb

Comments (0)

Files changed (1)

File src/main/clojure/clojurecheck/core.clj

   size guidance. The size guidance is passed verbatim to the
   item generator."
   {:added "2.0"}
-  [item & {:keys [length] :or {length (int)}}]
+  [item & {:keys [length max-elems] :or {length (int) max-elems 1000}}]
   (generators {len      length
-               elements (repeat item)}
+               elements (repeat max-elems item)}
     (take len elements)))
 
 (defn vec
   size guidance. The size guidance is passed verbatim to the item
   generator."
   {:added "2.0"}
-  [item & {:keys [length] :or {length (int)}}]
-  (generators {elems (list item :length length)}
+  [item & {:keys [length max-elems] :or {length (int) max-elems 1000}}]
+  (generators {elems (list item :length length :max-elems max-elems)}
     (clojure.core/vec elems)))
 
 (defn set
   size guidance. The size guidance is passed verbatim to the
   item generator."
   {:added "2.0"}
-  [item & {:keys [length] :or {length (int)}}]
-  (generators {elems (list item :length length)}
+  [item & {:keys [length max-elems] :or {length (int) max-elems 1000}}]
+  (generators {elems (list item :length length :max-elems max-elems)}
     (clojure.core/set elems)))
 
 (defn sorted-set
   size guidance. The size guidance is passed verbatim to the item
   generator."
   {:added "2.0"}
-  [item & {:keys [length] :or {length (int)}}]
-  (generators {elems (list item :length length)}
+  [item & {:keys [length max-elems] :or {length (int) max-elems 1000}}]
+  (generators {elems (list item :length length :max-elems max-elems)}
     (apply clojure.core/sorted-set elems)))
 
 (defn hash-map
   size guidance. The size guidance is passed verbatim to the key
   and value generators."
   {:added "2.0"}
-  [keys vals & {:keys [length] :or {length (int)}}]
+  [keys vals & {:keys [length max-elems] :or {length (int) max-elems 1000}}]
   (generators {len length
-               ks  (repeat keys)
-               vs  (repeat vals)}
+               ks  (repeat max-elems keys)
+               vs  (repeat max-elems vals)}
     (zipmap (take len ks) (take len vs))))
 
 (defn sorted-map
   size guidance. The size guidance is passed verbatim to the key and
   value generators."
   {:added "2.0"}
-  [keys vals & {:keys [length] :or {length (int)}}]
+  [keys vals & {:keys [length max-elems] :or {length (int) max-elems 1000}}]
   (generators {len length
-               ks  (repeat keys)
-               vs  (repeat vals)}
+               ks  (repeat max-elems keys)
+               vs  (repeat max-elems vals)}
     (apply clojure.core/sorted-map (interleave (take len ks) (take len vs)))))
 
 (defn string
   the size guidance. The size guidance is passed verbatim to the
   character generator."
   {:added "2.1"}
-  [characters & {:keys [length] :or {length (int)}}]
-  (generators {chs (list characters :length length)}
+  [characters & {:keys [length max-length] :or {length (int) max-length 1000}}]
+  (generators {chs (list characters :length length :max-elems max-length)}
     (apply str chs)))
 
 ;; ## Generator transformers