| 99 | |
| 100 | #[test] |
| 101 | fn array_new_fixed_with_elems() -> Result<()> { |
| 102 | let mut store = gc_store()?; |
| 103 | let array_ty = ArrayType::new( |
| 104 | store.engine(), |
| 105 | FieldType::new(Mutability::Const, ValType::I32.into()), |
| 106 | ); |
| 107 | let pre = ArrayRefPre::new(&mut store, array_ty); |
| 108 | let array = ArrayRef::new_fixed( |
| 109 | &mut store, |
| 110 | &pre, |
| 111 | &[Val::I32(11), Val::I32(22), Val::I32(33)], |
| 112 | )?; |
| 113 | assert_eq!(array.len(&store)?, 3); |
| 114 | for i in 0..3 { |
| 115 | assert_eq!(array.get(&mut store, i)?.unwrap_i32(), (i as i32 + 1) * 11); |
| 116 | } |
| 117 | Ok(()) |
| 118 | } |
| 119 | |
| 120 | #[test] |
| 121 | fn array_new_fixed_unrooted_initial_elem() -> Result<()> { |