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

Function anyref_as_array

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

Source from the content-addressed store, hash-verified

171
172#[test]
173fn anyref_as_array() -> Result<()> {
174 let mut store = gc_store()?;
175
176 let array_ty = ArrayType::new(
177 store.engine(),
178 FieldType::new(Mutability::Const, StorageType::ValType(ValType::I32)),
179 );
180 let pre = ArrayRefPre::new(&mut store, array_ty);
181 let a0 = ArrayRef::new_fixed(&mut store, &pre, &[])?;
182
183 let anyref: Rooted<AnyRef> = a0.into();
184 assert!(anyref.is_array(&store)?);
185 let a1 = anyref.as_array(&store)?.unwrap();
186 assert!(Rooted::ref_eq(&store, &a0, &a1)?);
187
188 let anyref = AnyRef::from_i31(&mut store, I31::new_i32(42).unwrap());
189 assert!(!anyref.is_array(&store)?);
190 assert!(anyref.as_array(&store)?.is_none());
191
192 Ok(())
193}
194
195#[test]
196fn array_len_empty() -> Result<()> {

Callers

nothing calls this directly

Calls 7

gc_storeFunction · 0.85
OkFunction · 0.85
newFunction · 0.50
ValTypeEnum · 0.50
engineMethod · 0.45
unwrapMethod · 0.45
as_arrayMethod · 0.45

Tested by

no test coverage detected