| 368 | |
| 369 | #[test] |
| 370 | fn array_set_given_unrooted() -> Result<()> { |
| 371 | let mut store = gc_store()?; |
| 372 | |
| 373 | let array_ty = ArrayType::new( |
| 374 | store.engine(), |
| 375 | FieldType::new(Mutability::Var, ValType::ANYREF.into()), |
| 376 | ); |
| 377 | let pre = ArrayRefPre::new(&mut store, array_ty); |
| 378 | |
| 379 | let array = ArrayRef::new_fixed(&mut store, &pre, &[Val::AnyRef(None)])?; |
| 380 | |
| 381 | let anyref = { |
| 382 | let mut scope = RootScope::new(&mut store); |
| 383 | AnyRef::from_i31(&mut scope, I31::new_i32(1234).unwrap()) |
| 384 | }; |
| 385 | |
| 386 | assert!(array.set(&mut store, 0, anyref.into()).is_err()); |
| 387 | Ok(()) |
| 388 | } |
| 389 | |
| 390 | #[test] |
| 391 | #[should_panic = "wrong store"] |