()
| 778 | #[test] |
| 779 | #[cfg_attr(miri, ignore)] |
| 780 | fn wasm_sets_array_in_table() -> Result<()> { |
| 781 | let mut store = gc_store()?; |
| 782 | |
| 783 | let module = Module::new( |
| 784 | store.engine(), |
| 785 | r#" |
| 786 | (module |
| 787 | (type (array i8)) |
| 788 | (table $t (export "t") 1 1 (ref null 0) (ref.null 0)) |
| 789 | (func (export "get") (result (ref null 0)) |
| 790 | i32.const 0 |
| 791 | table.get $t |
| 792 | ) |
| 793 | (func (export "set") (param (ref null 0)) |
| 794 | i32.const 0 |
| 795 | local.get 0 |
| 796 | table.set $t |
| 797 | ) |
| 798 | ) |
| 799 | "#, |
| 800 | )?; |
| 801 | |
| 802 | let array_ty = ArrayType::new( |
| 803 | store.engine(), |
| 804 | FieldType::new(Mutability::Const, StorageType::I8), |
| 805 | ); |
| 806 | let pre = ArrayRefPre::new(&mut store, array_ty.clone()); |
| 807 | let a0 = ArrayRef::new_fixed(&mut store, &pre, &[Val::I32(42)])?; |
| 808 | |
| 809 | let instance = Instance::new(&mut store, &module, &[])?; |
| 810 | let set = instance.get_func(&mut store, "set").unwrap(); |
| 811 | set.call(&mut store, &[a0.into()], &mut [])?; |
| 812 | |
| 813 | // Get the global from the host. |
| 814 | let t = instance.get_table(&mut store, "t").unwrap(); |
| 815 | let val = t.get(&mut store, 0).expect("in bounds"); |
| 816 | let anyref = val.unwrap_any().expect("non-null"); |
| 817 | let a1 = anyref.unwrap_array(&store)?; |
| 818 | assert_eq!(a1.len(&mut store)?, 1); |
| 819 | assert_eq!(a1.get(&mut store, 0)?.unwrap_i32(), 42); |
| 820 | assert!(Rooted::ref_eq(&store, &a0, &a1)?); |
| 821 | |
| 822 | // Get the global from the guest. |
| 823 | let f = instance.get_typed_func::<(), Option<Rooted<ArrayRef>>>(&mut store, "get")?; |
| 824 | let a2 = f.call(&mut store, ())?.expect("non-null"); |
| 825 | assert_eq!(a2.len(&mut store)?, 1); |
| 826 | assert_eq!(a2.get(&mut store, 0)?.unwrap_i32(), 42); |
| 827 | assert!(Rooted::ref_eq(&store, &a0, &a2)?); |
| 828 | |
| 829 | Ok(()) |
| 830 | } |
| 831 | |
| 832 | #[test] |
| 833 | fn instantiate_with_array_global() -> Result<()> { |
nothing calls this directly
no test coverage detected