| 18 | |
| 19 | #[test] |
| 20 | fn array_new_with_elems() -> Result<()> { |
| 21 | let mut store = gc_store()?; |
| 22 | let array_ty = ArrayType::new( |
| 23 | store.engine(), |
| 24 | FieldType::new(Mutability::Const, ValType::I32.into()), |
| 25 | ); |
| 26 | let pre = ArrayRefPre::new(&mut store, array_ty); |
| 27 | let array = ArrayRef::new(&mut store, &pre, &Val::I32(99), 3)?; |
| 28 | assert_eq!(array.len(&store)?, 3); |
| 29 | for i in 0..3 { |
| 30 | assert_eq!(array.get(&mut store, i)?.unwrap_i32(), 99); |
| 31 | } |
| 32 | Ok(()) |
| 33 | } |
| 34 | |
| 35 | #[test] |
| 36 | fn array_new_unrooted_initial_elem() -> Result<()> { |