| 166 | |
| 167 | #[test] |
| 168 | fn struct_set_field_simple() -> Result<()> { |
| 169 | let mut store = gc_store()?; |
| 170 | let struct_ty = StructType::new( |
| 171 | store.engine(), |
| 172 | [FieldType::new( |
| 173 | Mutability::Var, |
| 174 | StorageType::ValType(ValType::I32), |
| 175 | )], |
| 176 | )?; |
| 177 | let pre = StructRefPre::new(&mut store, struct_ty); |
| 178 | let s = StructRef::new(&mut store, &pre, &[Val::I32(1234)])?; |
| 179 | s.set_field(&mut store, 0, Val::I32(5678))?; |
| 180 | let val = s.field(&mut store, 0)?; |
| 181 | assert_eq!(val.unwrap_i32(), 5678); |
| 182 | Ok(()) |
| 183 | } |
| 184 | |
| 185 | #[test] |
| 186 | fn struct_set_field_out_of_bounds() -> Result<()> { |