| 230 | |
| 231 | #[test] |
| 232 | fn array_get_in_bounds() -> Result<()> { |
| 233 | let mut store = gc_store()?; |
| 234 | |
| 235 | let array_ty = ArrayType::new( |
| 236 | store.engine(), |
| 237 | FieldType::new(Mutability::Const, ValType::I32.into()), |
| 238 | ); |
| 239 | let pre = ArrayRefPre::new(&mut store, array_ty); |
| 240 | |
| 241 | let array = ArrayRef::new_fixed( |
| 242 | &mut store, |
| 243 | &pre, |
| 244 | &[Val::I32(11), Val::I32(22), Val::I32(33)], |
| 245 | )?; |
| 246 | |
| 247 | assert_eq!(array.get(&mut store, 0)?.unwrap_i32(), 11); |
| 248 | assert_eq!(array.get(&mut store, 1)?.unwrap_i32(), 22); |
| 249 | assert_eq!(array.get(&mut store, 2)?.unwrap_i32(), 33); |
| 250 | |
| 251 | Ok(()) |
| 252 | } |
| 253 | |
| 254 | #[test] |
| 255 | fn array_get_out_of_bounds() -> Result<()> { |