This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-12
Channels
- # announcements (2)
- # beginners (104)
- # cider (2)
- # cljs-dev (26)
- # cljsrn (1)
- # clojure (125)
- # clojure-dev (27)
- # clojure-italy (24)
- # clojure-nl (24)
- # clojure-russia (4)
- # clojure-spec (10)
- # clojure-uk (83)
- # clojurescript (18)
- # code-reviews (102)
- # community-development (14)
- # core-async (18)
- # cryogen (11)
- # cursive (15)
- # datomic (16)
- # emacs (6)
- # figwheel-main (6)
- # fulcro (142)
- # graphql (5)
- # jobs (5)
- # jobs-discuss (18)
- # kaocha (1)
- # keechma (1)
- # leiningen (20)
- # luminus (1)
- # mount (5)
- # pedestal (4)
- # reagent (17)
- # reitit (8)
- # shadow-cljs (29)
- # tools-deps (19)
- # vim (108)
#clojure-spec - hi all, could you help me understand why
(inst? (t/date-time 1986 10 14))
=> false
@ariel.silverman (class (t/date-time 1986 10 14))
would be some third-party Joda time thing, which isn't in scope of the inst?
predicate
Yes, t -> https://github.com/clj-time/clj-time
@ferossgp @schmee - fair enough. How do I sample a joda time thing then?
#clojure-spec - I was hoping to ask for some help generating samples for clj-time/date-time since I am currently interested in testing my spec and using the spec as a generator for unit tests. Can anyone spare a couple minutes to help or point me out to some resource that can assist me in this goal?
something like this should get you going:
(ns foo
(:require [clojure.spec :as s]
[clojure.spec.gen :as gen]
[clojure.test.check.generators :as tg]))
[clj-time.coerce :as c]
(def epoch-2000-01-01 946684800)
(def epoch-2100-01-01 4102444800)
(def date-range
(tg/large-integer* {:min epoch-2000-01-01 :max epoch-2100-01-01}))
(s/def ::timestamp
(s/spec nat-int?
:gen #(tg/fmap #(c/from-long %) (tg/large-integer* {:min epoch-2000-01-01 :max epoch-2100-01-01})))
@schmee Thank you! Actually I was looking into leveraging the specs specified here as part of my spec definition: https://github.com/clj-time/clj-time/blob/master/src/clj_time/spec.clj
I was able to require the namespace clj-time.spec and now I am trying to figure out how to do the dynamic binding of *period*
@ariel.silverman I have a one around for that, sec…
@schmee Thank you! Actually I was looking into leveraging the specs specified here as part of my spec definition: https://github.com/clj-time/clj-time/blob/master/src/clj_time/spec.clj