<commit_before>use super::helpers::fixtures::{get_highlight_config, get_language, test_loader};
use crate::test_highlight::{get_highlight_positions, parse_highlight_test};
use tree_sitter::{Parser, Point};
use tree_sitter_highlight::{Highlight, Highlighter};

#[test]
fn test_highlight_test_with_basic_test() {
    let language = get_language("javascript");
    let config = get_highlight_config(
        "javascript",
        "injections.scm",
        &[
            "function.definition".to_string(),
            "variable.parameter".to_string(),
            "keyword".to_string(),
        ],
    );
    let source = [
        "var abc = function(d) {",
        "  // ^ function.definition",
        "  //       ^ keyword",
        "  return d + e;",
        "  //     ^ variable.parameter",
        "};",
    ]
    .join("\n");

    let assertions = parse_highlight_test(&mut Parser::new(), language, source.as_bytes()).unwrap();
    assert_eq!(
        assertions,
        &[
            (Point::new(0, 5), "function.definition".to_string()),
            (Point::new(0, 11), "keyword".to_string()),
            (Point::new(3, 9), "variable.parameter".to_string()),
        ]
    );

    let mut highlighter = Highlighter::new();
    let highlight_positions =
        get_highlight_positions(test_loader(), &mut highlighter, &config, source.as_bytes())
            .unwrap();
    assert_eq!(
        highlight_positions,
        &[
            (Point::new(0, 0), Point::new(0, 3), Highlight(2)), // "var"
            (Point::new(0, 4), Point::new(0, 7), Highlight(0)), // "abc"
            (Point::new(0, 10), Point::new(0, 18), Highlight(2)), // "function"
            (Point::new(0, 19), Point::new(0, 20), Highlight(1)), // "d"
            (Point::new(3, 2), Point::new(3, 8), Highlight(2)), // "return"
            (Point::new(3, 9), Point::new(3, 10), Highlight(1)), // "d"
        ]
    );
}<commit_msg>Update unit test to reflect javascript query change<commit_after>use super::helpers::fixtures::{get_highlight_config, get_language, test_loader};
use crate::test_highlight::{get_highlight_positions, parse_highlight_test};
use tree_sitter::{Parser, Point};
use tree_sitter_highlight::{Highlight, Highlighter};

#[test]
fn test_highlight_test_with_basic_test() {
    let language = get_language("javascript");
    let config = get_highlight_config(
        "javascript",
        "injections.scm",
        &[
            "function".to_string(),
            "variable.parameter".to_string(),
            "keyword".to_string(),
        ],
    );
    let source = [
        "var abc = function(d) {",
        "  // ^ function",
        "  //       ^ keyword",
        "  return d + e;",
        "  //     ^ variable.parameter",
        "};",
    ]
    .join("\n");

    let assertions = parse_highlight_test(&mut Parser::new(), language, source.as_bytes()).unwrap();
    assert_eq!(
        assertions,
        &[
            (Point::new(0, 5), "function".to_string()),
            (Point::new(0, 11), "keyword".to_string()),
            (Point::new(3, 9), "variable.parameter".to_string()),
        ]
    );

    let mut highlighter = Highlighter::new();
    let highlight_positions =
        get_highlight_positions(test_loader(), &mut highlighter, &config, source.as_bytes())
            .unwrap();
    assert_eq!(
        highlight_positions,
        &[
            (Point::new(0, 0), Point::new(0, 3), Highlight(2)), // "var"
            (Point::new(0, 4), Point::new(0, 7), Highlight(0)), // "abc"
            (Point::new(0, 10), Point::new(0, 18), Highlight(2)), // "function"
            (Point::new(0, 19), Point::new(0, 20), Highlight(1)), // "d"
            (Point::new(3, 2), Point::new(3, 8), Highlight(2)), // "return"
            (Point::new(3, 9), Point::new(3, 10), Highlight(1)), // "d"
        ]
    );
}
{'fraction_non_alphanumeric': 0.1846435100548446, 'fraction_numerical': 0.021937842778793418, 'mean_word_length': 2.516988062442608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3612275', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1210, 'n_words': 219}