fluidattacks-blends-domain 0.41.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use super::build_arguments;
use crate::ast::node_utils::AstNodeAndId;
use crate::syntax::_node_builders::languages::rust::tests_utils::{find_node, rust_ast_graph};
use crate::syntax::core_nodes::{ArgumentList, Comment, CoreSyntaxNode, CoreSyntaxNodeWithId};
use crate::NodeId;

const SOURCE: &str = include_str!("arguments.test.rs");

// Tags every child with its kind so the expected list shows what was built
fn mock_build((node, n_id): AstNodeAndId) -> CoreSyntaxNodeWithId {
    let comment = Comment {
        value: node.kind.clone(),
    };
    (CoreSyntaxNode::Comment(comment), n_id)
}

fn mock_node(nid: NodeId, kind: &str) -> CoreSyntaxNodeWithId {
    (
        CoreSyntaxNode::Comment(Comment {
            value: kind.to_owned(),
        }),
        nid,
    )
}
#[test]
fn builds_every_child_in_order() {
    let graph = rust_ast_graph(SOURCE);
    let node = find_node(&graph, "arguments");
    let open = mock_node(NodeId(14), "(");
    let arg1 = mock_node(NodeId(15), "integer_literal");
    let arg2 = mock_node(NodeId(17), "integer_literal");
    let close = mock_node(NodeId(19), ")");
    let expected = ArgumentList {
        args: vec![open, arg1, arg2, close],
    };
    assert_eq!(
        build_arguments(&graph, node, |p| Ok(mock_build(p))),
        Ok(expected)
    );
}