Skip to content

test: property tests for staging stability and strictness #114

Description

@iljakuklic

Background

The staging literature specifies two testable correctness properties of the staging pass, neither of which the snapshot suite covers explicitly:

  • Stability: staging is the identity on splice-free code — unstaging a program whose code defs contain no splices (and no meta references) must reproduce it verbatim.
  • Strictness: staging performs no object-level computation — object redexes present in the input (lets, matches on literals, primitive applications in object code) must survive to the output unchanged.

The current implementation appears to satisfy both (eval_obj is structural), but nothing pins that down: a future "optimization" that constant-folds or inlines during eval_obj would silently violate strictness — and destroy user control over generated code size — without failing any test.

Proposal

  • Unit/integration tests: stage splice-free programs and assert output ≡ input (alpha-equality); stage programs with deliberate object redexes (let x = 1; x, match 0 { ... }, 1 + 1 in object code) and assert the redexes are preserved.
  • Optionally a bolero fuzz target: generate splice-free object programs, assert unstage(p) == p (stability is a cheap universally-quantified oracle).

Constant folding / simplification, if ever wanted, belongs in a separate explicit pass after staging, not in the staging evaluator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions