fix: print Infinity/-Infinity/NaN like Clojure (str and pr-str)

Numbers printed via Janet's (string v) rendered infinities/NaN as inf/-inf/nan.
Add fmt-number so str/pr-str (and collection rendering) emit Infinity/-Infinity/
NaN. str.cljc 3->32 pass. Remaining str fails are the integer-valued-double
divergence ((str 0.0) is "0" not "0.0" since 0.0 == 0 in Janet).

spec: numbers/printing-of-inf-&-nan (5). jpm test green.
This commit is contained in:
Yogthos 2026-06-05 10:23:57 -04:00
parent bcdace7543
commit a4d9d5f70b
3 changed files with 20 additions and 3 deletions

View file

@ -90,6 +90,13 @@
["exponent" "1000.0" "1e3"]
["exponent neg" "0.015" "1.5e-2"])
(defspec "numbers / printing of inf & nan"
["str Infinity" "\"Infinity\"" "(str ##Inf)"]
["str -Infinity" "\"-Infinity\"" "(str ##-Inf)"]
["str NaN" "\"NaN\"" "(str ##NaN)"]
["pr-str Infinity" "\"Infinity\"" "(pr-str ##Inf)"]
["inf inside coll" "\"[Infinity]\"" "(str [##Inf])"])
(defspec "numbers / bit-ops & math"
["bit-and" "4" "(bit-and 12 6)"]
["bit-or" "14" "(bit-or 12 6)"]