This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-25
Channels
- # aws (2)
- # bangalore-clj (2)
- # beginners (90)
- # boot (89)
- # bristol-clojurians (1)
- # cider (23)
- # cljs-dev (48)
- # cljsjs (2)
- # cljsrn (3)
- # clojure (118)
- # clojure-argentina (3)
- # clojure-austin (8)
- # clojure-czech (1)
- # clojure-dev (18)
- # clojure-ireland (1)
- # clojure-italy (4)
- # clojure-russia (6)
- # clojure-spec (75)
- # clojure-uk (224)
- # clojurescript (103)
- # core-async (28)
- # cursive (3)
- # datascript (7)
- # datomic (15)
- # dirac (30)
- # emacs (14)
- # events (3)
- # figwheel (1)
- # hispano (1)
- # hoplon (176)
- # lambdaisland (1)
- # lein-figwheel (6)
- # off-topic (21)
- # om (7)
- # onyx (2)
- # pedestal (6)
- # re-frame (4)
- # reagent (15)
- # spacemacs (67)
- # specter (13)
- # testing (9)
- # untangled (65)
- # vim (6)
- # yada (1)
@alexmiller i think you could get 90% of the way there with a smaller change than a custom stylesheet - Safari etc’s reader mode is broken on the current site b/c div#preamble doesn’t match div.sect1
i think that if you just make all the seconds have the same class, then reader modes will treat it all as body text and that’s a de facto print mode
most of that did not actually mean anything to me :)
each page in the reference has multiple divs, but only the first div shows up if you use an article reading filter
I’m like a monkey banging rocks together in web programming
you on a mac? go to any reference page in safari and you’ll see a little paragraph icon in the top left corner of the url bar
but since the “preamble” in the generated pages have different structure and style classes applied, only that first section gets treated as body text
so just some tweaks might fix that
ok, if I get a chance I’ll see if I can muggle my way through it
is that a font?
sadly, no rock emoji
specifically, change the div with class clj-content-container
from div
to article
- and see if that does it
i abuse reader mode and use huge fonts for most stuff i read 🙂 i have good eye sight and hope to keep it that way!
I match my font size to my age
@alexmiller could you take a look at this and confirm if I'm using instrument
correctly or if there might actually be an underlying issue with :gen
https://gist.github.com/luxbock/ecb263750f61cc6fab7a736e5bd96008
I will take a look in the morning
Maybe this is silly but say I have a spec like this (s/def ::dog (s/keys ::req [::name ::type ::sound]))
but I also want to include a key that's always something specific like :feet 4
- so if I generate that I'll get like {:name "red" :type "golden retriever" :sound "woofwoof" :feet 4}
I want to do something like this:
(defmulti dog-type :dog/type)
(defmethod dog-type :golden-retriever [_]
(s/keys :req [::name ::sound]))
But also have in the keys a type key that is dog-type and the actual key.Is it possible to use spec to validate maps that has keys that are not namespaced, like :name instead of :user/name?
@teng Yes, with :req-un
and :opt-un
. Although they require namespaced keys for the specs, the actual map keys are unqualified.
(see the guide for more details)
ok, thx.
@nick Do you mean you'd want (s/def ::feet #{4})
as the spec for the :feet
key?
(clojure.spec/explain string? 123)
val: 123 fails predicate: :clojure.spec/unknown
How can I get the predicate to show string?
@odinodin I think you need to do (s/def ::string? string)
and then you can (s/explain ::string? 123)
This unknown is a bug that has a pending patch btw
So that will work eventually
@alexmiller that is awesome 🙂
@luxbock I agree that I’d expect something like this to work. I did just notice this line in the instrument docs though: ":gen overrides are used only for :stub generation.” which honestly surprises me. it seems like they should be used also for instrumented :args gen too.
although maybe you should really be passing those :gen overrides in your call to check
yeah, you should move your gen overrides map from instrument into the check options map. also, in the :gen map, the values should be no-arg functions that return the generator, not the actual generator, so just prefix all of them with #
to turn them into anonymous no-arg functions
once I did that, it was running, but I started getting OOMEs
to address that, I narrowed the collection generators which default to max size 20. I added :gen-max 3
to both the fdef :args spec and the ::operations
override gen.
@alexmiller ah yeah I think I tried :gen
with check but I didn't realize that I need to wrap them in thunks
Then it worked
these days I generally preemptively add :gen-max 3
to all collection specs reachable by fdef :args or used in recursion
I think it would be a good idea to change the default there from 20 to 3
if you’d like to vote :)
it feels that all the spec related testing functionality one needs to write these types of tests is quite spread out, both in terms of namespaces and where the different options for customizing the generators go
nothing that a good utility library won't fix, but I have a hard time keeping in my head where everything is supposed to come from and how it ties together
well the stuff in spec vs spec.test is intentionally split to emphasize the parts that are designed specifically for testing. and spec.gen is the same - split out the part that dynamically loads and depends on test.check generators.
those are at this point pretty well factored in my mind
the gen overrides stuff is a bit messier and not consistent enough between s/exercise, stest/instrument, stest/check etc and we may still make some changes in those
I'm writing code which I can't fully test in use until it hits the production server so I'm trying to cover as many edge cases as possible with spec and generative tests to avoid the long feedback loop of deploy + test, and it's definitely giving me a lot more confidence in that I got rid of most of the silly bugs before trying it in actual use
cool, that’s good to hear
@ag (s/and int? pos-int? #(< % 100)
but once you start going there, consider integer ranges
(s/int-in 1 100)
the range specs come with a better generator by default
ah, right… thanks @alexmiller