This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-19
Channels
- # admin-announcements (2)
- # aws-lambda (3)
- # beginners (66)
- # boot (61)
- # cider (1)
- # cljs-dev (17)
- # clojure (100)
- # clojure-austin (4)
- # clojure-brasil (1)
- # clojure-canada (8)
- # clojure-quebec (6)
- # clojure-russia (48)
- # clojure-sg (6)
- # clojure-spec (37)
- # clojure-uk (61)
- # clojure-ukraine (2)
- # clojurescript (80)
- # core-async (13)
- # cursive (20)
- # datascript (37)
- # datomic (2)
- # defnpodcast (4)
- # emacs (5)
- # funcool (3)
- # hoplon (11)
- # jobs (7)
- # juxt (26)
- # lein-figwheel (48)
- # leiningen (3)
- # luminus (3)
- # om (34)
- # om-next (5)
- # onyx (5)
- # protorepl (6)
- # re-frame (10)
- # reagent (9)
- # rethinkdb (16)
- # ring-swagger (5)
- # spacemacs (14)
- # specter (54)
- # untangled (36)
- # vim (75)
- # yada (1)
@seancorfield: any reason you're not using create-ns
there?
yeah, create-ns
is equally valid
@borkdude: I just lifted that code from the example @alexmiller pointed us all to 🙂
Remind me: is there an easy way to create a generator based on a regular expression string?
@gfredericks: Looks like I could use test.chuck
for this? Although it says it doesn’t support anchors (yet)?
seancorfield: yes and yes; are you using nontrivial anchors or just the ^...$ sort of thing?
I can't remember if supporting general anchors was just a bit messy or if it was Really Hard the way backreferences &c. are
or maybe backreferences are easier but lookahead/behind are hard
man it's been a while
I’m only using #"^…$"
I can lift out the string between as a separate regex for generation if need be.
that's exactly what I've done
when in a similar position
seancorfield: do you need the anchors there? e.g., re-matches
already only matches the whole string
I can change how it’s used (from re-find
to re-matches
).
I think I was using anchors because prismatic/schema required them
Looks like it doesn’t handle a pattern like [^\s]
correctly maybe? I get spaces in the generated strings...
that sure oughta work
the thing is Surprisingly Robust™
if it can't handle something it should throw an exception when you try to create the generator
if you can share the regex I can try to reproduce
Sure… let me test something smaller...
Ah, no, it’s doing the right thing… that generated data is not what it seems 😐 Let me try something else...
What appeared to be a space is actually the character for decimal code 55335 (!) so it looks like we’re good. Excellent!
speaking of which I'd love to hear if anybody has any thoughts about string generators and unicode
there are a couple test.check tickets about it and I have no idea what the best idea as
s/as/is/
it's a question of what a reasonable distribution is
boot.user> (s/exercise ::m/email)
(["\"\"@[897.7.55.01]" "\"\"@[897.7.55.01]"] ["\"\"@R.V.zZl" "\"\"@R.V.zZl"] ["\"瘞\"@[562.0.2.073]" "\"瘞\"@[562.0.2.073]"] ["\"\"@[8.158.2.927]" "\"\"@[8.158.2.927]"] ["\"ƾ\"@4stFz.Tkc43.gZ4j.HRs-.mYf.VbC" "\"ƾ\"@4stFz.Tkc43.gZ4j.HRs-.mYf.VbC"] ["\"\"@[5.32.7.10]" "\"\"@[5.32.7.10]"] ["\"\"@[67.50.40.3]" "\"\"@[67.50.40.3]"] ["𰥽퐎..㳍.....@[6.9.905.824]" "𰥽퐎..㳍.....@[6.9.905.824]"] ["@9B.bCokjbO.6CJq2iCzy.cwIz" "@9B.bCokjbO.6CJq2iCzy.cwIz"] ["\"𢌎𪇤\"@[447.0.87.53]" "\"𢌎𪇤\"@[447.0.87.53]"])
emails are pairs?
exercise
produces pairs
Here’s the regex
(def email-regex
"Sophisticated regex for validating an email address."
(-> (str "(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|"
"(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|"
"(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))")
re-pattern))
those are some really good email addresses
(I don’t remember where we got that from and, yes, I know you can’t really validate email addresses correctly with "just" a regex but this has been pretty good for us so far)
But I’m very impressed that I could just throw that at test.chuck
and it worked right out of the box!