MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / test_directive_with_nested_directives

Function test_directive_with_nested_directives

aiscript-directive/src/lib.rs:280–308  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

278
279 #[test]
280 fn test_directive_with_nested_directives() {
281 let directive =
282 parse_single_directive("@combine(@length(min=5), @pattern(regex=\"[a-z]+\"))").unwrap();
283 assert_eq!(directive.name, "combine");
284 match directive.params {
285 DirectiveParams::Directives(directives) => {
286 assert_eq!(directives.len(), 2);
287
288 let first = &directives[0];
289 assert_eq!(first.name, "length");
290 match &first.params {
291 DirectiveParams::KeyValue(params) => {
292 assert_eq!(params.get("min").unwrap(), &json!(5));
293 }
294 _ => panic!("Expected KeyValue parameters for length directive"),
295 }
296
297 let second = &directives[1];
298 assert_eq!(second.name, "pattern");
299 match &second.params {
300 DirectiveParams::KeyValue(params) => {
301 assert_eq!(params.get("regex").unwrap(), &json!("[a-z]+"));
302 }
303 _ => panic!("Expected KeyValue parameters for pattern directive"),
304 }
305 }
306 _ => panic!("Expected Directives parameters"),
307 }
308 }
309
310 #[test]
311 fn test_directive_with_empty_array() {

Callers

nothing calls this directly

Calls 1

parse_single_directiveFunction · 0.85

Tested by

no test coverage detected