summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tools/wasm-shell.cpp22
-rw-r--r--test/spec/exception-handling.wast14
2 files changed, 26 insertions, 10 deletions
diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp
index 70f52a038..29ccc6c7f 100644
--- a/src/tools/wasm-shell.cpp
+++ b/src/tools/wasm-shell.cpp
@@ -35,6 +35,7 @@ using namespace wasm;
Name ASSERT_RETURN("assert_return");
Name ASSERT_TRAP("assert_trap");
+Name ASSERT_EXCEPTION("assert_exception");
Name ASSERT_INVALID("assert_invalid");
Name ASSERT_MALFORMED("assert_malformed");
Name ASSERT_UNLINKABLE("assert_unlinkable");
@@ -114,6 +115,8 @@ protected:
parseAssertReturn(s);
} else if (id == ASSERT_TRAP) {
parseAssertTrap(s);
+ } else if (id == ASSERT_EXCEPTION) {
+ parseAssertException(s);
} else if ((id == ASSERT_INVALID) || (id == ASSERT_MALFORMED)) {
parseModuleAssertion(s);
}
@@ -203,11 +206,24 @@ protected:
parseOperation(inner);
} catch (const TrapException&) {
trapped = true;
+ }
+ assert(trapped);
+ }
+
+ void parseAssertException(Element& s) {
+ [[maybe_unused]] bool thrown = false;
+ auto& inner = *s[1];
+ if (inner[0]->str() == MODULE) {
+ return parseModuleAssertion(s);
+ }
+
+ try {
+ parseOperation(inner);
} catch (const WasmException& e) {
std::cout << "[exception thrown: " << e << "]" << std::endl;
- trapped = true;
+ thrown = true;
}
- assert(trapped);
+ assert(thrown);
}
void parseAssertReturn(Element& s) {
@@ -284,7 +300,7 @@ protected:
ModuleUtils::iterImportedMemories(wasm, reportUnknownImport);
}
- if (!invalid && id == ASSERT_TRAP) {
+ if (!invalid && (id == ASSERT_TRAP || id == ASSERT_EXCEPTION)) {
try {
instantiate(&wasm);
} catch (const TrapException&) {
diff --git a/test/spec/exception-handling.wast b/test/spec/exception-handling.wast
index 4b817a81d..5ec78dfed 100644
--- a/test/spec/exception-handling.wast
+++ b/test/spec/exception-handling.wast
@@ -285,23 +285,23 @@
)
)
-(assert_trap (invoke "throw_single_value"))
-(assert_trap (invoke "throw_multiple_values"))
+(assert_exception (invoke "throw_single_value"))
+(assert_exception (invoke "throw_multiple_values"))
(assert_return (invoke "try_nothrow") (i32.const 3))
(assert_return (invoke "try_throw_catch") (i32.const 3))
-(assert_trap (invoke "try_throw_nocatch"))
+(assert_exception (invoke "try_throw_nocatch"))
(assert_return (invoke "try_throw_catchall") (i32.const 3))
(assert_return (invoke "try_call_catch") (i32.const 5))
(assert_return (invoke "try_throw_multivalue_catch") (i32.const 5))
-(assert_trap (invoke "try_throw_rethrow"))
-(assert_trap (invoke "try_call_rethrow"))
+(assert_exception (invoke "try_throw_rethrow"))
+(assert_exception (invoke "try_call_rethrow"))
(assert_return (invoke "rethrow_target_test1") (i32.const 2))
(assert_return (invoke "rethrow_target_test2") (i32.const 1))
(assert_return (invoke "rethrow_target_test3") (i32.const 1))
(assert_return (invoke "try_delegate_caught") (i32.const 3))
-(assert_trap (invoke "try_delegate_to_catchless_try"))
+(assert_exception (invoke "try_delegate_to_catchless_try"))
(assert_return (invoke "try_delegate_to_delegate") (i32.const 3))
-(assert_trap (invoke "try_delegate_to_caller"))
+(assert_exception (invoke "try_delegate_to_caller"))
(assert_invalid
(module