Source the conformance corpus from JVM Clojure; retire the prelude gate
corpus.edn :expected is now the value reference JVM Clojure produces, set by the new test/conformance/regen-corpus.clj (one JVM process, per-row thread watchdog). 167 rows moved to the JVM value: ratios (/ 1 2)=>1/2, doubles (double 3)=>3.0, shared-heap concurrency (the future/pmap/agent cases), clojure.math doubles. The JVM is the spec; jolt is measured against it. known-divergences.edn shrinks to the rows whose JVM value is an opaque host object that can't round-trip to source (Java arrays, transients, atoms, beans, proxies, chunks all print as #object[..@addr]) plus (fn* foo) and a few racy concurrency cases (:flaky). The zero-janet gate's allowlist becomes the set of host gaps vs the JVM spec (no Class/array/BigDecimal, :jolt reader, jolt's own printing). Math/clojure.math sqrt/pow/floor/trig now return doubles (Chez returns exact for exact args, e.g. (sqrt 9)=>3); JVM always returns a double. extract-corpus.janet no longer writes corpus.edn unless asked (the test runner imported it and was silently overwriting the JVM corpus with the spec sources' placeholder answers). The prelude parity gate is deleted — the zero-janet spine + certify.clj are the oracles. zero-janet 2678 (0 new divergences), certify 0 new / 0 stale, emit-test 330/330.
This commit is contained in:
parent
467ad75ff7
commit
da775802d6
13 changed files with 435 additions and 823 deletions
|
|
@ -1,9 +1,7 @@
|
|||
;; converters + string ops (jolt-t6cr) — host-coupled seed natives the Chez host
|
||||
;; must provide; def-var!'d into clojure.core, resolved in prelude mode. Loaded
|
||||
;; last (after jolt-pr-str), since `str` reuses the printer. Semantics match the
|
||||
;; Janet seed (core_print.janet str-render-one, core_io.janet core-compare,
|
||||
;; core_refs.janet int/double). jolt is all-flonum, so numeric results are
|
||||
;; flonums (int truncates toward zero, compare returns -1.0/0.0/1.0).
|
||||
;; converters + string ops — host-coupled natives def-var!'d into clojure.core,
|
||||
;; resolved in prelude mode. Loaded last (after jolt-pr-str), since `str` reuses
|
||||
;; the printer. int/long truncate toward zero to an exact integer; compare returns
|
||||
;; an exact -1/0/1; double yields a flonum.
|
||||
|
||||
;; str: nil -> "", string raw, char bare (not \c), regex -> raw source, else the
|
||||
;; printer (which renders collections with readable elements).
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
;; dynamic vars (jolt-9ls5) — the handful of clojure.core dynamic vars the seed
|
||||
;; binds natively (src/jolt/core.janet) that aren't emitted into the prelude, so
|
||||
;; they var-deref to nil on Chez. These two are plain constants; *ns* (a namespace
|
||||
;; object) needs a value type with get-see-through and map?=false and is tracked
|
||||
;; separately. Loaded from rt.ss after the value model + def-var!.
|
||||
;; dynamic vars — the handful of clojure.core dynamic vars that aren't emitted into
|
||||
;; the prelude. These two are plain constants; *ns* (a namespace object) needs a
|
||||
;; value type with get-see-through and map?=false and is tracked separately. Loaded
|
||||
;; from rt.ss after the value model + def-var!.
|
||||
|
||||
;; *clojure-version* — a jolt map {:major 1 :minor 11 :incremental 0 :qualifier nil}
|
||||
;; (jolt is all-flonum, so the numbers are flonums).
|
||||
;; *clojure-version* — a map {:major 1 :minor 11 :incremental 0 :qualifier nil}.
|
||||
(def-var! "clojure.core" "*clojure-version*"
|
||||
(jolt-hash-map (keyword #f "major") 1
|
||||
(keyword #f "minor") 11
|
||||
|
|
|
|||
|
|
@ -122,22 +122,26 @@
|
|||
(define (char-code c) (if (char? c) (char->integer c) (jnum->exact c)))
|
||||
|
||||
;; ---- java.lang statics ------------------------------------------------------
|
||||
;; java.lang.Math: sqrt/pow/floor/ceil/trig/log/exp always return a DOUBLE on the
|
||||
;; JVM (Chez's sqrt/expt return EXACT for exact args, e.g. (sqrt 9) -> 3), so coerce
|
||||
;; to flonum. round -> long (exact); abs/max/min preserve the argument's type.
|
||||
(define (->dbl x) (exact->inexact x))
|
||||
(register-class-statics! "Math"
|
||||
(list (cons "sqrt" (lambda (x) (->num (sqrt x))))
|
||||
(cons "pow" (lambda (a b) (->num (expt a b))))
|
||||
(cons "floor" (lambda (x) (->num (floor x))))
|
||||
(cons "ceil" (lambda (x) (->num (ceiling x))))
|
||||
(cons "round" (lambda (x) (->num (round x))))
|
||||
(cons "abs" (lambda (x) (->num (abs x))))
|
||||
(cons "sin" (lambda (x) (->num (sin x)))) (cons "cos" (lambda (x) (->num (cos x))))
|
||||
(cons "tan" (lambda (x) (->num (tan x)))) (cons "asin" (lambda (x) (->num (asin x))))
|
||||
(cons "acos" (lambda (x) (->num (acos x)))) (cons "atan" (lambda (x) (->num (atan x))))
|
||||
(cons "log" (lambda (x) (->num (log x)))) (cons "log10" (lambda (x) (->num (/ (log x) (log 10)))))
|
||||
(cons "exp" (lambda (x) (->num (exp x))))
|
||||
(cons "max" (lambda (a b) (->num (if (> a b) a b)))) (cons "min" (lambda (a b) (->num (if (< a b) a b))))
|
||||
(list (cons "sqrt" (lambda (x) (->dbl (sqrt x))))
|
||||
(cons "pow" (lambda (a b) (->dbl (expt a b))))
|
||||
(cons "floor" (lambda (x) (->dbl (floor x))))
|
||||
(cons "ceil" (lambda (x) (->dbl (ceiling x))))
|
||||
(cons "round" (lambda (x) (exact (floor (+ x 1/2))))) ; JVM round-half-up -> long
|
||||
(cons "abs" (lambda (x) (abs x)))
|
||||
(cons "sin" (lambda (x) (->dbl (sin x)))) (cons "cos" (lambda (x) (->dbl (cos x))))
|
||||
(cons "tan" (lambda (x) (->dbl (tan x)))) (cons "asin" (lambda (x) (->dbl (asin x))))
|
||||
(cons "acos" (lambda (x) (->dbl (acos x)))) (cons "atan" (lambda (x) (->dbl (atan x))))
|
||||
(cons "log" (lambda (x) (->dbl (log x)))) (cons "log10" (lambda (x) (->dbl (/ (log x) (log 10)))))
|
||||
(cons "exp" (lambda (x) (->dbl (exp x))))
|
||||
(cons "max" (lambda (a b) (if (> a b) a b))) (cons "min" (lambda (a b) (if (< a b) a b)))
|
||||
(cons "signum" (lambda (x) (cond ((< x 0) -1.0) ((> x 0) 1.0) (else 0.0))))
|
||||
(cons "PI" (->num (* 4 (atan 1)))) (cons "E" (->num (exp 1)))
|
||||
(cons "random" (lambda args (->num (random 1.0))))))
|
||||
(cons "PI" (->dbl (* 4 (atan 1)))) (cons "E" (->dbl (exp 1)))
|
||||
(cons "random" (lambda args (random 1.0)))))
|
||||
|
||||
;; Thread: real OS threads back futures/promises (jolt-byjr), so sleep genuinely
|
||||
;; parks the calling thread for `ms` milliseconds (a worker sleeping doesn't block
|
||||
|
|
|
|||
|
|
@ -31,28 +31,32 @@
|
|||
(define (jolt-math-floor-div a b) (floor (/ a b)))
|
||||
(define (jolt-math-floor-mod a b) (- a (* b (floor (/ a b)))))
|
||||
|
||||
(def-var! "clojure.math" "sqrt" sqrt)
|
||||
;; clojure.math fns always return a DOUBLE; Chez's sqrt/expt/sin/floor/... return
|
||||
;; EXACT for exact args ((sqrt 9) -> 3, (sin 0) -> 0), so coerce.
|
||||
(define (m1 f) (lambda (x) (exact->inexact (f x))))
|
||||
(define (m2 f) (lambda (a b) (exact->inexact (f a b))))
|
||||
(def-var! "clojure.math" "sqrt" (m1 sqrt))
|
||||
(def-var! "clojure.math" "cbrt" jolt-math-cbrt)
|
||||
(def-var! "clojure.math" "pow" expt)
|
||||
(def-var! "clojure.math" "exp" exp)
|
||||
(def-var! "clojure.math" "pow" (m2 expt))
|
||||
(def-var! "clojure.math" "exp" (m1 exp))
|
||||
(def-var! "clojure.math" "expm1" (lambda (x) (- (exp x) 1.0)))
|
||||
(def-var! "clojure.math" "log" log)
|
||||
(def-var! "clojure.math" "log10" (lambda (x) (log x 10.0)))
|
||||
(def-var! "clojure.math" "log" (m1 log))
|
||||
(def-var! "clojure.math" "log10" (lambda (x) (exact->inexact (log x 10.0))))
|
||||
(def-var! "clojure.math" "log1p" (lambda (x) (log (+ 1.0 x))))
|
||||
(def-var! "clojure.math" "sin" sin)
|
||||
(def-var! "clojure.math" "cos" cos)
|
||||
(def-var! "clojure.math" "tan" tan)
|
||||
(def-var! "clojure.math" "asin" asin)
|
||||
(def-var! "clojure.math" "acos" acos)
|
||||
(def-var! "clojure.math" "atan" atan)
|
||||
(def-var! "clojure.math" "sin" (m1 sin))
|
||||
(def-var! "clojure.math" "cos" (m1 cos))
|
||||
(def-var! "clojure.math" "tan" (m1 tan))
|
||||
(def-var! "clojure.math" "asin" (m1 asin))
|
||||
(def-var! "clojure.math" "acos" (m1 acos))
|
||||
(def-var! "clojure.math" "atan" (m1 atan))
|
||||
;; clojure.math/atan2 is atan2(y, x); Chez's 2-arg atan is (atan y x).
|
||||
(def-var! "clojure.math" "atan2" (lambda (y x) (atan y x)))
|
||||
(def-var! "clojure.math" "sinh" sinh)
|
||||
(def-var! "clojure.math" "cosh" cosh)
|
||||
(def-var! "clojure.math" "tanh" tanh)
|
||||
(def-var! "clojure.math" "floor" floor)
|
||||
(def-var! "clojure.math" "ceil" ceiling)
|
||||
(def-var! "clojure.math" "rint" round)
|
||||
(def-var! "clojure.math" "atan2" (lambda (y x) (exact->inexact (atan y x))))
|
||||
(def-var! "clojure.math" "sinh" (m1 sinh))
|
||||
(def-var! "clojure.math" "cosh" (m1 cosh))
|
||||
(def-var! "clojure.math" "tanh" (m1 tanh))
|
||||
(def-var! "clojure.math" "floor" (m1 floor))
|
||||
(def-var! "clojure.math" "ceil" (m1 ceiling))
|
||||
(def-var! "clojure.math" "rint" (m1 round))
|
||||
(def-var! "clojure.math" "round" jolt-math-round)
|
||||
(def-var! "clojure.math" "signum" jolt-math-signum)
|
||||
(def-var! "clojure.math" "to-degrees" jolt-math-to-degrees)
|
||||
|
|
|
|||
|
|
@ -73,11 +73,9 @@
|
|||
;; jolt models EVERY number as a double (emit-const lowers integer literals to
|
||||
;; flonums too), so the reader coerces every parsed number to inexact — else a
|
||||
;; read int (exact) is not jolt= to a source int literal (flonum).
|
||||
;; Preserve exactness for the Chez numeric tower (JVM parity): integer literals
|
||||
;; read as exact integers (= Long/BigInt, arbitrary precision), a/b ratios as
|
||||
;; exact rationals (= Ratio), and decimal/exponent literals as flonums (= double).
|
||||
;; Only the zero-Janet path (this reader) carries exactness through to runtime;
|
||||
;; the Janet-reader prelude path stays all-flonum (Janet has only doubles).
|
||||
;; Numeric tower (JVM parity): integer literals read as exact integers (= Long/
|
||||
;; BigInt, arbitrary precision), a/b ratios as exact rationals (= Ratio), and
|
||||
;; decimal/exponent literals as flonums (= double).
|
||||
(define (rdr-try-number tok)
|
||||
(rdr-try-number-raw tok))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue