<commit_before>#include <stdlib.h>
#include <stdbool.h>
#include "ptest.h"

#include "common.h"

void test_parser_numeric(void) {
    awlenv* e = setup_test();

    AWL_ASSERT_TYPE(e, "15", AWLVAL_INT);
    AWL_ASSERT_TYPE(e, "0", AWLVAL_INT);
    AWL_ASSERT_TYPE(e, "-0", AWLVAL_INT);
    AWL_ASSERT_TYPE(e, "-15", AWLVAL_INT);
    AWL_ASSERT_TYPE(e, "2.23", AWLVAL_FLOAT);
    AWL_ASSERT_TYPE(e, ".23", AWLVAL_FLOAT);
    AWL_ASSERT_TYPE(e, "4.", AWLVAL_FLOAT);
    AWL_ASSERT_TYPE(e, "-10.9", AWLVAL_FLOAT);

    teardown_test(e);
}

void test_parser_string(void) {
    awlenv* e = setup_test();

    AWL_ASSERT_TYPE(e, "\"mystr\"", AWLVAL_STR);
    AWL_ASSERT_TYPE(e, "'mystr'", AWLVAL_STR);

    teardown_test(e);
}

void test_parser_bool(void) {
    awlenv* e = setup_test();

    AWL_ASSERT_TYPE(e, "true", AWLVAL_BOOL);
    AWL_ASSERT_TYPE(e, "false", AWLVAL_BOOL);

    teardown_test(e);
}

void test_parser_qexpr(void) {
    awlenv* e = setup_test();

    AWL_ASSERT_TYPE(e, "{}", AWLVAL_QEXPR);
    AWL_ASSERT_TYPE(e, "{true}", AWLVAL_QEXPR);
    AWL_ASSERT_TYPE(e, "{1 2 3}", AWLVAL_QEXPR);
    AWL_ASSERT_TYPE(e, "{foo bar baz}", AWLVAL_QEXPR);

    teardown_test(e);
}

void test_parser_eexpr(void) {
    awlenv* e = setup_test();

    // EExprs may only appear within QExprs
    AWL_ASSERT_TYPE(e, "\\(+ 2 3)", AWLVAL_ERR);
    AWL_ASSERT_TYPE(e, "(+ \\(+ 2 3) 5)", AWLVAL_ERR);

    teardown_test(e);
}

void test_parser_cexpr(void) {
    awlenv* e = setup_test();

    // CExprs may only appear within QExprs
    AWL_ASSERT_TYPE(e, "@(+ 2 3)", AWLVAL_ERR);
    AWL_ASSERT_TYPE(e, "(+ @(+ 2 3) 5)", AWLVAL_ERR);

    teardown_test(e);
}

void suite_parser(void) {
    pt_add_test(test_parser_numeric, "Test Numeric", "Suite Parser");
    pt_add_test(test_parser_string, "Test String", "Suite Parser");
    pt_add_test(test_parser_bool, "Test Bool", "Suite Parser");
    pt_add_test(test_parser_qexpr, "Test QExpr", "Suite Parser");
    pt_add_test(test_parser_eexpr, "Test EExpr", "Suite Parser");
    pt_add_test(test_parser_cexpr, "Test CExpr", "Suite Parser");
}
<commit_msg>Expand parser tests for EExprs<commit_after>#include <stdlib.h>
#include <stdbool.h>
#include "ptest.h"

#include "common.h"

void test_parser_numeric(void) {
    awlenv* e = setup_test();

    AWL_ASSERT_TYPE(e, "15", AWLVAL_INT);
    AWL_ASSERT_TYPE(e, "0", AWLVAL_INT);
    AWL_ASSERT_TYPE(e, "-0", AWLVAL_INT);
    AWL_ASSERT_TYPE(e, "-15", AWLVAL_INT);
    AWL_ASSERT_TYPE(e, "2.23", AWLVAL_FLOAT);
    AWL_ASSERT_TYPE(e, ".23", AWLVAL_FLOAT);
    AWL_ASSERT_TYPE(e, "4.", AWLVAL_FLOAT);
    AWL_ASSERT_TYPE(e, "-10.9", AWLVAL_FLOAT);

    teardown_test(e);
}

void test_parser_string(void) {
    awlenv* e = setup_test();

    AWL_ASSERT_TYPE(e, "\"mystr\"", AWLVAL_STR);
    AWL_ASSERT_TYPE(e, "'mystr'", AWLVAL_STR);

    teardown_test(e);
}

void test_parser_bool(void) {
    awlenv* e = setup_test();

    AWL_ASSERT_TYPE(e, "true", AWLVAL_BOOL);
    AWL_ASSERT_TYPE(e, "false", AWLVAL_BOOL);

    teardown_test(e);
}

void test_parser_qexpr(void) {
    awlenv* e = setup_test();

    AWL_ASSERT_TYPE(e, "{}", AWLVAL_QEXPR);
    AWL_ASSERT_TYPE(e, "{true}", AWLVAL_QEXPR);
    AWL_ASSERT_TYPE(e, "{1 2 3}", AWLVAL_QEXPR);
    AWL_ASSERT_TYPE(e, "{foo bar baz}", AWLVAL_QEXPR);

    teardown_test(e);
}

void test_parser_eexpr(void) {
    awlenv* e = setup_test();

    // EExprs may only appear within QExprs
    AWL_ASSERT_TYPE(e, "{x y \\(+ 2 4)}", AWLVAL_QEXPR);
    AWL_ASSERT_TYPE(e, "\\(+ 2 3)", AWLVAL_ERR);
    AWL_ASSERT_TYPE(e, "(+ \\(+ 2 3) 5)", AWLVAL_ERR);

    teardown_test(e);
}

void test_parser_cexpr(void) {
    awlenv* e = setup_test();

    // CExprs may only appear within QExprs
    AWL_ASSERT_TYPE(e, "{x y @(first {1 2 3})}", AWLVAL_QEXPR);
    AWL_ASSERT_TYPE(e, "@(first {1 2 3})", AWLVAL_ERR);
    AWL_ASSERT_TYPE(e, "(+ @(first {1 2 3}) 5)", AWLVAL_ERR);

    teardown_test(e);
}

void suite_parser(void) {
    pt_add_test(test_parser_numeric, "Test Numeric", "Suite Parser");
    pt_add_test(test_parser_string, "Test String", "Suite Parser");
    pt_add_test(test_parser_bool, "Test Bool", "Suite Parser");
    pt_add_test(test_parser_qexpr, "Test QExpr", "Suite Parser");
    pt_add_test(test_parser_eexpr, "Test EExpr", "Suite Parser");
    pt_add_test(test_parser_cexpr, "Test CExpr", "Suite Parser");
}

{'fraction_non_alphanumeric': 0.1625978811607554, 'fraction_numerical': 0.014509442653155229, 'mean_word_length': 4.38833746898263, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5673381', 'n_tokens_mistral': 1923, 'n_tokens_neox': 1840, 'n_words': 336}