js-on-sx: format Infinity/-Infinity/NaN per JS spec (+4 String)
js-number-to-string did (str n), which gives OCaml-native "inf"/"-inf"/ "nan"/"-nan" strings. JS spec requires "Infinity"/"-Infinity"/"NaN". Fix: cond-check js-number-is-nan, and =infinity-value first, fall through to (str n) for finite. Unit 521/522, slice 148/148 unchanged. String scoreboard: 34/100 → 38/100 (+4, S15.5.1.1_A1_T11/T12 family — String(1/0)/String(-1/0)/String(0/0)).
This commit is contained in:
@@ -1098,7 +1098,15 @@
|
|||||||
(+ i 1)
|
(+ i 1)
|
||||||
(str acc (js-to-string (nth parts i)))))))
|
(str acc (js-to-string (nth parts i)))))))
|
||||||
|
|
||||||
(define js-number-to-string (fn (n) (str n)))
|
(define
|
||||||
|
js-number-to-string
|
||||||
|
(fn
|
||||||
|
(n)
|
||||||
|
(cond
|
||||||
|
((js-number-is-nan n) "NaN")
|
||||||
|
((= n (js-infinity-value)) "Infinity")
|
||||||
|
((= n (- 0 (js-infinity-value))) "-Infinity")
|
||||||
|
(else (str n)))))
|
||||||
|
|
||||||
(define
|
(define
|
||||||
js-add
|
js-add
|
||||||
|
|||||||
Reference in New Issue
Block a user