| 113 | |
| 114 | #[test] |
| 115 | fn struct_field_simple() -> Result<()> { |
| 116 | let mut store = gc_store()?; |
| 117 | let struct_ty = StructType::new( |
| 118 | store.engine(), |
| 119 | [FieldType::new( |
| 120 | Mutability::Var, |
| 121 | StorageType::ValType(ValType::I32), |
| 122 | )], |
| 123 | )?; |
| 124 | let pre = StructRefPre::new(&mut store, struct_ty); |
| 125 | let s = StructRef::new(&mut store, &pre, &[Val::I32(1234)])?; |
| 126 | let val = s.field(&mut store, 0)?; |
| 127 | assert_eq!(val.unwrap_i32(), 1234); |
| 128 | Ok(()) |
| 129 | } |
| 130 | |
| 131 | #[test] |
| 132 | fn struct_field_out_of_bounds() -> Result<()> { |