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

Function rename_functions

crates/wizer/tests/all/tests.rs:560–600  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

558
559#[tokio::test]
560async fn rename_functions() -> Result<()> {
561 let wat = r#"
562(module
563 (func (export "wizer-initialize"))
564 (func (export "func_a") (result i32)
565 i32.const 1)
566 (func (export "func_b") (result i32)
567 i32.const 2)
568 (func (export "func_c") (result i32)
569 i32.const 3))
570 "#;
571
572 let wasm = wat_to_wasm(wat)?;
573 let mut wizer = Wizer::new();
574 wizer.func_rename("func_a", "func_b");
575 wizer.func_rename("func_b", "func_c");
576 let wasm = wizer.run(&mut store()?, &wasm, instantiate).await?;
577 let wat = wasmprinter::print_bytes(&wasm).to_wasmtime_result()?;
578
579 let expected_wat = r#"
580(module
581 (type (;0;) (func))
582 (type (;1;) (func (result i32)))
583 (export "func_a" (func 2))
584 (export "func_b" (func 3))
585 (func (;0;) (type 0))
586 (func (;1;) (type 1) (result i32)
587 i32.const 1
588 )
589 (func (;2;) (type 1) (result i32)
590 i32.const 2
591 )
592 (func (;3;) (type 1) (result i32)
593 i32.const 3
594 )
595)
596 "#;
597
598 assert_eq!(wat.trim(), expected_wat.trim());
599 Ok(())
600}
601
602#[tokio::test]
603async fn wasi_reactor() -> wasmtime::Result<()> {

Callers

nothing calls this directly

Calls 7

print_bytesFunction · 0.85
OkFunction · 0.85
func_renameMethod · 0.80
to_wasmtime_resultMethod · 0.80
storeFunction · 0.70
newFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected