<commit_before>module FSpec.Matchers

type MatchResult =
    | MatchSuccess of obj
    | MatchFail of obj

type MatchType =
    | Should
    | ShouldNot

[<AbstractClass>]
type Matcher<'TActual> () = 
    abstract member ApplyActual<'TResult> : (MatchResult -> 'TResult) -> 'TActual -> 'TResult
    abstract member ExpectationMsgForShould : string
    abstract member ExpectationMsgForShouldNot : string
    [<System.Obsolete("Use ExpectationMsgForShould instead")>]
    member this.FailureMsgForShould = this.ExpectationMsgForShould
    [<System.Obsolete("Use ExpectationMsgForShouldNot instead")>]
    member this.FailureMsgForShouldNot = this.ExpectationMsgForShouldNot
    static member IsMatch (matcher:Matcher<'TActual>) actual =
        let resultToBool = function | MatchSuccess _ -> true | _ -> false
        actual |> matcher.ApplyActual resultToBool
    member self.MessageFor = 
        function
            | Should -> self.ExpectationMsgForShould
            | ShouldNot -> self.ExpectationMsgForShouldNot

let applyMatcher<'T,'U> (matcher: Matcher<'T>) f (a : 'T) : 'U =
    matcher.ApplyActual f a

let createFullMatcher<'T> 
        (f : 'T -> MatchResult) 
        (shouldMsg : string) 
        (shouldNotMsg : string) =
    { new Matcher<'T> () with
        member __.ApplyActual g actual = f actual |> g
        member __.ExpectationMsgForShould = shouldMsg
        member __.ExpectationMsgForShouldNot = shouldNotMsg
    }

let createMatcher<'T> (f : 'T -> MatchResult) (shouldMsg : string) =
    createFullMatcher f shouldMsg (sprintf "not %s" shouldMsg)

/// Helps create a matcher, that uses a child matcher for some verification.<commit_msg>Removed unnecessary generic definition<commit_after>module FSpec.Matchers

type MatchResult =
    | MatchSuccess of obj
    | MatchFail of obj

type MatchType =
    | Should
    | ShouldNot

[<AbstractClass>]
type Matcher<'TActual> () = 
    abstract member ApplyActual : (MatchResult -> 'a) -> 'TActual -> 'a
    abstract member ExpectationMsgForShould : string
    abstract member ExpectationMsgForShouldNot : string
    [<System.Obsolete("Use ExpectationMsgForShould instead")>]
    member this.FailureMsgForShould = this.ExpectationMsgForShould
    [<System.Obsolete("Use ExpectationMsgForShouldNot instead")>]
    member this.FailureMsgForShouldNot = this.ExpectationMsgForShouldNot
    static member IsMatch (matcher:Matcher<'TActual>) actual =
        let resultToBool = function | MatchSuccess _ -> true | _ -> false
        actual |> matcher.ApplyActual resultToBool
    member self.MessageFor = 
        function
            | Should -> self.ExpectationMsgForShould
            | ShouldNot -> self.ExpectationMsgForShouldNot

let applyMatcher<'T,'U> (matcher: Matcher<'T>) f (a : 'T) : 'U =
    matcher.ApplyActual f a

let createFullMatcher<'T> 
        (f : 'T -> MatchResult) 
        (shouldMsg : string) 
        (shouldNotMsg : string) =
    { new Matcher<'T> () with
        member __.ApplyActual g actual = f actual |> g
        member __.ExpectationMsgForShould = shouldMsg
        member __.ExpectationMsgForShouldNot = shouldNotMsg
    }

let createMatcher<'T> (f : 'T -> MatchResult) (shouldMsg : string) =
    createFullMatcher f shouldMsg (sprintf "not %s" shouldMsg)

/// Helps create a matcher, that uses a child matcher for some verification.
{'fraction_non_alphanumeric': 0.09565217391304348, 'fraction_numerical': 0.0, 'mean_word_length': 3.3664921465968587, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 46, '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': '7343346', 'n_tokens_mistral': 966, 'n_tokens_neox': 968, 'n_words': 256}