<commit_before>﻿namespace Fuchu

open System
open System.Linq
open System.Runtime.CompilerServices

type TestCode = unit -> unit

type Test = 
    | TestCase of TestCode
    | TestList of Test list
    | TestLabel of string * Test

[<AutoOpen>]
[<Extension>]
module F =

    let withLabel label test = TestLabel (label, test)

    type TestResult = 
        | Passed
        | Failed of string
        | Exception of exn

    let testResultToString =
        function
        | Passed -> "Passed"
        | Failed error -> "Failed: " + error
        | Exception e -> "Exception: " + e.ToString()

    type TestResultCounts = {
        Passed: int
        Failed: int
        Errored: int
    }
        with override x.ToString() =
                        sprintf "%d tests run: %d passed, %d failed, %d errored\n"
                            (x.Errored + x.Failed + x.Passed)
                            x.Passed
                            x.Failed
                            x.Errored

    let testResultCountsToErrorLevel (c: TestResultCounts) =
        (if c.Failed > 0 then 1 else 0) ||| (if c.Errored > 0 then 2 else 0)

    let sumTestResults results =
        let counts = 
            results 
            |> Seq.map snd
            |> Seq.countBy (function
                            | Passed -> 0
                            | Failed _ -> 1
                            | Exception _ -> 2)
            |> dict
        let get i = <commit_msg>count addition<commit_after>﻿namespace Fuchu

open System
open System.Linq
open System.Runtime.CompilerServices

type TestCode = unit -> unit

type Test = 
    | TestCase of TestCode
    | TestList of Test list
    | TestLabel of string * Test

[<AutoOpen>]
[<Extension>]
module F =

    let withLabel label test = TestLabel (label, test)

    type TestResult = 
        | Passed
        | Failed of string
        | Exception of exn

    let testResultToString =
        function
        | Passed -> "Passed"
        | Failed error -> "Failed: " + error
        | Exception e -> "Exception: " + e.ToString()

    type TestResultCounts = {
        Passed: int
        Failed: int
        Errored: int
    }
        with 
        override x.ToString() =
                        sprintf "%d tests run: %d passed, %d failed, %d errored\n"
                            (x.Errored + x.Failed + x.Passed)
                            x.Passed
                            x.Failed
                            x.Errored
        static member (+) (c1: TestResultCounts, c2: TestResultCounts) = 
            { Passed = c1.Passed + c2.Passed
              Failed = c1.Failed + c2.Failed
              Errored = c1.Errored + c2.Errored }
            

    let testResultCountsToErrorLevel (c: TestResultCounts) =
        (if c.Failed > 0 then 1 else 0) ||| (if c.Errored > 0 then 2 else 0)

    let sumTestResults results =
        let counts = 
            results 
            |> Seq.map snd
            |> Seq.countBy (function
                            | Passed -> 0
                            | Failed _ -> 1
                            | Exception _ -> 2)
            |> dict
        let get i = 
{'fraction_non_alphanumeric': 0.0848966613672496, 'fraction_numerical': 0.008267090620031796, 'mean_word_length': 1.313235294117647, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, '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': '5060907', 'n_tokens_mistral': 922, 'n_tokens_neox': 854, 'n_words': 262}