()
| 712 | |
| 713 | #[test] |
| 714 | fn 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] |
| 743 | fn everything() -> Result<()> { |
nothing calls this directly
no test coverage detected