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

Function flags

tests/all/component_model/dynamic.rs:714–740  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

712
713#[test]
714fn flags() -> Result<()> {
715 let engine = super::engine();
716 let mut store = Store::new(&engine, ());
717
718 let component = Component::new(
719 &engine,
720 make_echo_component_with_params(
721 r#"(flags "A" "B" "C" "D" "E")"#,
722 &[Param(Type::U8, Some(0))],
723 ),
724 )?;
725 let instance = Linker::new(&engine).instantiate(&mut store, &component)?;
726 let func = instance.get_func(&mut store, "echo").unwrap();
727 let input = Val::Flags(vec!["B".into(), "D".into()]);
728 let mut output = [Val::Bool(false)];
729 func.call(&mut store, &[input.clone()], &mut output)?;
730
731 assert_eq!(input, output[0]);
732
733 // Sad path: unknown flags
734
735 let err = Val::Flags(vec!["B".into(), "D".into(), "F".into()]);
736 let err = func.call(&mut store, &[err], &mut output).unwrap_err();
737 assert!(err.to_string().contains("unknown flag"), "{err}");
738
739 Ok(())
740}
741
742#[test]
743fn everything() -> Result<()> {

Callers

nothing calls this directly

Calls 11

ParamClass · 0.85
OkFunction · 0.85
engineFunction · 0.50
newFunction · 0.50
FlagsClass · 0.50
instantiateMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
callMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected