diff options
| author | Henry <mail@henrygressmann.de> | 2026-07-22 21:28:35 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-07-22 21:28:35 +0200 |
| commit | b484f2bc074dab2419245ec2443f60efd33b80f0 (patch) | |
| tree | 04c5a7ee1391b3ccb7fa836acc9eb3bf774c1088 /crates/cli/src/wast_runner.rs | |
| parent | 1d754813f178fc92afffe43e3ab638ddfc03cb66 (diff) | |
chore: update deps, fix clippy warnings, add wast ModuleDefinition
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/cli/src/wast_runner.rs')
| -rw-r--r-- | crates/cli/src/wast_runner.rs | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/crates/cli/src/wast_runner.rs b/crates/cli/src/wast_runner.rs index 3c0a1cd..99f1efe 100644 --- a/crates/cli/src/wast_runner.rs +++ b/crates/cli/src/wast_runner.rs @@ -219,7 +219,7 @@ impl WastRunner { let span = directive.span(); use wast::WastDirective::{ AssertExhaustion, AssertInvalid, AssertMalformed, AssertReturn, AssertTrap, AssertUnlinkable, Invoke, - Module as Wat, Register, + Module as Wat, ModuleDefinition, Register, }; match directive { @@ -253,6 +253,17 @@ impl WastRunner { test_group.add_result(&format!("Wat({i})"), span.linecol_in(wast_raw), result.map(|_| ())); } + ModuleDefinition(module) => { + let result = catch_unwind_silent(|| { + let (_, bytes) = encode_quote_wat(module); + parse_module_bytes(&bytes) + }) + .map_err(|err| eyre!("failed to parse module definition: {}", try_downcast_panic(err))) + .and_then(|result| result) + .map(|_| ()); + + test_group.add_result(&format!("ModuleDefinition({i})"), span.linecol_in(wast_raw), result); + } AssertMalformed { span, mut module, message } => { let Ok(encoded) = module.encode() else { test_group.add_result(&format!("AssertMalformed({i})"), span.linecol_in(wast_raw), Ok(())); @@ -742,7 +753,9 @@ fn convert_wastret<'a>(args: impl Iterator<Item = wast::WastRet<'a>>) -> Result< } fn wastarg2tinywasmvalue(arg: wast::WastArg) -> Result<WasmValue> { - let wast::WastArg::Core(arg) = arg else { bail!("unsupported arg type: Component") }; + let wast::WastArg::Core(arg) = arg else { + bail!("unsupported arg type: Component"); + }; use wast::core::WastArgCore::*; Ok(match arg { F32(f) => WasmValue::F32(f32::from_bits(f.bits)), @@ -758,9 +771,13 @@ fn wastarg2tinywasmvalue(arg: wast::WastArg) -> Result<WasmValue> { wast::core::HeapType::Abstract { shared: false, ty: AbstractHeapType::Extern } => { WasmValue::RefExtern(ExternRef::null()) } - _ => bail!("unsupported arg type: refnull: {:?}", t), + _ => { + bail!("unsupported arg type: refnull: {:?}", t); + } }, - RefHost(_) => bail!("unsupported arg type: RefHost"), + RefHost(_) => { + bail!("unsupported arg type: RefHost"); + } }) } @@ -781,7 +798,9 @@ fn wast_v128_to_bytes(i: wast::core::V128Pattern) -> [u8; 16] { } fn wastret2tinywasmvalues(ret: wast::WastRet) -> Result<Vec<WasmValue>> { - let wast::WastRet::Core(ret) = ret else { bail!("unsupported arg type") }; + let wast::WastRet::Core(ret) = ret else { + bail!("unsupported arg type"); + }; match ret { wast::core::WastRetCore::Either(options) => { options.into_iter().map(wastretcore2tinywasmvalue).collect::<Result<Vec<_>>>() @@ -805,14 +824,20 @@ fn wastretcore2tinywasmvalue(ret: wast::core::WastRetCore) -> Result<WasmValue> Some(wast::core::HeapType::Abstract { shared: false, ty: AbstractHeapType::Extern }) => { WasmValue::RefExtern(ExternRef::null()) } - _ => bail!("unsupported arg type: refnull: {:?}", t), + _ => { + bail!("unsupported arg type: refnull: {:?}", t); + } }, RefExtern(v) => WasmValue::RefExtern(ExternRef::new(v)), RefFunc(v) => WasmValue::RefFunc(FuncRef::new(match v { Some(wast::token::Index::Num(n, _)) => Some(n), - _ => bail!("unsupported arg type: reffunc: {:?}", v), + _ => { + bail!("unsupported arg type: reffunc: {:?}", v); + } })), - a => bail!("unsupported arg type {:?}", a), + a => { + bail!("unsupported arg type {:?}", a); + } }) } |
