reduce dispatches to a reify's IReduceInit reduce method (jolt-z1zu)
(reduce f init (reify clojure.lang.IReduceInit (reduce [_ f i] ...))) tried to seq the reify and threw 'not seqable'. When the coll is a reify carrying a reduce method, drive the reduction through it. Corpus 2693->2694.
This commit is contained in:
parent
31a453d492
commit
f15a4e7747
2 changed files with 11 additions and 3 deletions
|
|
@ -11,7 +11,7 @@
|
||||||
;; reset between cases so there is no leakage — same isolation a fresh process gives.
|
;; reset between cases so there is no leakage — same isolation a fresh process gives.
|
||||||
;;
|
;;
|
||||||
;; chez --script host/chez/run-corpus.ss
|
;; chez --script host/chez/run-corpus.ss
|
||||||
;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2693)
|
;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2694)
|
||||||
;; JOLT_CORPUS_LIMIT=N every-Nth stride (fast iteration; floor drops to 0)
|
;; JOLT_CORPUS_LIMIT=N every-Nth stride (fast iteration; floor drops to 0)
|
||||||
;; JOLT_DUMP_CRASH_LABELS=1 list crash + allowlisted labels
|
;; JOLT_DUMP_CRASH_LABELS=1 list crash + allowlisted labels
|
||||||
(import (chezscheme))
|
(import (chezscheme))
|
||||||
|
|
@ -203,7 +203,7 @@
|
||||||
|
|
||||||
;; Regression floor: fail on any NEW divergence or if pass drops below the floor.
|
;; Regression floor: fail on any NEW divergence or if pass drops below the floor.
|
||||||
(define base-floor (let ((s (getenv "JOLT_CHEZ_ZJ_FLOOR")))
|
(define base-floor (let ((s (getenv "JOLT_CHEZ_ZJ_FLOOR")))
|
||||||
(if s (string->number s) 2693)))
|
(if s (string->number s) 2694)))
|
||||||
(define floor (if limit 0 base-floor))
|
(define floor (if limit 0 base-floor))
|
||||||
(when (or (> (length diverged) 0) (< pass floor))
|
(when (or (> (length diverged) 0) (< pass floor))
|
||||||
(printf "REGRESSION: pass ~a < floor ~a or ~a new divergence(s)\n"
|
(printf "REGRESSION: pass ~a < floor ~a or ~a new divergence(s)\n"
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,15 @@
|
||||||
((f coll) (let ((s (jolt-seq coll)))
|
((f coll) (let ((s (jolt-seq coll)))
|
||||||
(if (jolt-nil? s) (jolt-invoke f) ; (reduce f []) -> (f)
|
(if (jolt-nil? s) (jolt-invoke f) ; (reduce f []) -> (f)
|
||||||
(reduce-seq f (seq-first s) (jolt-seq (seq-more s))))))
|
(reduce-seq f (seq-first s) (jolt-seq (seq-more s))))))
|
||||||
((f init coll) (reduce-seq f init (jolt-seq coll)))))
|
((f init coll)
|
||||||
|
;; IReduceInit: a reify/record with its own `reduce` method drives the
|
||||||
|
;; reduction (reduce f init (reify clojure.lang.IReduceInit (reduce [_ f i] ...))).
|
||||||
|
(cond
|
||||||
|
((and (jreify? coll) (reified-methods coll)
|
||||||
|
(hashtable-ref (reified-methods coll) "reduce" #f))
|
||||||
|
=> (lambda (m) (let ((r (jolt-invoke m coll f init)))
|
||||||
|
(if (jolt-reduced? r) (jolt-reduced-val r) r))))
|
||||||
|
(else (reduce-seq f init (jolt-seq coll)))))))
|
||||||
|
|
||||||
(define (jolt-into to from) (reduce-seq (lambda (acc x) (jolt-conj1 acc x)) to (jolt-seq from)))
|
(define (jolt-into to from) (reduce-seq (lambda (acc x) (jolt-conj1 acc x)) to (jolt-seq from)))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue