MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / array_new_fixed_with_elems

Function array_new_fixed_with_elems

tests/all/arrays.rs:101–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99
100#[test]
101fn array_new_fixed_with_elems() -> Result<()> {
102 let mut store = gc_store()?;
103 let array_ty = ArrayType::new(
104 store.engine(),
105 FieldType::new(Mutability::Const, ValType::I32.into()),
106 );
107 let pre = ArrayRefPre::new(&mut store, array_ty);
108 let array = ArrayRef::new_fixed(
109 &mut store,
110 &pre,
111 &[Val::I32(11), Val::I32(22), Val::I32(33)],
112 )?;
113 assert_eq!(array.len(&store)?, 3);
114 for i in 0..3 {
115 assert_eq!(array.get(&mut store, i)?.unwrap_i32(), (i as i32 + 1) * 11);
116 }
117 Ok(())
118}
119
120#[test]
121fn array_new_fixed_unrooted_initial_elem() -> Result<()> {

Callers

nothing calls this directly

Calls 4

gc_storeFunction · 0.85
OkFunction · 0.85
newFunction · 0.50
engineMethod · 0.45

Tested by

no test coverage detected