<commit_before>package golog

import "testing"

func TestBasic(t *testing.T) {

    // read single terms
    single := make(map[string]string)
    single[`hello. world.`] = `hello`       // read only the first term
    single[`a + b.`] = `+(a, b)`
    single[`first, second.`] = `','(first, second)`
    single[`\+ j.`] = `\+(j)`
    single[`a + b*c.`] = `+(a, *(b, c))`    // test precedence
    single[`a + b + c.`] = `+(+(a, b), c)`  // test left associativity
    single[`a^b^c.`] = `^(a, ^(b, c))`      // test right associativity
    for test, wanted := range single {
        got, err := ReadTerm(test)
        maybePanic(err)
        if got.String() != wanted {
            t.Errorf("Reading `%s` gave `%s` instead of `%s`", test, got, wanted)
        }
    }

    // read single terms (with user-defined operators)
    user := make(map[string]string)
    user[`a x b.`] = `x(a, b)`
    user[`a x b x c.`] = `x(x(a, b), c)`
    user[`two weeks.`] = `weeks(two)`
    for test, wanted := range user {
        r, err := NewTermReader(test)
        maybePanic(err)
        r.Op(400, yfx, "x")
        r.Op(200, yf, "weeks")

        got, err := r.Next()
        maybePanic(err)<commit_msg>Add tests for parsing compound terms<commit_after>package golog

import "testing"

func TestBasic(t *testing.T) {

    // read single terms
    single := make(map[string]string)
    single[`hello. world.`] = `hello`       // read only the first term
    single[`a + b.`] = `+(a, b)`
    single[`first, second.`] = `','(first, second)`
    single[`\+ j.`] = `\+(j)`
    single[`a + b*c.`] = `+(a, *(b, c))`    // test precedence
    single[`a + b + c.`] = `+(+(a, b), c)`  // test left associativity
    single[`a^b^c.`] = `^(a, ^(b, c))`      // test right associativity
    single[`x(a).`] = `x(a)`
    single[`x(a,b,c).`] = `x(','(a, ','(b, c)))`
    for test, wanted := range single {
        got, err := ReadTerm(test)
        maybePanic(err)
        if got.String() != wanted {
            t.Errorf("Reading `%s` gave `%s` instead of `%s`", test, got, wanted)
        }
    }

    // read single terms (with user-defined operators)
    user := make(map[string]string)
    user[`a x b.`] = `x(a, b)`
    user[`a x b x c.`] = `x(x(a, b), c)`
    user[`two weeks.`] = `weeks(two)`
    for test, wanted := range user {
        r, err := NewTermReader(test)
        maybePanic(err)
        r.Op(400, yfx, "x")
        r.Op(200, yf, "weeks")

        got, err := r.Next()
        maybePanic(err)
{'fraction_non_alphanumeric': 0.2131081624447125, 'fraction_numerical': 0.0048250904704463205, 'mean_word_length': 2.3085106382978724, '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': '7099089', 'n_tokens_mistral': 986, 'n_tokens_neox': 959, 'n_words': 248}