()
| 130 | #[test] |
| 131 | #[cfg_attr(miri, ignore)] |
| 132 | fn function_interposition_renamed() -> Result<()> { |
| 133 | let mut store = Store::<()>::default(); |
| 134 | let mut linker = Linker::new(store.engine()); |
| 135 | linker.allow_shadowing(true); |
| 136 | let mut module = Module::new( |
| 137 | store.engine(), |
| 138 | r#"(module (func (export "export") (result i32) (i32.const 7)))"#, |
| 139 | )?; |
| 140 | for _ in 0..4 { |
| 141 | let instance = linker.instantiate(&mut store, &module)?; |
| 142 | let export = instance.get_export(&mut store, "export").unwrap().clone(); |
| 143 | linker.define(&mut store, "red", "green", export)?; |
| 144 | module = Module::new( |
| 145 | store.engine(), |
| 146 | r#"(module |
| 147 | (import "red" "green" (func (result i32))) |
| 148 | (func (export "export") (result i32) (i32.mul (call 0) (i32.const 2))) |
| 149 | )"#, |
| 150 | )?; |
| 151 | } |
| 152 | let instance = linker.instantiate(&mut store, &module)?; |
| 153 | let func = instance.get_func(&mut store, "export").unwrap(); |
| 154 | let func = func.typed::<(), i32>(&store)?; |
| 155 | assert_eq!(func.call(&mut store, ())?, 112); |
| 156 | Ok(()) |
| 157 | } |
| 158 | |
| 159 | // Similar to `function_interposition`, but use `Linker::instance` instead of |
| 160 | // `Linker::define`. |
nothing calls this directly
no test coverage detected