| 329 | |
| 330 | #[test] |
| 331 | fn struct_fields_non_empty() -> Result<()> { |
| 332 | let mut store = gc_store()?; |
| 333 | let struct_ty = StructType::new( |
| 334 | store.engine(), |
| 335 | [ |
| 336 | FieldType::new(Mutability::Const, StorageType::I8), |
| 337 | FieldType::new(Mutability::Var, StorageType::ValType(ValType::ANYREF)), |
| 338 | ], |
| 339 | )?; |
| 340 | let pre = StructRefPre::new(&mut store, struct_ty.clone()); |
| 341 | let s = StructRef::new(&mut store, &pre, &[Val::I32(36), Val::null_any_ref()])?; |
| 342 | let mut fields = s.fields(&mut store)?; |
| 343 | assert_eq!(fields.len(), 2); |
| 344 | assert_eq!(fields.next().unwrap().unwrap_i32(), 36); |
| 345 | assert!(fields.next().unwrap().unwrap_any_ref().is_none()); |
| 346 | assert!(fields.next().is_none()); |
| 347 | Ok(()) |
| 348 | } |
| 349 | |
| 350 | #[test] |
| 351 | fn struct_fields_unrooted() -> Result<()> { |