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

Function reflect_resource_import

tests/all/component_model/aot.rs:140–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138
139#[test]
140fn reflect_resource_import() -> Result<()> {
141 let engine = super::engine();
142 let c = Component::new(
143 &engine,
144 r#"
145 (component
146 (import "x" (type $x (sub resource)))
147 (import "y" (func (result (own $x))))
148 )
149 "#,
150 )?;
151 let ty = c.component_type();
152 let mut imports = ty.imports(&engine);
153 let (_, x) = imports.next().unwrap();
154 let (_, y) = imports.next().unwrap();
155 let x = match x.ty {
156 ComponentItem::Resource(t) => t,
157 _ => unreachable!(),
158 };
159 let y = match y.ty {
160 ComponentItem::ComponentFunc(t) => t,
161 _ => unreachable!(),
162 };
163 let result = y.results().next().unwrap();
164 assert_eq!(result, Type::Own(x));
165
166 Ok(())
167}
168
169#[test]
170#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 8

OkFunction · 0.85
component_typeMethod · 0.80
engineFunction · 0.50
newFunction · 0.50
importsMethod · 0.45
unwrapMethod · 0.45
nextMethod · 0.45
resultsMethod · 0.45

Tested by

no test coverage detected