This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-21
Channels
- # admin-announcements (1)
- # announcements (6)
- # babashka (8)
- # beginners (134)
- # calva (18)
- # chlorine-clover (1)
- # cider (6)
- # circleci (6)
- # clj-commons (111)
- # cljsrn (13)
- # clojure (95)
- # clojure-australia (2)
- # clojure-europe (15)
- # clojure-nl (1)
- # clojure-spec (52)
- # clojure-uk (17)
- # clojurescript (4)
- # datavis (9)
- # datomic (8)
- # docker (2)
- # emacs (15)
- # events (7)
- # fulcro (6)
- # graphql (1)
- # gratitude (1)
- # introduce-yourself (2)
- # kaocha (8)
- # meander (87)
- # minecraft (2)
- # music (2)
- # off-topic (20)
- # portal (119)
- # releases (1)
- # reveal (55)
- # shadow-cljs (34)
- # sql (36)
- # tools-deps (9)
- # vim (8)
- # xtdb (39)
is there ever a situation where the :ret value passed to a (failing) fdef :fn checker would diverge from the value you get when you run the function in question with the associated :args manually ?
these are the reported values:
:cljs.spec.alpha/value
{:args {:maps ({:A/A ""} {:A/A ""})}, :ret {:A/A " "}},
I think unless it’s being conformed into that different value it will be the same. You could try doing:
(s/conform (:ret (s/get-spec `your-function)) {:A/A ""})
as a sanity check to make sure your spec isn’t changing it during conforming.could this be a bug in clojure spec ? it is in alpha after all. @U064X3EF3 ?
sorry, can you re-explain?
is there ever a situation where the :ret value passed to a (failing) fdef :fn checker would diverge from the value you get when you run the function in question with the associated :args manually ?
these are the reported values:
:cljs.spec.alpha/value
{:args {:maps ({:A/A ""} {:A/A ""})}, :ret {:A/A " "}},
this is the manual repl invocation of the function in question:
utils.utils=> (-merge-attribs '({:A/A ""} {:A/A ""}))
{:A/A ""}
the manual repl invocation is the "correct" oneNotice that the one reported by spec includes a \space and the one returned from the manual invocation is merely the empty string.
it seems like you're asking me a question about your function, not spec
maybe there is more here than you can "see" - that "empty" string could have a Unicode non-breaking space or something in it
or zero-width space, whatever that weird unicode thing is
in general, my answer to your original question is no (unless you're using spec :stub instrumentation or something)
spec says that for some input a specific return value is returned. when i run that function manually in the repl with the exact same input a different value is returned.
a 1-character string with a Unicode zero-width space character looks like an empty string
not those
well, that's one I've had this problem with. there are probably others
hehe 🙂 too bad https://clojuredocs.org/clojure.core/char-escape-string doesn't exist in cljs (although seems that wouldn't cover all of these anyway)
you add a debug in your :fn function to print the count of the input strings or map char etc
I'm just guessing here - this is a possible answer that matches what I see, but you should validate
these kinds of things happen with generative tests :)
might be worth thinking about how to better report string values (adding perhaps unicode escapes for these as well as the platform default escapes)