feat(strictness): peek/pop/vec/key/val reject malformed args
- peek/pop are stack-only (vectors/lists): throw on sets/maps/strings/scalars, and pop throws on an empty vector/list - vec throws on non-seqable args (numbers/keywords/transients) - key/val require a map entry (2-element vector); throw on nil/numbers/maps/sets pop clean; peek 9/2; vec 17/2/1; key/val 12/2/1 (remaining are the 2-vector-vs-MapEntry / tuple-from-seq divergences). pass 3824->3840. spec: seq/accessor-strictness (16). jpm test green.
This commit is contained in:
parent
e7a58a0ed6
commit
b82477dac3
3 changed files with 38 additions and 13 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 3820)
|
||||
(def baseline-pass 3835)
|
||||
# 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;
|
||||
|
|
|
|||
|
|
@ -145,3 +145,23 @@
|
|||
["symbol from keyword" "\"x\"" "(name (symbol :x))"]
|
||||
["keyword bad 2-arg" :throws "(keyword \"abc\" nil)"]
|
||||
["keyword from symbol" "\"x\"" "(name (keyword 'x))"])
|
||||
|
||||
# Stack/accessor strictness: peek/pop are stack-only; vec needs a seqable;
|
||||
# key/val need a map entry.
|
||||
(defspec "seq / accessor strictness"
|
||||
["peek vector" "3" "(peek [1 2 3])"]
|
||||
["peek list" "1" "(peek '(1 2 3))"]
|
||||
["peek empty vec" "nil" "(peek [])"]
|
||||
["peek on set" :throws "(peek #{1 2})"]
|
||||
["peek on number" :throws "(peek 42)"]
|
||||
["pop empty vec" :throws "(pop [])"]
|
||||
["pop on number" :throws "(pop 0)"]
|
||||
["pop vector" "[1 2]" "(pop [1 2 3])"]
|
||||
["vec on number" :throws "(vec 42)"]
|
||||
["vec on keyword" :throws "(vec :a)"]
|
||||
["vec ok" "[1 2]" "(vec '(1 2))"]
|
||||
["key on nil" :throws "(key nil)"]
|
||||
["key on map" :throws "(key {})"]
|
||||
["val on number" :throws "(val 0)"]
|
||||
["key of entry" ":a" "(key (first {:a 1}))"]
|
||||
["val of entry" "1" "(val (first {:a 1}))"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue