Skip to content

Expand the corpus to cover every accepted grammar shape#81

Merged
StreamDemon merged 1 commit into
feature/parser-enhancements-basefrom
feature/parser-enh-corpus
Jul 2, 2026
Merged

Expand the corpus to cover every accepted grammar shape#81
StreamDemon merged 1 commit into
feature/parser-enhancements-basefrom
feature/parser-enh-corpus

Conversation

@StreamDemon

@StreamDemon StreamDemon commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds six corpus fixtures covering the accepted grammar shapes that had none (crates/AGENTS.md rule: "add corpus tests for every grammar shape accepted"):
    • extern_onchain.spextern "C" (plain + async string-target), extern onchain mod, top-level onchain enum, onchain mod with a storage block.
    • casts_literals.spas cast chains, based integer literals with separators/suffixes (0xFF_FFu32, 0b1010_1010u8, u128/u256), float exponents (2.5e-3, 1e10f64), string escapes (\x41, \u{1F600}), char literals, lifetimes in generic params and reference types.
    • async_await.spasync fn, .await, .await?, ? chains outside pipes, .context(...).
    • modules_use.sp — inline/file modules, use with brace lists, pub use re-export, contextual crate/super path heads.
    • attributes.sp — bare markers, derive lists, named args (@supervisor(strategy: "one_for_one", ...)), actor-handler @mailbox(capacity: 2048).
    • expressions.sp — struct literals (value position, shorthand init, nesting, parenthesized block-head escape), boolean/comparison operators.
  • The harness now discovers tests/corpus/*.sp instead of maintaining a hard-coded list, so a new fixture cannot be silently skipped; an is-empty guard catches a moved or emptied corpus directory. Discovery is sorted for deterministic ordering.

Sixth and final sub-PR of the enhancement wave (PR #71 roadmap: "Corpus expansion for all accepted shapes"). Runs last so the fixtures exercise the wave's final code (span tokens, operator enums, attribute args).

Related Issue

None (PR #71 roadmap item).

Spec Sections Affected

None — tests only. Fixtures deliberately stay inside the parser's accepted subset documented in crates/AGENTS.md (no match/while/for/closures/spawn/emit, no unit-expression (), block-statement ; rule respected).

Checklist

  • Code follows the Sploosh design principles (one way to do it, explicit over implicit, etc.)
  • Documentation updated in relevant docs/ pages — N/A, tests only
  • Tests added or updated
  • All build targets still compile (if applicable)
  • Spec-only PR (skip Build Targets section if checked)

Build Targets Tested

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace all green locally (54 tests, 13 corpus fixtures).

Test Plan

  • parses_corpus_files discovers and parses all 13 fixtures (7 existing + 6 new); every fixture parses clean on the wave's final parser.

Summary by cubic

Add six new corpus fixtures to cover every accepted grammar shape and switch the test harness to auto-discover all .sp files. Improves parser coverage and prevents new fixtures from being skipped.

  • New Features

    • Added corpus files: extern_onchain.sp, casts_literals.sp, async_await.sp, modules_use.sp, attributes.sp, expressions.sp.
    • Covers: extern/onchain modules and enums, casts and numeric/string/char literals, async/await and ?, modules/use and re-exports, attributes with named args, struct literals and boolean/comparison ops.
  • Refactors

    • Test harness now discovers tests/corpus/*.sp (no hard-coded list) and sorts paths for deterministic runs.
    • Added an is-empty guard to fail if the corpus directory is missing or empty.

Written for commit bbed8be. Summary will update on new commits.

Review in cubic

The crates/AGENTS.md rule is "add corpus tests for every grammar shape
accepted", but extern blocks, onchain modules, use trees, casts, the
literal zoo, async/.await, `?` outside pipes, attribute arguments, and
struct-literal shapes had no fixtures. Six new fixtures close those
gaps.

The harness now discovers `tests/corpus/*.sp` instead of maintaining a
hard-coded list, so a new fixture cannot be silently skipped; an
is-empty guard catches a moved or emptied corpus directory.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Test-only PR: adds six corpus fixtures covering grammar shapes and switches harness to auto-discovery. No production code changes.

Re-trigger cubic

@StreamDemon StreamDemon merged commit 4f25344 into feature/parser-enhancements-base Jul 2, 2026
2 checks passed
@StreamDemon StreamDemon deleted the feature/parser-enh-corpus branch July 2, 2026 11:46
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