<commit_before>#!/usr/bin/env bats
. "$BATS_TEST_DIRNAME"/env.sh

cd "$BATS_TMPDIR"

check_correct_output() {
    local m=$1 n=$2
    tee \
        >(wc -l >num_lines) \
        >(awk 'BEGIN{ m = 0 } { m += $1 } END { print m }' >sum) \
        >(awk '{ ++lineno; if ($1 != ($3 - $2 + 1)) { print lineno } }' >incorrect_lines) \
        #
    # check number of partitions
    local n_actual=$(cat num_lines; rm -f num_lines)
    echo "num_output_partitions: $n_actual = $n ?"
    [[ $n_actual -eq $n ]]
    # check if they all sum up to m
    local sum=$(cat sum; rm -f sum)
    echo "sum_partition_sizes: $sum = $m ?"
    [[ $sum -eq $m ]]
    # check if any line contained incorrect ranges
    if [[ -s incorrect_lines ]]; then
        echo "incorrect ranges at lines:"
        cat incorrect_lines; rm -f incorrect_lines
        false
    fi
}

@test "partition_integers usage" {
    ! partition_integers || false
    ! partition_integers 10 || false
    ! partition_integers 10 two || false
    ! partition_integers ten 2 || false
    ! partition_integers ten two || false
    partition_integers 10 2 >/dev/null
}<commit_msg>Tweaks .bats to make it pass on Travis<commit_after>#!/usr/bin/env bats
. "$BATS_TEST_DIRNAME"/env.sh

cd "$BATS_TMPDIR"

check_correct_output() {
    local m=$1 n=$2
    tee \
        >(wc -l >num_lines) \
        >(awk 'BEGIN{ m = 0 } { m += $1 } END { print m }' >sum) \
        >(awk '{ ++lineno; if ($1 != ($3 - $2 + 1)) { print lineno } }' >incorrect_lines) \
        #
    # check number of partitions
    local n_actual=$(cat num_lines; rm -f num_lines)
    echo "num_output_partitions: $n_actual = $n ?"
    [[ $n_actual -eq $n ]]
    # check if they all sum up to m
    local sum=$(cat sum; rm -f sum)
    echo "sum_partition_sizes: $sum = $m ?"
    [[ $sum -eq $m ]]
    # check if any line contained incorrect ranges
    ! [[ -s incorrect_lines ]] || {
        echo "incorrect ranges at lines:"
        cat incorrect_lines; rm -f incorrect_lines
        false
    }
}

@test "partition_integers usage" {
    ! partition_integers || false
    ! partition_integers 10 || false
    ! partition_integers 10 two || false
    ! partition_integers ten 2 || false
    ! partition_integers ten two || false
    partition_integers 10 2 >/dev/null
}
{'fraction_non_alphanumeric': 0.1356453028972783, 'fraction_numerical': 0.014047410008779631, 'mean_word_length': 2.5169753086419755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5811385', 'n_tokens_mistral': 828, 'n_tokens_neox': 779, 'n_words': 240}