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

Function export_missing_get_max

tests/all/component_model/instance.rs:137–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135#[test]
136#[cfg_attr(miri, ignore)]
137fn export_missing_get_max() -> Result<()> {
138 let engine = super::engine();
139 let component = r#"
140 (component
141 (core module $m1)
142 (core module $m2 (import "" "" (func)))
143 (export "a:b/m@1.0.1" (core module $m1))
144 (export "a:b/m@1.0.3" (core module $m2))
145 )
146 "#;
147
148 fn assert_m2(module: &Module) {
149 assert_eq!(module.imports().len(), 1);
150 }
151 fn assert_m1(module: &Module) {
152 assert_eq!(module.imports().len(), 0);
153 }
154
155 let component = Component::new(&engine, component)?;
156 let mut store = Store::new(&engine, ());
157 let instance = Linker::new(&engine).instantiate(&mut store, &component)?;
158
159 let tests = [
160 ("a:b/m@1.0.0", assert_m2 as fn(&_)), // no exact, should pick max available
161 ("a:b/m@1.0.1", assert_m1), // exact hit
162 ("a:b/m@1.0.2", assert_m2), // no exact, should pick max available
163 ("a:b/m@1.0.3", assert_m2), // exact hit
164 ("a:b/m@1.0.4", assert_m2), // no exact, should pick max available
165 ];
166
167 for (name, test_fn) in tests {
168 println!("test {name}");
169 let m = component.get_export_index(None, name).unwrap();
170 let m = instance.get_module(&mut store, &m).unwrap();
171 test_fn(&m);
172
173 let m = instance.get_module(&mut store, name).unwrap();
174 test_fn(&m);
175
176 let m = instance.get_export_index(&mut store, None, name).unwrap();
177 let m = instance.get_module(&mut store, &m).unwrap();
178 test_fn(&m);
179 }
180
181 Ok(())
182}

Callers

nothing calls this directly

Calls 7

OkFunction · 0.85
engineFunction · 0.50
newFunction · 0.50
instantiateMethod · 0.45
unwrapMethod · 0.45
get_export_indexMethod · 0.45
get_moduleMethod · 0.45

Tested by

no test coverage detected