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

Function no_leak

tests/all/linker.rs:214–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

212#[test]
213#[cfg_attr(miri, ignore)]
214fn no_leak() -> Result<()> {
215 struct DropMe(Rc<Cell<bool>>);
216
217 impl Drop for DropMe {
218 fn drop(&mut self) {
219 self.0.set(true);
220 }
221 }
222
223 let flag = Rc::new(Cell::new(false));
224 {
225 let mut store = Store::new(&Engine::default(), DropMe(flag.clone()));
226 let mut linker = Linker::new(store.engine());
227 let module = Module::new(
228 store.engine(),
229 r#"
230 (module
231 (func (export "_start"))
232 )
233 "#,
234 )?;
235 linker.module(&mut store, "a", &module)?;
236 }
237 assert!(flag.get(), "store was leaked");
238 Ok(())
239}
240
241#[test]
242#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 6

DropMeClass · 0.85
OkFunction · 0.85
newFunction · 0.50
cloneMethod · 0.45
engineMethod · 0.45
moduleMethod · 0.45

Tested by

no test coverage detected