feat(strictness): numeric ops reject non-numbers/non-integers like Clojure
- zero?/pos?/neg? throw on non-numbers; odd?/even? throw on non-integers (nil, infinities, NaN, fractional) via need-num/need-int helpers - comparisons < > <= >= throw on non-number args (1-arity stays true, no check) - max/min throw on non-number args - quot/rem/mod throw on zero divisor and non-finite operands odd?/even?/lt/gt/lt_eq/gt_eq suite files now clean; pass 3691->3738. Updated systematic-coverage-test (zero? nil now throws). spec: numbers/strictness (15). jpm test green.
This commit is contained in:
parent
4238ec745b
commit
07d5b43fbb
5 changed files with 50 additions and 15 deletions
|
|
@ -59,7 +59,8 @@
|
|||
(let [ctx (init)]
|
||||
(assert (= true (ct-eval ctx "(zero? 0)")) "zero? 0")
|
||||
(assert (= false (ct-eval ctx "(zero? 1)")) "zero? 1")
|
||||
(assert (= false (ct-eval ctx "(zero? nil)")) "zero? nil")
|
||||
# zero?/pos?/neg? now reject non-numbers (Clojure-strict), like the JVM.
|
||||
(assert (not ((protect (ct-eval ctx "(zero? nil)")) 0)) "zero? nil throws")
|
||||
(assert (= true (ct-eval ctx "(pos? 1)")) "pos?")
|
||||
(assert (= false (ct-eval ctx "(pos? 0)")) "pos? 0")
|
||||
(assert (= false (ct-eval ctx "(pos? -1)")) "pos? -1")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue