summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorHenry <mail@henrygressmann.de>2026-08-27 17:42:25 +0200
committerHenry <mail@henrygressmann.de>2026-08-27 17:42:25 +0200
commitbec01366093debe42285e52861ad2d46ee55c037 (patch)
treefed423b46d05c1d94469268a2aa64a1583f3aea2 /crates
parent843e0ff5601479239791f452bec9865df779839b (diff)
chore: fix tests
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates')
-rw-r--r--crates/tinywasm/src/func/context.rs3
-rw-r--r--crates/tinywasm/src/macros.rs15
-rw-r--r--crates/tinywasm/tests/internal_refs.rs2
-rw-r--r--crates/tinywasm/tests/memory.rs2
4 files changed, 9 insertions, 13 deletions
diff --git a/crates/tinywasm/src/func/context.rs b/crates/tinywasm/src/func/context.rs
index 9f637f0..aa54e1d 100644
--- a/crates/tinywasm/src/func/context.rs
+++ b/crates/tinywasm/src/func/context.rs
@@ -24,8 +24,7 @@ impl FuncContext<'_> {
pub fn module(&self) -> crate::ModuleInstance {
unwrap_or_unreachable!(
self.store.get_module_instance(self.module_id),
- "invalid module instance id in host function context: {}",
- self.module_id
+ "invalid module instance id in host function context"
)
.clone()
}
diff --git a/crates/tinywasm/src/macros.rs b/crates/tinywasm/src/macros.rs
index b071259..96a2e40 100644
--- a/crates/tinywasm/src/macros.rs
+++ b/crates/tinywasm/src/macros.rs
@@ -19,18 +19,15 @@ macro_rules! cold_err {
macro_rules! unwrap_or_unreachable {
($value:expr) => {{
- unwrap_or_unreachable!($value, "entered unreachable code")
+ match $value {
+ Some(value) => value,
+ None => cold!(unreachable!()),
+ }
}};
- ($value:expr, $($message:tt)+) => {{
+ ($value:expr, $($arg:tt)+) => {{
match $value {
Some(value) => value,
- None => $crate::macros::unwrap_unreachable(format_args!($($message)+)),
+ None => cold!(unreachable!($($arg)+)),
}
}};
}
-
-#[cold]
-#[inline(never)]
-pub(crate) fn unwrap_unreachable(message: core::fmt::Arguments<'_>) -> ! {
- unreachable!("{message}")
-}
diff --git a/crates/tinywasm/tests/internal_refs.rs b/crates/tinywasm/tests/internal_refs.rs
index ac44e26..410ea20 100644
--- a/crates/tinywasm/tests/internal_refs.rs
+++ b/crates/tinywasm/tests/internal_refs.rs
@@ -11,7 +11,7 @@ fn private_items_are_accessible_by_index() -> Result<(), Box<dyn core::error::Er
(module
(func (result i32)
i32.const 7)
- (memory 1)
+ (memory (export "memory") 1)
(global (mut i32) (i32.const 11))
(table 2 funcref)
(elem (i32.const 0) func 0)
diff --git a/crates/tinywasm/tests/memory.rs b/crates/tinywasm/tests/memory.rs
index 608b9e1..cf90c13 100644
--- a/crates/tinywasm/tests/memory.rs
+++ b/crates/tinywasm/tests/memory.rs
@@ -137,7 +137,7 @@ fn resource_limiter_rejects_host_memory_initial_size() {
#[test]
fn resource_limiter_rejects_module_memory_initial_size() -> TestResult {
- let wasm = wat::parse_str("(module (memory 1))")?;
+ let wasm = wat::parse_str("(module (memory (export \"memory\") 1))")?;
let module = tinywasm::parse_bytes(&wasm)?;
let mut store = store_with_limiter(DenyAll);
let result = ModuleInstance::instantiate(&mut store, &module, None);