MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / i31ref_table_set

Function i31ref_table_set

tests/all/table.rs:154–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

152
153#[test]
154fn i31ref_table_set() -> Result<()> {
155 let mut config = Config::new();
156 config.wasm_function_references(true);
157 config.wasm_gc(true);
158
159 let engine = Engine::new(&config)?;
160 let mut store = Store::new(&engine, ());
161
162 for (elem_ty, inits, vals) in [
163 (
164 RefType::I31REF,
165 vec![
166 Ref::Any(None),
167 AnyRef::from_i31(&mut store, I31::default()).into(),
168 ],
169 vec![
170 Ref::Any(None),
171 AnyRef::from_i31(&mut store, I31::wrapping_u32(42)).into(),
172 ],
173 ),
174 (
175 RefType::new(false, HeapType::I31),
176 vec![AnyRef::from_i31(&mut store, I31::default()).into()],
177 vec![AnyRef::from_i31(&mut store, I31::wrapping_u32(42)).into()],
178 ),
179 ] {
180 let table_ty = TableType::new(elem_ty, 10, None);
181 for init in inits {
182 for expected in vals.clone() {
183 let table = Table::new(&mut store, table_ty.clone(), init.clone())?;
184 for i in 0..10 {
185 table.set(&mut store, i, expected.clone())?;
186 let actual = table.get(&mut store, i).unwrap();
187 assert_eq!(expected.is_null(), actual.is_null());
188 assert_eq!(
189 expected
190 .as_any()
191 .expect("is anyref")
192 .map(|a| a.as_i31(&store).expect("is in scope")),
193 actual
194 .as_any()
195 .expect("is anyref")
196 .map(|a| a.as_i31(&store).expect("is in scope"))
197 )
198 }
199 }
200 }
201 }
202
203 Ok(())
204}
205
206#[test]
207fn i31ref_table_grow() -> Result<()> {

Callers

nothing calls this directly

Calls 8

OkFunction · 0.85
newFunction · 0.50
wasm_gcMethod · 0.45
cloneMethod · 0.45
setMethod · 0.45
unwrapMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected