apl: Phase 3 reshape ⍴ / transpose ⍉ — 27/27 structural tests green
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

Add apl-reshape (dyadic ⍴, cycling), apl-transpose (monadic ⍉, reverse
axes), apl-transpose-dyadic (dyadic ⍉, permutation), plus helpers
apl-strides / apl-flat->multi / apl-multi->flat.

lib/apl/tests/structural.sx: 27 new tests covering ravel, reshape,
monadic/dyadic transpose across scalar/vector/matrix/3-D cases.

test.sh now runs structural.sx via its own inline framework (skips
stale tests/runtime.sx which targeted a pre-Phase-2 list-based API).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 18:36:43 +00:00
parent 2314735431
commit be26f77410
3 changed files with 289 additions and 4 deletions

View File

@@ -20,17 +20,22 @@ cat > "$TMPFILE" << 'EPOCHS'
(load "spec/stdlib.sx")
(load "lib/apl/runtime.sx")
(epoch 2)
(load "lib/apl/tests/runtime.sx")
(eval "(define apl-test-pass 0)")
(eval "(define apl-test-fail 0)")
(eval "(define apl-test-fails (list))")
(eval "(define (apl-test name got expected) (if (= got expected) (set! apl-test-pass (+ apl-test-pass 1)) (begin (set! apl-test-fail (+ apl-test-fail 1)) (set! apl-test-fails (append apl-test-fails (list {:name name :got got :expected expected}))))))")
(epoch 3)
(load "lib/apl/tests/structural.sx")
(epoch 4)
(eval "(list apl-test-pass apl-test-fail)")
EPOCHS
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
LINE=$(echo "$OUTPUT" | awk '/^\(ok-len 3 / {getline; print; exit}')
LINE=$(echo "$OUTPUT" | awk '/^\(ok-len 4 / {getline; print; exit}')
if [ -z "$LINE" ]; then
LINE=$(echo "$OUTPUT" | grep -E '^\(ok 3 \([0-9]+ [0-9]+\)\)' | tail -1 \
| sed -E 's/^\(ok 3 //; s/\)$//')
LINE=$(echo "$OUTPUT" | grep -E '^\(ok 4 \([0-9]+ [0-9]+\)\)' | tail -1 \
| sed -E 's/^\(ok 4 //; s/\)$//')
fi
if [ -z "$LINE" ]; then
echo "ERROR: could not extract summary"