Fork me on GitHub
#clojure-spec
<
2017-06-21
>
bbrinck02:06:22

Is multi-spec intended to work with the :default implementation of the multimethod?

bbrinck02:06:41

i.e. is it intended that I could use the :default implementation to provide a default spec? https://gist.github.com/bhb/7eefe3034a0622b6499a5b5dd2f7e52a

Alex Miller (Clojure team)04:06:38

yes, this should work (it does in Clojure)

Alex Miller (Clojure team)04:06:26

so, that's a bug in cljs spec

Alex Miller (Clojure team)04:06:53

actually, that's already been fixed if you update your cljs version

bbrinck15:06:48

@alexmiller Ah, shoot, I should have checked JIRA. Thanks for the info!!!

royalaid18:06:40

Is there a currently recommended way to integrate clojure.specs generative testing with clojure.test?

carocad09:06:18

royalaid: I wrote a similar macro for fdef which is basically a simplification of that one. Here it is:

(defmacro defspec-test
  ([name sym-or-syms] `(defspec-test ~name ~sym-or-syms nil))
  ([name sym-or-syms opts]
   `(t/deftest ~name
      (let [check-results#  (clojure.spec.test/check ~sym-or-syms ~opts)]
        (doseq [result# check-results#]
          (t/is (nil? (:failure result#)) (str (clojure.spec.test/abbrev-result result#)))
          (when (nil? (:failure result#))
            (println "[OK] - " (clojure.spec.test/abbrev-result result#))))))))

royalaid18:06:53

But it seems a bit hacky and the output on failure isn't very helpful

mattly19:06:07

@royalaid I can't speak to clojure.spec, but with test.check I use test.chuck, which has a macro checking that behaves similar to testing

mattly19:06:24

I'd link you to it except slack's electron app decided I can't use my clipboard anymore

sneakypeet19:06:40

Hi all. started using spec in cljs today. I am running into a weird issue

(ns tenandsix.app.flow
  (:require-macros [cljs.spec :as s])
  (:require  [cljs.spec :as spec]))

(s/def :flow/action-type keyword?) => works
(s/def :flow/action (s/tuple keyword? keyword?)) => No such namespace: s, could not locate s.cljs, s.cljc, or Closure namespace ""

dpsutton19:06:17

:flow vs :flo possibly?

sneakypeet19:06:12

no that was actually me testing if the keyword made a difference 🙂

sneakypeet19:06:22

but no that does not fix it

sneakypeet19:06:06

any thoughts? I mean this is as basic as it gets

dpsutton19:06:55

thoughts, perhaps s/tuple is a macro and the import macro statement is malformed

dpsutton19:06:02

but only when actually trying to macroexpand

dpsutton19:06:00

looks like tuple is a macro

sneakypeet19:06:08

so actually. it works, but my repl gives the error, when I use the spec it works

dpsutton19:06:24

i don't understand your statement

sneakypeet19:06:49

I'll try again

dpsutton19:06:59

if you're on a recent cljs, it looks like you no longer need a require-macros part

dpsutton19:06:03

try just requiring spec

sneakypeet19:06:21

1. evaluating that actually creates the spec

sneakypeet19:06:39

2. I can use the spec

sneakypeet19:06:55

3. It gives the error when I create the spec

sneakypeet19:06:25

checking the link

sneakypeet19:06:18

@dpsutton thanks your link helped

sneakypeet19:06:51

thats a pretty big improvement

adamfrey21:06:54

what's the cleanest way to make a generator that constantly returns the same value? Similar to constantly in core?

adamfrey21:06:46

I came up with this, which works. I just wanted to make sure I wasn't missing an easier way

#(gen/fmap (constantly 1)
       (gen/int))

gfredericks21:06:56

probably with an extra # in a spec context