diff --git a/host/chez/printing.ss b/host/chez/printing.ss index 2187c69..22796ec 100644 --- a/host/chez/printing.ss +++ b/host/chez/printing.ss @@ -28,11 +28,11 @@ (define (jolt-pr-readable x) (cond ((string? x) (string-append "\"" (jolt-str-escape x) "\"")) - ;; pr renders the infinities / NaN long-form (Clojure .toString), at every - ;; nesting level — unlike the -e printer's inf/-inf/nan. - ((and (flonum? x) (fl= x +inf.0)) "Infinity") - ((and (flonum? x) (fl= x -inf.0)) "-Infinity") - ((and (flonum? x) (not (fl= x x))) "NaN") + ;; pr renders the infinities / NaN in READABLE form (##Inf reads back), unlike + ;; str's "Infinity"/"-Infinity"/"NaN". Applies at every nesting level. + ((and (flonum? x) (fl= x +inf.0)) "##Inf") + ((and (flonum? x) (fl= x -inf.0)) "##-Inf") + ((and (flonum? x) (not (fl= x x))) "##NaN") ;; transients print as a cold tagged type (print-method routes this through a ;; multimethod; the readable fallback renders it directly). ;; forward refs to transients.ss (loaded later) — resolved at call time. diff --git a/host/chez/rt.ss b/host/chez/rt.ss index 4cde04a..ee405b4 100644 --- a/host/chez/rt.ss +++ b/host/chez/rt.ss @@ -133,12 +133,12 @@ ;; without a ".0" ((* 1.0 5) prints as "5", (/ 1 2) as "0.5"). (define (jolt-num->string x) (cond - ;; the -e / element printer renders the infinities and NaN as inf/-inf/nan - ;; (Chez's number->string gives +inf.0 etc.); the str/print family uses the - ;; long "Infinity"/"NaN" forms (see jolt-str-render-one in converters.ss). - ((and (flonum? x) (fl= x +inf.0)) "inf") - ((and (flonum? x) (fl= x -inf.0)) "-inf") - ((and (flonum? x) (not (fl= x x))) "nan") + ;; the -e / element printer renders the infinities and NaN in READABLE form + ;; (##Inf reads back, like Clojure's REPL/pr); str/print uses "Infinity"/"NaN" + ;; (see jolt-str-render-one in converters.ss). + ((and (flonum? x) (fl= x +inf.0)) "##Inf") + ((and (flonum? x) (fl= x -inf.0)) "##-Inf") + ((and (flonum? x) (not (fl= x x))) "##NaN") ((and (rational? x) (integer? x)) (number->string (exact x))) (else (number->string x)))) diff --git a/host/chez/run-corpus.ss b/host/chez/run-corpus.ss index 1ae6b16..471dcf3 100644 --- a/host/chez/run-corpus.ss +++ b/host/chez/run-corpus.ss @@ -11,7 +11,7 @@ ;; reset between cases so there is no leakage — same isolation a fresh process gives. ;; ;; chez --script host/chez/run-corpus.ss -;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2695) +;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2698) ;; JOLT_CORPUS_LIMIT=N every-Nth stride (fast iteration; floor drops to 0) ;; JOLT_DUMP_CRASH_LABELS=1 list crash + allowlisted labels (import (chezscheme)) @@ -93,11 +93,11 @@ "^Type tag on var" "symbol hint -> :tag" "lists extended type" "seq of tags" "close on throw" "macroexpand-1" "ns-imports empty user" - "bean is the map" "proxy resolves nil" "unchecked-char" + "bean is the map" "proxy resolves nil" "*in* is bound" "*in* bound" "bigdec" "bigdec int M" "bigdec suffix M" "transient vector" "transient map" - "atom override fires nested" "inf inside coll" "pr-str Infinity" + "atom override fires nested" "defmethod overrides a record, top level" "defmethod fires nested in a map" "defmethod fires through prn" "direct builtin override" "methods table inspectable" @@ -203,7 +203,7 @@ ;; Regression floor: fail on any NEW divergence or if pass drops below the floor. (define base-floor (let ((s (getenv "JOLT_CHEZ_ZJ_FLOOR"))) - (if s (string->number s) 2695))) + (if s (string->number s) 2698))) (define floor (if limit 0 base-floor)) (when (or (> (length diverged) 0) (< pass floor)) (printf "REGRESSION: pass ~a < floor ~a or ~a new divergence(s)\n" diff --git a/host/chez/seed/prelude.ss b/host/chez/seed/prelude.ss index 0f9e9a7..fe710b3 100644 --- a/host/chez/seed/prelude.ss +++ b/host/chez/seed/prelude.ss @@ -561,7 +561,7 @@ (guard (e (#t #f)) (def-var! "clojure.core" "unchecked-short" (letrec ((unchecked-short (lambda (x) (let fnrec918 ((x x)) (jolt-invoke (var-deref "clojure.core" "bit-and") (jolt-invoke (var-deref "clojure.core" "int") x) 65535))))) unchecked-short))) (guard (e (#t #f)) - (def-var! "clojure.core" "unchecked-char" (letrec ((unchecked-char (lambda (x) (let fnrec919 ((x x)) (jolt-invoke (var-deref "clojure.core" "bit-and") (jolt-invoke (var-deref "clojure.core" "int") x) 65535))))) unchecked-char))) + (def-var! "clojure.core" "unchecked-char" (letrec ((unchecked-char (lambda (x) (let fnrec919 ((x x)) (jolt-invoke (var-deref "clojure.core" "char") (jolt-invoke (var-deref "clojure.core" "bit-and") (jolt-invoke (var-deref "clojure.core" "int") x) 65535)))))) unchecked-char))) (guard (e (#t #f)) (def-var! "clojure.core" "unchecked-float" (letrec ((unchecked-float (lambda (x) (let fnrec920 ((x x)) (jolt-invoke (var-deref "clojure.core" "double") x))))) unchecked-float))) (guard (e (#t #f)) diff --git a/jolt-core/clojure/core/20-coll.clj b/jolt-core/clojure/core/20-coll.clj index d814eab..2efc187 100644 --- a/jolt-core/clojure/core/20-coll.clj +++ b/jolt-core/clojure/core/20-coll.clj @@ -1072,12 +1072,11 @@ (defn to-array-2d [coll] (to-array (map to-array coll))) ;; Masking integer coercions (not aliases): byte/short wrap to their width. -;; unchecked-char keeps jolt's historical NUMBER result (Clojure returns a -;; char) — the char wrapper is a different value type here. int handles chars, -;; so (unchecked-byte \a) works as on the JVM. +;; unchecked-byte/short truncate to a number; unchecked-char returns a char (as on +;; the JVM). int handles chars, so (unchecked-byte \a) works. (defn unchecked-byte [x] (bit-and (int x) 0xff)) (defn unchecked-short [x] (bit-and (int x) 0xffff)) -(defn unchecked-char [x] (bit-and (int x) 0xffff)) +(defn unchecked-char [x] (char (bit-and (int x) 0xffff))) (defn unchecked-float [x] (double x)) (defn unchecked-double [x] (double x))