feat(strictness): seq/shuffle/NaN?/nthrest/nthnext reject bad args
- seq throws on non-seqables (numbers/functions); collections/strings/nil ok - shuffle requires a collection (throws on numbers/strings/nil) - NaN? throws on non-numbers - nthrest/nthnext require a numeric count (nil count throws), clamp negative counts to the whole coll, and treat a nil coll as nil - update inherits assoc's vector bounds/keyword-key checks nan_qmark clean; shuffle 9/1; nthrest 13/1; nthnext 12/0/1; update 59/2/2. clojure-test-suite pass 3880->3889. spec: seq/strictness-round-3 (14). jpm test green.
This commit is contained in:
parent
f644b4b719
commit
6544d8ef44
3 changed files with 32 additions and 6 deletions
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
# Baseline: assertions Jolt currently passes across the suite. Raise as Jolt
|
||||
# improves so a regression (previously-passing assertion breaking) is caught.
|
||||
(def baseline-pass 3875)
|
||||
(def baseline-pass 3885)
|
||||
# A file is "clean" when it ran with zero failures AND zero errors.
|
||||
(def baseline-clean-files 45)
|
||||
# Per-file wall-clock budget (seconds). Normal files finish in well under 1s;
|
||||
|
|
|
|||
|
|
@ -179,3 +179,21 @@
|
|||
["assoc odd args" :throws "(assoc {:a 1} :b)"]
|
||||
["assoc on number" :throws "(assoc 5 :a 1)"]
|
||||
["assoc on set" :throws "(assoc #{} :a 1)"])
|
||||
|
||||
# Strictness on more core fns: seq/shuffle need seqables, NaN? needs a number,
|
||||
# nthrest/nthnext need a numeric count (and clamp negatives / accept nil coll).
|
||||
(defspec "seq / strictness round 3"
|
||||
["seq on number" :throws "(seq 1)"]
|
||||
["seq on fn" :throws "(seq (fn [] 1))"]
|
||||
["seq vector ok" "[1 2]" "(seq [1 2])"]
|
||||
["NaN? on nil" :throws "(NaN? nil)"]
|
||||
["NaN? on number ok" "false" "(NaN? 1.0)"]
|
||||
["shuffle on number" :throws "(shuffle 1)"]
|
||||
["shuffle on string" :throws "(shuffle \"abc\")"]
|
||||
["shuffle vec ok" "3" "(count (shuffle [1 2 3]))"]
|
||||
["nthrest nil count" :throws "(nthrest [0 1 2] nil)"]
|
||||
["nthrest negative" "[0 1 2]" "(nthrest [0 1 2] -1)"]
|
||||
["nthrest nil coll" "nil" "(nthrest nil 0)"]
|
||||
["nthnext nil count" :throws "(nthnext [0 1 2] nil)"]
|
||||
["update vec oob" :throws "(update [] 1 identity)"]
|
||||
["update vec kw key" :throws "(update [1 2 3] :k identity)"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue