MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / test_get_wasm_val

Function test_get_wasm_val

crates/tinywasm/src/store/table.rs:204–225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

202
203 #[test]
204 fn test_get_wasm_val() {
205 let kind = dummy_table_type();
206 let mut table_instance = TableInstance::new(kind);
207
208 table_instance.set(0, TableElement::Initialized(0)).expect("Setting table element failed");
209 table_instance.set(1, TableElement::Uninitialized).expect("Setting table element failed");
210
211 match table_instance.get_wasm_val(0) {
212 Ok(WasmValue::RefFunc(_)) => {}
213 _ => panic!("get_wasm_val failed to return the correct WasmValue"),
214 }
215
216 match table_instance.get_wasm_val(1) {
217 Ok(WasmValue::RefFunc(f)) if f.is_null() => {}
218 _ => panic!("get_wasm_val failed to return the correct WasmValue"),
219 }
220
221 match table_instance.get_wasm_val(999) {
222 Err(Trap::TableOutOfBounds { .. }) => {}
223 _ => panic!("get_wasm_val failed to handle undefined element correctly"),
224 }
225 }
226
227 #[test]
228 fn test_set_and_get() {

Callers

nothing calls this directly

Calls 4

dummy_table_typeFunction · 0.85
get_wasm_valMethod · 0.80
setMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected