feat(strictness): num/cons/realized?/symbol/keyword reject malformed args

- num throws on non-numbers (no longer coerces chars)
- cons throws when the second arg isn't seqable (a number/keyword/boolean/fn)
- realized? throws on non-IPending values (only delays/promises/lazy-seqs)
- symbol: 1-arg accepts string/symbol/keyword (->symbol), throws otherwise;
  2-arg requires string ns (nil ok) and string name
- keyword: (keyword nil) is nil, 1-arg accepts string/symbol/keyword, 2-arg
  requires string name and nil-or-string ns

keyword file clean; symbol 60/0/1; cons 18/1/1; realized? 25/1/0.
clojure-test-suite pass 3738->3781. spec: seq/strictness (13). jpm test green.
This commit is contained in:
Yogthos 2026-06-05 11:04:06 -04:00
parent 07d5b43fbb
commit fb36577ee7
3 changed files with 50 additions and 15 deletions

View file

@ -129,3 +129,19 @@
["conj map + map" "{:a 0, :b 1}" "(conj {:a 0} {:b 1})"]
["conj map + pair" "{:a 0, :b 1}" "(conj {:a 0} [:b 1])"]
["conj map merge wins" "{:a 2}" "(conj {:a 0} {:a 1} {:a 2})"])
# Strictness: these reject malformed arguments like Clojure.
(defspec "seq / strictness (throws like Clojure)"
["cons non-seqable num" :throws "(cons 1 42)"]
["cons non-seqable kw" :throws "(cons 1 :k)"]
["cons onto nil ok" "[1]" "(cons 1 nil)"]
["cons onto seq ok" "[0 1 2]" "(cons 0 [1 2])"]
["num non-number" :throws "(num \"x\")"]
["num ok" "5" "(num 5)"]
["realized? on number" :throws "(realized? 1)"]
["realized? on nil" :throws "(realized? nil)"]
["symbol from nil" :throws "(symbol nil)"]
["symbol bad 2-arg" :throws "(symbol :a \"b\")"]
["symbol from keyword" "\"x\"" "(name (symbol :x))"]
["keyword bad 2-arg" :throws "(keyword \"abc\" nil)"]
["keyword from symbol" "\"x\"" "(name (keyword 'x))"])