diff --git a/crates/tests/tests/invalid.rs b/crates/tests/tests/invalid.rs index 14372e25..66a27534 100644 --- a/crates/tests/tests/invalid.rs +++ b/crates/tests/tests/invalid.rs @@ -10,8 +10,14 @@ fn run(wat: &Path) -> Result<(), failure::Error> { let wasm = walrus_tests_utils::wat2wasm(wat, &["--no-check"])?; // NB: reading the module will do the validation. - if let Ok(_) = walrus::Module::from_buffer(&wasm) { - failure::bail!("expected {} to be invalid, but it was valid", wat.display()); + match walrus::Module::from_buffer(&wasm) { + Err(e) => { + eprintln!("Got error, as expected:"); + for c in e.iter_chain() { + eprintln!(" - {}", c); + } + } + Ok(_) => failure::bail!("expected {} to be invalid, but it was valid", wat.display()), } Ok(()) diff --git a/crates/tests/tests/invalid/if-with-no-else.wat b/crates/tests/tests/invalid/if-with-no-else.wat new file mode 100644 index 00000000..c3683744 --- /dev/null +++ b/crates/tests/tests/invalid/if-with-no-else.wat @@ -0,0 +1,12 @@ +(module + (func (export "f") (param i32) (result i32) + (local.get 0) + (if (result i32) + (then (i32.const 1)) + ;; Note: since the `if` block is supposed to produce a result, we need an + ;; `else` here to produce that result if the condition is false. + ;; + ;; (else (i32.const 2)) + ) + ) +)