feat(strictness): subs validates bounds; assoc! bounds-checks vector index
- subs requires a string and validates 0<=start<=end<=count (no Janet from-end/clamping); negative/out-of-range/nil indices throw - assoc! on a transient vector bounds-checks the index (0..count) subs 11-fail -> 24/5 (5 remaining are byte-vs-codepoint Unicode, platform); assoc_bang 32/6 -> 35/3. clojure-test-suite pass 3889->3898. spec: string/subs-strictness (7), transient/assoc!-bounds (4). jpm test green.
This commit is contained in:
parent
6544d8ef44
commit
740b50aef3
4 changed files with 35 additions and 6 deletions
|
|
@ -33,3 +33,13 @@
|
|||
["replace" "\"hexxo\"" "(do (require (quote [clojure.string :as s])) (s/replace \"hello\" \"l\" \"x\"))"]
|
||||
["reverse" "\"cba\"" "(do (require (quote [clojure.string :as s])) (s/reverse \"abc\"))"]
|
||||
["index-of" "2" "(do (require (quote [clojure.string :as s])) (s/index-of \"hello\" \"l\"))"])
|
||||
|
||||
# subs validates bounds like Clojure (no Janet from-end/clamping).
|
||||
(defspec "string / subs strictness"
|
||||
["subs basic" "\"bcd\"" "(subs \"abcde\" 1 4)"]
|
||||
["subs to end" "\"cde\"" "(subs \"abcde\" 2)"]
|
||||
["subs start>end" :throws "(subs \"abcde\" 2 1)"]
|
||||
["subs negative" :throws "(subs \"abcde\" -1)"]
|
||||
["subs end past len" :throws "(subs \"abcde\" 1 6)"]
|
||||
["subs nil start" :throws "(subs \"abcde\" nil 2)"]
|
||||
["subs on nil" :throws "(subs nil 1 2)"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue