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

Function drop_component_still_works

tests/all/component_model/func.rs:2505–2558  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2503
2504#[test]
2505fn drop_component_still_works() -> Result<()> {
2506 let component = r#"
2507 (component
2508 (import "f" (func $f))
2509
2510 (core func $f_lower
2511 (canon lower (func $f))
2512 )
2513 (core module $m
2514 (import "" "" (func $f))
2515
2516 (func $f2
2517 call $f
2518 call $f
2519 )
2520
2521 (export "f" (func $f2))
2522 )
2523 (core instance $i (instantiate $m
2524 (with "" (instance
2525 (export "" (func $f_lower))
2526 ))
2527 ))
2528 (func (export "g")
2529 (canon lift
2530 (core func $i "f")
2531 )
2532 )
2533 )
2534 "#;
2535
2536 let (mut store, instance) = {
2537 let engine = super::engine();
2538 let component = Component::new(&engine, component)?;
2539 let mut store = Store::new(&engine, 0);
2540 let mut linker = Linker::new(&engine);
2541 linker.root().func_wrap(
2542 "f",
2543 |mut store: StoreContextMut<'_, u32>, _: ()| -> Result<()> {
2544 *store.data_mut() += 1;
2545 Ok(())
2546 },
2547 )?;
2548 let instance = linker.instantiate(&mut store, &component)?;
2549 (store, instance)
2550 };
2551
2552 let f = instance.get_typed_func::<(), ()>(&mut store, "g")?;
2553 assert_eq!(*store.data(), 0);
2554 f.call(&mut store, ())?;
2555 assert_eq!(*store.data(), 2);
2556
2557 Ok(())
2558}
2559
2560#[test]
2561fn raw_slice_of_various_types() -> Result<()> {

Callers

nothing calls this directly

Calls 8

OkFunction · 0.85
engineFunction · 0.50
newFunction · 0.50
func_wrapMethod · 0.45
rootMethod · 0.45
data_mutMethod · 0.45
instantiateMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected