Another interesting side effect of this project is that I’ve always considered Clojure(script) to be rock solid. But when you start poking at the corner cases…
made PR for swap!
and reset!
merged.
I’m a bit hesitant about the cleaning one.
I’m hesitant to removing :ret
specs
Even though speculative’s raison d’etre isn’t necessarily to test core, :ret
doesn’t hurt and it does aid wrt documentation.
So for =
the specs are useless in terms of better error messages, but useful (kind’a sort’a) doc purposes, as the spec is reflected in the docs.
@slipset I only removed a :ret any?
since this is a bit pointless
and removed some stale comments
and a duplicate fdef for =
I first posted some comments about (s/* any?)
-ish args specs, but I later removed them
if you expand the code a bit, it might be clearer why I removed the =
spec 😉
if you want I can revert the :ret
thing and we can discuss later
Ah! I see it now. D’oh!
Thanks for seeing that!
👍
I wonder how the coal-mine adventure turned out, did it run?
I didn't let coal-mine run all the way through to completion, but after about an hour or two it had made it through about half of the problems successfully.
funny that sets are not associative?
they’re sort of maps with keys that map onto themselves?
Found another bug in spec or such which only manifests in planck
19:13 $ plk -A:test
ClojureScript 1.10.339
cljs.user=> (ns speculative.core
#_=> (:require [clojure.spec.alpha :as s]
#_=> [clojure.spec.test.alpha :as stest]))
nil
speculative.core=> (s/fdef clojure.core/assoc
#_=> :args (s/cat :map (s/nilable associative?) :key any? :val any? :kvs (s/* (s/cat :ks any? :vs any?)))
#_= #_=> :ret map?)
cljs.core/assoc
speculative.core=> (stest/instrument)
Vector's key for assoc must be a number.
cljs.core/-assoc [cljs.core/IAssociative] (cljs/core.cljs:5546:14)
cljs.core/-assoc (cljs/core.cljs:630:24)
cljs.core/apply-to (cljs/core.cljs:3845:1)
cljs.spec.test.alpha/c (cljs/spec/test/alpha.cljs:120:34)
cljs.spec.test.alpha/d (cljs/spec/test/alpha.cljs:114:29)
cljs.core/-assoc [cljs.core/IAssociative] (cljs/core.cljs:6621:6)
cljs.core/-assoc (cljs/core.cljs:630:24)
cljs.core/apply-to (cljs/core.cljs:3845:1)
cljs.spec.test.alpha/c (cljs/spec/test/alpha.cljs:120:34)
cljs.spec.test.alpha/d (cljs/spec/test/alpha.cljs:114:29)
cljs/lang/applyTo (cljs/core.cljs:1961:7)
cljs.spec.test.alpha/f (cljs/spec/test/alpha.cljs:113:16)
cljs.spec.alpha/rep* (cljs/spec/alpha.cljs:953:10)
cljs.spec.alpha/deriv (cljs/spec/alpha.cljs:1090:22)
cljs.spec.alpha/deriv (cljs/spec/alpha.cljs:1087:50)
cljs.spec.alpha/re-conform (cljs/spec/alpha.cljs:1211:17)
cljs.spec.alpha/conform* [cljs.spec.alpha/Spec] (cljs/spec/alpha.cljs:1252:10)
cljs.spec.alpha/conform* (cljs/spec/alpha.cljs:39:1)
cljs.spec.alpha/conform (cljs/spec/alpha.cljs:153:4)
cljs.spec.test.alpha/f (cljs/spec/test/alpha.cljs:110:39)
planck.pprint.width-adjust/generate-sample (planck/pprint/width_adjust.cljs:5:218)
planck.pprint.width-adjust/bisect (planck/pprint/width_adjust.cljs:7:302)
planck.pprint.width-adjust/adjusted-with (planck/pprint/width_adjust.cljs:11:143)
planck.pprint.width-adjust/d (planck/pprint/width_adjust.cljs:12:301)
planck.repl/print-value (planck/repl.cljs:1940:12)
cljs.core/e (cljs/core.cljs:4240:17)
cljs.js/B (cljs/js.cljs:1133:24)
cljs.js/eval-str* (cljs/js.cljs:1047:6)
planck.repl/process-execute-source (planck/repl.cljs:2003:11)
planck.repl/execute-source (planck/repl.cljs:2056:18)
planck.repl/execute (planck/repl.cljs:2065:7)
@mfikes can I get some output using the coal mine runner? I made an intentional bug in juxt:
(s/fdef clojure.core/juxt
:args (s/+ int? #_ifn?)
:ret fn?)
and I see it’s used in some code, but I’m not sure if it’s hitting that code@borkdude check out the coal-mine aliases in deps.edn
—they’ve been committed and merged in
@mfikes do you mean like clj -A:test:coal-mine-clj
? I have done that, but my CPU spins and I see no progress bar or anything.
I looked a bit into the source code of coal-mine and there seems to be something for this. I’m not sure how to activate that
You have to wait for a few hours
You can instead run a few test namespaces to see if things work. (The code is pretty straightforward, just start a REPL instead and run-tests
on a namespace.)
k
ah, now I see why my wrong juxt wasn’t catched. these puzzles try to re-implement juxt, but never call it… https://github.com/mfikes/coal-mine/blob/master/src/coal_mine/problem_59.cljc
🙂
@slipset The Planck issue you mentioned above might be similar to some of the other tickets logged where instrumenting a variadic function appears to offset the arguments. (It is interesting that it would only affect self-host, though.)
it’s sometimes triggered during instrumentation instead of during checking something
hmm, juxt is used in other places
@borkdude Problem 168 uses juxt in its tests: https://github.com/mfikes/coal-mine/blob/master/src/coal_mine/checks.cljc#L1607-L1608
I’m running this, but no catch:
:main-opts ["-e" "(require,'speculative.core,'clojure.spec.test.alpha)"
"-e" "(clojure.spec.test.alpha/instrument)"
"-e" "(require,'coal-mine.checks)"
"-e" "(require,'clojure.test)"
"-e" "(clojure.test/run-tests,'coal-mine.checks)"
]
it doesn’t even catch this when I insert it in between: "-e" "(juxt,1)"
my bad, it does catch a mistake, I just changed the juxt spec to
(s/fdef clojure.core/juxt
:args (s/+ int? #_ifn?)
:ret fn?)
so on "-e" "(juxt,identity)"
it complainsbut still doesn’t catch the call in coal-mine it seems
$ clj -A:test:coal-mine-clj
[clojure.core/remove clojure.core// clojure.core/reduce clojure.core/first clojure.core/= clojure.core/every? clojure.core/some clojure.core/merge clojure.core/some? clojure.core/str clojure.core/count clojure.core/apply clojure.core/filter clojure.core/not-any? clojure.core/not-every? clojure.core/reset! clojure.core/juxt clojure.core/map clojure.core/merge-with clojure.core/fnil clojure.core/swap!]
Testing coal-mine.checks
Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
{:test 0, :pass 0, :fail 0, :error 0, :type :summary}
cool, with
:main-opts ["-e" "(require,'speculative.core,'clojure.spec.test.alpha)"
"-e" "(clojure.spec.test.alpha/instrument)"
"-e" "(require,'coal-mine.problem-171)"
"-e" "(require,'clojure.test)"
"-e" "(clojure.test/run-tests,'coal-mine.problem-171)"
]
I get an error:
actual: clojure.lang.ExceptionInfo: Call to #'clojure.core/juxt did not conform to spec.
coal-mine.checks
isn't actually a test namespace... it is a utility namespace included by the test namespaces
yeah but with 168 I didn’t get an error either