| 119 | |
| 120 | #[test] |
| 121 | fn array_new_fixed_unrooted_initial_elem() -> Result<()> { |
| 122 | let mut store = gc_store()?; |
| 123 | let array_ty = ArrayType::new( |
| 124 | store.engine(), |
| 125 | FieldType::new(Mutability::Var, StorageType::ValType(ValType::ANYREF)), |
| 126 | ); |
| 127 | let pre = ArrayRefPre::new(&mut store, array_ty); |
| 128 | |
| 129 | // Passing an unrooted `anyref` to `StructRef::new` results in an error. |
| 130 | let anyref = { |
| 131 | let mut scope = RootScope::new(&mut store); |
| 132 | AnyRef::from_i31(&mut scope, I31::new_i32(1234).unwrap()) |
| 133 | }; |
| 134 | |
| 135 | assert!(ArrayRef::new_fixed(&mut store, &pre, &[anyref.into()]).is_err()); |
| 136 | Ok(()) |
| 137 | } |
| 138 | |
| 139 | #[test] |
| 140 | #[should_panic = "wrong store"] |