Skip to content

Extend direct test runner with array, while, and cross-module support#160

Open
tompassarelli wants to merge 2 commits into
vercel-labs:mainfrom
tompassarelli:test-runner-array-while-support
Open

Extend direct test runner with array, while, and cross-module support#160
tompassarelli wants to merge 2 commits into
vercel-labs:mainfrom
tompassarelli:test-runner-array-while-support

Conversation

@tompassarelli
Copy link
Copy Markdown

Summary

The direct-frontend test runner (zero test) currently supports basic expressions and simple unit tests but cannot evaluate integration tests that use arrays, while loops, or cross-module function calls. This means projects with richer test suites have most of their tests marked xfail.

This PR extends the test runner to handle:

  • Array literals and indexingEXPR_ARRAY_LITERAL, EXPR_INDEX, bounds checking, TEST_VALUE_ARRAY with deep copy/free/equality
  • While loops — with break/continue support and a 100k-iteration guard
  • Assignment — to simple variables, array elements (arr[i] = val), and shape fields (shape.field = val)
  • Borrow/cast passthroughEXPR_BORROW and EXPR_CAST evaluate to their inner expression (borrows are no-ops in the interpreter)
  • Choice variant resolutionFailureReason.dependency_cycle resolves to the variant's tag index
  • Mutref parameter writebackmutref<T> parameters propagate modifications back to the caller's environment after the function returns
  • Shape equality — field-by-field structural comparison

Impact

Tested against a workflow scheduler codebase with 49 tests (9 unit + 40 xfail integration): 19 of 40 previously-xfail tests now pass. The remaining 18 fail at assertion time (the test logic runs but produces incorrect results in complex multi-function scheduling scenarios — likely edge cases in cross-module state threading). No regressions on existing conformance tests.

Context

I've been building a typed workflow language called Beagle and was running cross-language benchmarks (Beagle vs Zero vs Python+mypy) to compare how type systems affect AI agent repair accuracy. The Zero track was blocked because zero test couldn't evaluate the integration test oracle — this PR unblocks that.

Test plan

  • make compiles cleanly with -Wall -Wextra -Wpedantic
  • All existing conformance/native/pass/ tests still pass
  • 19 previously-xfail integration tests now pass (cross-module scheduler tests)
  • No unexpected behavior on existing unit tests (12/12 pass)

The direct-frontend test runner now handles a broader set of Zero
language features, enabling integration tests that were previously
marked xfail to run and pass.

New capabilities:
- Array literals (EXPR_ARRAY_LITERAL) and indexing (EXPR_INDEX)
- While loops with break/continue and iteration guard
- Assignment to variables, array elements, and shape fields
- Borrow expressions (&x) and casts (passthrough in interpreted context)
- Choice/enum variant resolution (e.g. FailureReason.dependency_cycle)
- Mutable reference (mutref) parameter writeback to caller environment
- Array and shape equality comparison
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

@tompassarelli is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread native/zero-c/src/main.c
STMT_CONTINUE inside a nested block (e.g., if inside while) did not
propagate upward, so remaining statements in the loop body would still
execute. Add a separate `continued` flag that propagates through
nested blocks the same way `broke` does, and is consumed by the
while loop handler to restart the next iteration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant