<commit_before>package org.spoofax.jsglr2.integrationtest.features;

import java.util.Arrays;
import java.util.stream.Stream;

import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
import org.spoofax.jsglr.client.imploder.IToken;
import org.spoofax.jsglr2.integrationtest.BaseTestWithSdf3ParseTables;
import org.spoofax.jsglr2.integrationtest.TokenDescriptor;
import org.spoofax.terms.ParseError;

public class TokenizationTest extends BaseTestWithSdf3ParseTables {

    public TokenizationTest() {
        super("tokenization.sdf3");
    }

    @TestFactory public Stream<DynamicTest> number() throws ParseError {
        return testTokens("1", Arrays.asList(
        //@formatter:off
            new TokenDescriptor("1", IToken.TK_NUMBER, 0, 1, 1, "NUMBER", null)
        //@formatter:on
        ));
    }

    @TestFactory public Stream<DynamicTest> identifier() throws ParseError {
        return testTokens("x", Arrays.asList(
        //@formatter:off
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 0, 1, 1, "ID", null)
        //@formatter:on
        ));
    }

    @TestFactory public Stream<DynamicTest> operator() throws ParseError {
        return testTokens("x+x", Arrays.asList(
        //@formatter:off
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 0, 1, 1, "ID", null),
            new TokenDescriptor("+", IToken.TK_OPERATOR,   1, 1, 2, "Exp", "AddOperator"),
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 2, 1, 3, "ID", null)
        //@formatter:on
        ));<commit_msg>Consistent tokens for ambiguous trees<commit_after>package org.spoofax.jsglr2.integrationtest.features;

import java.util.Arrays;
import java.util.stream.Stream;

import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
import org.spoofax.jsglr.client.imploder.IToken;
import org.spoofax.jsglr2.integrationtest.BaseTestWithSdf3ParseTables;
import org.spoofax.jsglr2.integrationtest.TokenDescriptor;
import org.spoofax.terms.ParseError;

public class TokenizationTest extends BaseTestWithSdf3ParseTables {

    public TokenizationTest() {
        super("tokenization.sdf3");
    }

    @TestFactory public Stream<DynamicTest> number() throws ParseError {
        return testTokens("1", Arrays.asList(
        //@formatter:off
            new TokenDescriptor("1", IToken.TK_NUMBER, 0, 1, 1, "NUMBER", null)
        //@formatter:on
        ));
    }

    @TestFactory public Stream<DynamicTest> identifier() throws ParseError {
        return testTokens("x", Arrays.asList(
        //@formatter:off
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 0, 1, 1, "ID", null)
        //@formatter:on
        ));
    }

    @TestFactory public Stream<DynamicTest> operator() throws ParseError {
        return testTokens("x+x", Arrays.asList(
        //@formatter:off
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 0, 1, 1, "ID", null),
            new TokenDescriptor("+", IToken.TK_OPERATOR,   1, 1, 2, "Exp", "AddOperator"),
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 2, 1, 3, "ID", null)
        //@formatter:on
        ));
    }

    @TestFactory public Stream<DynamicTest> ambiguousOperator() throws ParseError {
        return testTokens("x+x+x", Arrays.asList(
        //@formatter:off
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 0, 1, 1, "ID", null),
            new TokenDescriptor("+", IToken.TK_OPERATOR,   1, 1, 2, "Exp", "AddOperator"),
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 2, 1, 3, "ID", null),
            new TokenDescriptor("+", IToken.TK_OPERATOR,   3, 1, 4, "Exp", "AddOperator"),
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 4, 1, 5, "ID", null),
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 0, 1, 1, "ID", null),
            new TokenDescriptor("+", IToken.TK_OPERATOR,   1, 1, 2, "Exp", "AddOperator"),
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 2, 1, 3, "ID", null),
            new TokenDescriptor("+", IToken.TK_OPERATOR,   3, 1, 4, "Exp", "AddOperator"),
            new TokenDescriptor("x", IToken.TK_IDENTIFIER, 4, 1, 5, "ID", null)
        //@formatter:on
        ));
{'fraction_non_alphanumeric': 0.13678682263069944, 'fraction_numerical': 0.01814275483408928, 'mean_word_length': 3.1444114737883284, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '1701019', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1320, 'n_words': 293}