core: move the pure-leaf fns to the overlay; memfn is a real macro now

Round 3 of the seed shrink. To the overlay: identity, constantly, neg?,
even?, odd? (20-coll, ahead of their first in-tier uses), not= and unreduced
(00-syntax — the kernel and seq tiers use them), ==, ensure-reduced,
halt-when, parse-boolean, parse-uuid, newline, seque, array-seq, to-array-2d,
and the masking unchecked-byte/short/char/float/double coercions. parse-uuid
validates via re-matches over a new __make-uuid host binding (overlay source
can't write :jolt/type map literals). memfn moves to 30-macros as a working
macro over the .method call sugar instead of a fn that throws.

Behavior fixes toward Clojure, each with spec rows: == now throws on
non-numbers instead of comparing them, and halt-when is the canonical
::halt-map version (the halt value replaces the whole reduction result, no
double completion). list? and map-entry? stay in the seed — both are
representation-coupled (plist/tuple checks).

clojure-test-suite goes 4701 -> 4700: update.cljc expects
(update {:k 1} :k identity 1 2 3 4) to throw an arity error, and jolt fns
don't enforce fixed arity anywhere (pre-existing, language-wide — the seed's
Janet identity threw natively). Filed as jolt-6xn; fixing it should flip
several suite rows at once.
This commit is contained in:
Yogthos 2026-06-11 12:38:12 -04:00
parent 65687c69ae
commit 7ca88ab2b5
7 changed files with 154 additions and 84 deletions

View file

@ -192,3 +192,15 @@
["num passes a number through" "5" "(num 5)"]
["num on a double" "5.5" "(num 5.5)"]
["num throws on non-number" :throws "(num \"x\")"])
# == is numeric equality: single arg is trivially true (Clojure's 1-arity
# never inspects the value); 2+ args must be numbers.
(defspec "numbers / == numeric equality"
["== single arg" "true" "(== :a)"]
["== equal" "true" "(== 2 2)"]
["== unequal" "false" "(== 2 3)"]
["== chained" "true" "(== 2 2 2)"]
["== chained unequal" "false" "(== 2 2 3)"]
["== int and double" "true" "(== 1 1.0)"]
["== throws on non-number" :throws "(== 1 :a)"]
["== throws on two keywords" :throws "(== :a :a)"])

View file

@ -28,6 +28,19 @@
["eduction" "[2 3 4]" "(into [] (eduction (map inc) [1 2 3]))"]
["completing" "9" "(transduce (map inc) (completing +) 0 [1 2 3])"])
# halt-when replaces the WHOLE reduction result with the halting input (or
# with (retf acc input)) — Clojure's ::halt map protocol, unwrapped by the
# transducer's completion arity.
(defspec "transducers / halt-when"
["halt returns the halting input" "7"
"(transduce (halt-when (fn [x] (> x 5))) conj [1 2 7 3])"]
["no halt is a plain reduction" "[1 2 3]"
"(transduce (halt-when (fn [x] (> x 5))) conj [1 2 3])"]
["retf combines acc and input" "[[1 2] 7]"
"(transduce (halt-when (fn [x] (> x 5)) (fn [r i] [r i])) conj [1 2 7 3])"]
["halt-when through into" "3"
"(into [] (halt-when odd?) [2 4 3 6])"])
# A `take`/`take-while` transducer returns `reduced`, which must short-circuit
# the reduction so transducing over an INFINITE seq terminates rather than
# realizing it eagerly.

View file

@ -114,7 +114,11 @@
["update-proxy" "nil" "(update-proxy nil {})"]
["proxy-mappings" "{}" "(proxy-mappings nil)"]
["proxy-call-with-super calls" "1" "(proxy-call-with-super (fn [] 1) nil \"m\")"]
["memfn throws" :throws "((memfn count) \"abc\")"]
["memfn upper" "\"ABC\"" "((memfn toUpperCase) \"abc\")"]
["memfn with args" "2" "((memfn indexOf needle) \"hello\" \"l\")"]
["memfn length" "3" "((memfn length) \"abc\")"]
["array-seq" "(quote (1 2 3))" "(array-seq (to-array [1 2 3]))"]
["array-seq empty" "nil" "(array-seq (to-array []))"]
["proxy-super throws" :throws "(proxy-super count [1])"]
["re-groups throws" :throws "(re-groups (re-matcher #\"a\" \"b\"))"]
["re-matcher builds" "false" "(nil? (re-matcher #\"a\" \"abc\"))"]