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

Function i31ref_global_get

tests/all/globals.rs:131–164  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

129
130#[test]
131fn i31ref_global_get() -> Result<()> {
132 let mut config = Config::new();
133 config.wasm_function_references(true);
134 config.wasm_gc(true);
135
136 let engine = Engine::new(&config)?;
137 let mut store = Store::new(&engine, ());
138
139 for mutability in [Mutability::Const, Mutability::Var] {
140 for val in [
141 Some(AnyRef::from_i31(&mut store, I31::new_u32(42).unwrap())),
142 None,
143 ] {
144 let val = Val::from(val);
145 let global = Global::new(
146 &mut store,
147 GlobalType::new(ValType::I31REF, mutability),
148 val,
149 )?;
150
151 let got = global.get(&mut store);
152
153 let val = val
154 .anyref()
155 .and_then(|a| a.and_then(|a| a.as_i31(&store).unwrap()));
156 let got = got
157 .anyref()
158 .and_then(|a| a.and_then(|a| a.as_i31(&store).unwrap()));
159
160 assert_eq!(val, got);
161 }
162 }
163 Ok(())
164}
165
166#[test]
167fn i31ref_global_set() -> Result<()> {

Callers

nothing calls this directly

Calls 9

fromFunction · 0.85
OkFunction · 0.85
newFunction · 0.50
wasm_gcMethod · 0.45
unwrapMethod · 0.45
getMethod · 0.45
anyrefMethod · 0.45
as_i31Method · 0.45

Tested by

no test coverage detected