<commit_before>set ::num_tests 0
set ::num_passed 0
set ::num_failed 0
set ::num_skipped 0
set ::num_aborted 0
set ::tests_failed {}

proc fail {msg} {
    error "assertion:$msg"
}

proc assert {condition} {
    if {![uplevel 1 [list expr $condition]]} {
        error "assertion:Expected condition '$condition' to be true ([uplevel 1 [list subst -nocommands $condition]])"
    }
}

proc assert_no_match {pattern value} {
    if {[string match $pattern $value]} {
        error "assertion:Expected '$value' to not match '$pattern'"
    }
}

proc assert_match {pattern value} {
    if {![string match $pattern $value]} {
        error "assertion:Expected '$value' to match '$pattern'"
    }
}

proc assert_equal {expected value {detail ""}} {
    if {$expected ne $value} {
        if {$detail ne ""} {
            set detail " (detail: $detail)"
        }
        error "assertion:Expected '$value' to be equal to '$expected'$detail"
    }
}<commit_msg>test infra: improve prints on failed assertions<commit_after>set ::num_tests 0
set ::num_passed 0
set ::num_failed 0
set ::num_skipped 0
set ::num_aborted 0
set ::tests_failed {}

proc fail {msg} {
    error "assertion:$msg"
}

proc assert {condition} {
    if {![uplevel 1 [list expr $condition]]} {
        set context "(context: [info frame -1])"
        error "assertion:Expected [uplevel 1 [list subst -nocommands $condition]] $context"
    }
}

proc assert_no_match {pattern value} {
    if {[string match $pattern $value]} {
        set context "(context: [info frame -1])"
        error "assertion:Expected '$value' to not match '$pattern' $context"
    }
}

proc assert_match {pattern value} {
    if {![string match $pattern $value]} {
        set context "(context: [info frame -1])"
        error "assertion:Expected '$value' to match '$pattern' $context"
    }
}

proc assert_equal {value expected {detail ""}} {
    if {$expected ne $value} {
        if {$detail ne ""} {
            set detail "(detail: $detail)"
        } else {
            set detail "(context: [info frame -1])"
        }
        error "assertion:Expected '$value' to be equal to '$expected' $detail"
    }
}

proc assert_lessthan {value expected {detail ""}} {
    if {!($value < $expected)} {
        if {$detail ne ""} {
            set detail "(detail: $detail)"
        } else {
            set detail "(context: [info frame -1])"
        }
        error "assertion:Expected '$value' to be lessthan to '$expected' $detail"
    }
}

proc assert_range {value min max {detail ""}} {
    if {!($value <= $max && $value >= $min)} {
        if {$detail ne ""} {
            set detail "(detail: $detail)"
        } else {
            set detail "(context: [info frame -1])"
        }
        error "assertion:Expected '$value' to be between to '$min' and '$max' $detail"
    }
}
{'fraction_non_alphanumeric': 0.14595170454545456, 'fraction_numerical': 0.007102272727272727, 'mean_word_length': 2.7509986684420773, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '4786912', 'n_tokens_mistral': 880, 'n_tokens_neox': 862, 'n_words': 295}