MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / test_node_with_custom_name

Function test_node_with_custom_name

node-graph/node-macro/src/parsing.rs:1508–1550  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1506
1507 #[test]
1508 fn test_node_with_custom_name() {
1509 let attr = quote!(category("Custom"), name("CustomNode2"));
1510 let input = quote!(
1511 fn custom_node(input: i32) -> i32 {
1512 input * 2
1513 }
1514 );
1515
1516 let parsed = parse_node_fn(attr, input).unwrap();
1517 let expected = ParsedNodeFn {
1518 vis: Visibility::Inherited,
1519 attributes: NodeFnAttributes {
1520 category: Some(parse_quote!("Custom")),
1521 display_name: Some(parse_quote!("CustomNode2")),
1522 path: None,
1523 skip_impl: false,
1524 properties_string: None,
1525 cfg: None,
1526 shader_node: None,
1527 serialize: None,
1528 memoize: false,
1529 inject_scope: false,
1530 },
1531 fn_name: Ident::new("custom_node", Span::call_site()),
1532 struct_name: Ident::new("CustomNode", Span::call_site()),
1533 mod_name: Ident::new("custom_node", Span::call_site()),
1534 fn_generics: vec![],
1535 where_clause: None,
1536 input: Input {
1537 pat_ident: pat_ident("input"),
1538 ty: parse_quote!(i32),
1539 implementations: Punctuated::new(),
1540 context_features: vec![],
1541 },
1542 output_type: parse_quote!(i32),
1543 is_async: false,
1544 fields: vec![],
1545 body: TokenStream2::new(),
1546 description: String::new(),
1547 };
1548
1549 assert_parsed_node_fn(&parsed, &expected);
1550 }
1551
1552 #[test]
1553 #[should_panic(expected = "Multiple 'category' attributes are not allowed")]

Callers

nothing calls this directly

Calls 3

parse_node_fnFunction · 0.85
pat_identFunction · 0.85
assert_parsed_node_fnFunction · 0.85

Tested by

no test coverage detected