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

Function array_new_unrooted_initial_elem

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

Source from the content-addressed store, hash-verified

34
35#[test]
36fn array_new_unrooted_initial_elem() -> Result<()> {
37 let mut store = gc_store()?;
38 let array_ty = ArrayType::new(
39 store.engine(),
40 FieldType::new(Mutability::Var, StorageType::ValType(ValType::ANYREF)),
41 );
42 let pre = ArrayRefPre::new(&mut store, array_ty);
43
44 // Passing an unrooted `anyref` to `StructRef::new` results in an error.
45 let anyref = {
46 let mut scope = RootScope::new(&mut store);
47 AnyRef::from_i31(&mut scope, I31::new_i32(1234).unwrap())
48 };
49
50 assert!(ArrayRef::new(&mut store, &pre, &anyref.into(), 3).is_err());
51 Ok(())
52}
53
54#[test]
55#[should_panic = "wrong store"]

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected