fluidattacks-blends-domain 0.41.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use super::build_string_literal;
use crate::syntax::_node_builders::languages::rust::tests_utils::{find_node, rust_ast_graph};
use crate::syntax::core_nodes::StringLiteral;
use alloc::borrow::ToOwned;

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

#[test]
fn keeps_the_string_source_text() {
    let graph = rust_ast_graph(SOURCE);
    let node = find_node(&graph, "string_literal");
    let built = build_string_literal(&graph, node).unwrap();
    assert_eq!(
        built,
        StringLiteral {
            value: "\"hi\\n\"".to_owned(),
        }
    );
}

#[test]
fn keeps_only_the_raw_string_content() {
    let graph = rust_ast_graph(SOURCE);
    let node = find_node(&graph, "raw_string_literal");
    let built = build_string_literal(&graph, node).unwrap();
    assert_eq!(
        built,
        StringLiteral {
            value: "a \"quoted\" word".to_owned(),
        }
    );
}

#[test]
fn keeps_the_char_source_text() {
    let graph = rust_ast_graph(SOURCE);
    let node = find_node(&graph, "char_literal");
    let built = build_string_literal(&graph, node).unwrap();
    assert_eq!(
        built,
        StringLiteral {
            value: "'x'".to_owned(),
        }
    );
}