Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env planck -D org.clojure/test.check:0.10.0-alpha2 -K
- (ns generate-calls
- (:require [clojure.spec.alpha :as s]
- [clojure.test.check.generators :as gen])
- (:require-macros [clojure.test.check.generators :as gen]))
- (s/def ::direction #{"inbound" "outbound"})
- (s/def ::duration pos-int?)
- (s/def ::id pos-int?)
- (s/def ::agent_id (s/with-gen pos-int? #(s/gen (set (range 10)))))
- (s/def ::group_id (s/with-gen pos-int? #(s/gen (set (range 3)))))
- (s/def ::start_time (s/int-in 0 (-> (js/Date.) .getTime)))
- (s/def ::end_time (s/int-in 0 (-> (js/Date.) .getTime)))
- (def call-no-constraints-map (s/keys :req-un [::direction ::duration ::agent_id ::group_id ::id ::start_time ::end_time]))
- (defn call-gen []
- (gen/let [e (s/gen call-no-constraints-map)
- duration (s/gen (s/int-in 1 3600))]
- (assoc e :end_time (+ (:start_time e) duration)
- :duration duration)))
- (s/def ::call (s/with-gen call-no-constraints-map call-gen))
- (let [argv1 (first *command-line-args*)]
- (dotimes [i (if argv1 (js/parseInt argv1) 1000000)]
- (println (.stringify js/JSON (clj->js (assoc (gen/generate (s/gen ::call)) :id i))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement