diff --git a/lib/runtime-c-api/tests/test-tables.c b/lib/runtime-c-api/tests/test-tables.c index 66ebf832d..48b7be710 100644 --- a/lib/runtime-c-api/tests/test-tables.c +++ b/lib/runtime-c-api/tests/test-tables.c @@ -19,7 +19,7 @@ int main() uint32_t len = wasmer_table_length(table); printf("Table length: %d\n", len); - assert(len == 15); + assert(len == 10); // wasmer_result_t grow_result1 = wasmer_table_grow(table, 5); // assert(grow_result1 == WASMER_OK); diff --git a/lib/runtime-core/src/memory/mod.rs b/lib/runtime-core/src/memory/mod.rs index 56d4c643b..bc706b564 100644 --- a/lib/runtime-core/src/memory/mod.rs +++ b/lib/runtime-core/src/memory/mod.rs @@ -306,3 +306,21 @@ impl Clone for SharedMemory { unimplemented!() } } + +#[cfg(test)] +mod memory_tests { + + use super::{Memory, MemoryDescriptor, Pages}; + + #[test] + fn test_initial_memory_size() { + let unshared_memory = Memory::new(MemoryDescriptor { + minimum: Pages(10), + maximum: Some(Pages(20)), + shared: false, + }) + .unwrap(); + assert_eq!(unshared_memory.size(), Pages(10)); + } + +} diff --git a/lib/runtime-core/src/table/anyfunc.rs b/lib/runtime-core/src/table/anyfunc.rs index 161e26097..789f67ada 100644 --- a/lib/runtime-core/src/table/anyfunc.rs +++ b/lib/runtime-core/src/table/anyfunc.rs @@ -53,10 +53,7 @@ impl AnyfuncTable { desc: TableDescriptor, local: &mut vm::LocalTable, ) -> Result, CreationError> { - let initial_table_backing_len = match desc.maximum { - Some(max) => max, - None => desc.minimum, - } as usize; + let initial_table_backing_len = desc.minimum as usize; let mut storage = Box::new(AnyfuncTable { backing: vec![vm::Anyfunc::null(); initial_table_backing_len], diff --git a/lib/runtime-core/src/table/mod.rs b/lib/runtime-core/src/table/mod.rs index 1bad9a3c4..a45593802 100644 --- a/lib/runtime-core/src/table/mod.rs +++ b/lib/runtime-core/src/table/mod.rs @@ -148,3 +148,21 @@ impl fmt::Debug for Table { .finish() } } + +#[cfg(test)] +mod table_tests { + + use super::{ElementType, Table, TableDescriptor}; + + #[test] + fn test_initial_table_size() { + let table = Table::new(TableDescriptor { + element: ElementType::Anyfunc, + minimum: 10, + maximum: Some(20), + }) + .unwrap(); + assert_eq!(table.size(), 10); + } + +}