<commit_before>﻿module FSpec.SelfTests.TestRunnerSpecs
open FSpec.Core
open MatchersV3
open Dsl
open ExampleHelper
open TestContextOperations
open Helpers
open TestReporter

let beExampleWithResult f =
    function
    | Example(_,r) -> f r
    | _ -> false
    |> createSimpleMatcher

let itIsFailure = function
    | Failure(_) -> true
    | _ -> false

let itIsError = function
    | Error(_) -> true
    | _ -> false

let itRaisesException = fun _ -> raise (new System.NotImplementedException())
let beExample = beExampleWithResult (fun _ -> true)
let bePending = beExampleWithResult (fun r -> r = Pending)
let beSuccess = beExampleWithResult (fun r -> r = Success)

let doRun grp =
    let reporter = TestReporter.instance
    let data = Runner.doRun grp reporter (reporter.BeginTestRun())
    data.CallStack |> List.rev
    
let itReportsExactlyOneExample f = 
    MultipleOperations [
        it "should report exactly one example" <| fun c ->
            c |> getSubject |> should (have.exactly 1 (beExample))

        it "should report correct result" <| fun c ->
            c |> getSubject |> should (have.exactly 1 (beExampleWithResult f))
    ]

let specs =<commit_msg>TestRunnerSpecs takes advantage of Should extension<commit_after>﻿module FSpec.SelfTests.TestRunnerSpecs
open FSpec.Core
open MatchersV3
open Dsl
open ExampleHelper
open TestContextOperations
open Helpers
open TestReporter

let beExampleWithResult f =
    function
    | Example(_,r) -> f r
    | _ -> false
    |> createSimpleMatcher

let itIsFailure = function
    | Failure(_) -> true
    | _ -> false

let itIsError = function
    | Error(_) -> true
    | _ -> false

let itRaisesException = fun _ -> raise (new System.NotImplementedException())
let beExample = beExampleWithResult (fun _ -> true)
let bePending = beExampleWithResult (fun r -> r = Pending)
let beSuccess = beExampleWithResult (fun r -> r = Success)

let doRun grp =
    let reporter = TestReporter.instance
    let data = Runner.doRun grp reporter (reporter.BeginTestRun())
    data.CallStack |> List.rev
    
let itReportsExactlyOneExample f = 
    MultipleOperations [
        it "should report exactly one example" <| fun c ->
            c.Subject.Should (have.exactly 1 (beExample))

        it "should report correct result" <| fun c ->
            c.Subject.Should (have.exactly 1 (beExampleWithResult f))
    ]

let specs =
{'fraction_non_alphanumeric': 0.09060402684563758, 'fraction_numerical': 0.0025167785234899327, 'mean_word_length': 3.1842105263157894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, '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': '898309', 'n_tokens_mistral': 723, 'n_tokens_neox': 710, 'n_words': 221}