Skip to main content

wasmsh_testkit/
lib.rs

1//! Test utilities, TOML test runner, and compatibility harness for wasmsh.
2//!
3//! This crate provides:
4//! - `runner`: TOML-based declarative test runner
5//! - `toml_case`: Test case schema (serde-deserializable)
6//! - `features`: Feature gate registry
7//! - `oracle`: Reference shell comparison (opt-in)
8//! - `compat`: Legacy compatibility case format
9
10pub mod compat;
11pub mod features;
12pub mod oracle;
13pub mod runner;
14pub mod toml_case;
15
16/// Parse source and assert it produces a valid AST (no parse errors).
17pub fn assert_parses(source: &str) {
18    wasmsh_parse::parse(source).expect("expected successful parse");
19}
20
21/// Parse source and assert it produces a parse error.
22pub fn assert_parse_error(source: &str) {
23    assert!(
24        wasmsh_parse::parse(source).is_err(),
25        "expected parse error for: {source:?}"
26    );
27}
28
29/// Parse source, lower to HIR, and return the HIR program.
30pub fn parse_and_lower(source: &str) -> wasmsh_hir::HirProgram {
31    let ast = wasmsh_parse::parse(source).expect("parse failed");
32    wasmsh_hir::lower(&ast)
33}