test(spec): numbers, strings, predicates — fix variadic <, seq?, index-of
Add spec suites for numbers/arithmetic, strings (str + clojure.string), and type/value predicates. Bugs they caught and fixed: - <, >, <=, >= were binary-only; now variadic ((< 1 2 3) chains) - seq? was true for vectors; vectors are not ISeq in Clojure, so (seq? [1]) is now false (true only for lists/lazy-seqs) - clojure.string/index-of and last-index-of were 1-based (stray inc); now 0-based per Clojure Corrected a systematic-coverage assertion that encoded the old seq? bug. jpm test green, conformance 218/218.
This commit is contained in:
parent
b353d625f1
commit
68d6b1d6c1
6 changed files with 178 additions and 12 deletions
33
test/spec/strings-spec.janet
Normal file
33
test/spec/strings-spec.janet
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Specification: strings (str + clojure.string).
|
||||
(use ../support/harness)
|
||||
|
||||
(defspec "string / str & basics"
|
||||
["str concat" "\"abc\"" "(str \"a\" \"b\" \"c\")"]
|
||||
["str of numbers" "\"12\"" "(str 1 2)"]
|
||||
["str nil is empty" "\"\"" "(str nil)"]
|
||||
["str mixed" "\"a1:b\"" "(str \"a\" 1 :b)"]
|
||||
["str of coll" "\"[1 2]\"" "(str [1 2])"]
|
||||
["count" "3" "(count \"abc\")"]
|
||||
["subs from" "\"bc\"" "(subs \"abc\" 1)"]
|
||||
["subs range" "\"b\"" "(subs \"abc\" 1 2)"]
|
||||
["string? true" "true" "(string? \"x\")"]
|
||||
["seq of string" "[\\a \\b]" "(seq \"ab\")"])
|
||||
|
||||
(defspec "clojure.string"
|
||||
["join" "\"a,b,c\"" "(do (require (quote [clojure.string :as s])) (s/join \",\" [\"a\" \"b\" \"c\"]))"]
|
||||
["join no sep" "\"abc\"" "(do (require (quote [clojure.string :as s])) (s/join [\"a\" \"b\" \"c\"]))"]
|
||||
["split" "[\"a\" \"b\"]" "(do (require (quote [clojure.string :as s])) (s/split \"a,b\" #\",\"))"]
|
||||
["split-lines" "[\"a\" \"b\"]" "(do (require (quote [clojure.string :as s])) (s/split-lines \"a\\nb\"))"]
|
||||
["upper-case" "\"ABC\"" "(do (require (quote [clojure.string :as s])) (s/upper-case \"abc\"))"]
|
||||
["lower-case" "\"abc\"" "(do (require (quote [clojure.string :as s])) (s/lower-case \"ABC\"))"]
|
||||
["capitalize" "\"Abc\"" "(do (require (quote [clojure.string :as s])) (s/capitalize \"abc\"))"]
|
||||
["trim" "\"x\"" "(do (require (quote [clojure.string :as s])) (s/trim \" x \"))"]
|
||||
["triml" "\"x \"" "(do (require (quote [clojure.string :as s])) (s/triml \" x \"))"]
|
||||
["blank? true" "true" "(do (require (quote [clojure.string :as s])) (s/blank? \" \"))"]
|
||||
["blank? false" "false" "(do (require (quote [clojure.string :as s])) (s/blank? \"x\"))"]
|
||||
["includes?" "true" "(do (require (quote [clojure.string :as s])) (s/includes? \"hello\" \"ell\"))"]
|
||||
["starts-with?" "true" "(do (require (quote [clojure.string :as s])) (s/starts-with? \"hello\" \"he\"))"]
|
||||
["ends-with?" "true" "(do (require (quote [clojure.string :as s])) (s/ends-with? \"hello\" \"lo\"))"]
|
||||
["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\"))"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue