| 34 | |
| 35 | #[test] |
| 36 | fn 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"] |