From 67df95508defc043b5916113bcaf021106898a03 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 24 Apr 2026 12:39:06 +0000 Subject: [PATCH] js-on-sx: format Infinity/-Infinity/NaN per JS spec (+4 String) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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)). --- lib/js/runtime.sx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/js/runtime.sx b/lib/js/runtime.sx index 48a647d7..45b89225 100644 --- a/lib/js/runtime.sx +++ b/lib/js/runtime.sx @@ -1098,7 +1098,15 @@ (+ i 1) (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 js-add