<commit_before>﻿module FSpec.Core.Dsl

let pending = fun _ -> raise PendingError
type Operation =
    | AddExampleOperation of Example.T
    | AddExampleGroupOperation of ExampleGroup.T
    | AddSetupOperation of ExampleGroup.TestFunc
    | AddTearDownOperation of ExampleGroup.TestFunc
    | MultipleOperations of Operation list
    static member ApplyMetaData metaData op =
        match op with
        | AddExampleOperation e ->
            e |> Example.addMetaData metaData |> AddExampleOperation
        | AddExampleGroupOperation g ->
            g |> ExampleGroup.addMetaData metaData |> AddExampleGroupOperation
        | _ -> failwith "not supported"
    static member (==>) (md, op) = Operation.ApplyMetaData md op

let applyGroup s f = function
    | AddExampleGroupOperation grp -> s grp
    | _ -> f ()

let it name func = AddExampleOperation <| Example.create name func

let rec applyOperation grp op =
    match op with
    | AddExampleOperation example -> grp |> ExampleGroup.addExample example
    | AddExampleGroupOperation childGrp -> grp |> ExampleGroup.addChildGroup childGrp
    | AddSetupOperation f -> grp |> ExampleGroup.addSetup f
    | AddTearDownOperation f -> grp |> ExampleGroup.addTearDown f
    | MultipleOperations o -> o |> List.fold applyOperation grp

let describe name operations =
    let grp = ExampleGroup.create name
    operations |> List.fold applyOperation grp
    |> AddExampleGroupOperation
    
let context = describe
    
let before f = AddSetupOperation f

let after f = AddTearDownOperation f

let subject f = before (fun ctx -> ctx.SetSubject (f ctx))
let (++) = MetaData.(++)
<commit_msg>Moved folder function to inner level<commit_after>﻿module FSpec.Core.Dsl

let pending = fun _ -> raise PendingError

type Operation =
    | AddExampleOperation of Example.T
    | AddExampleGroupOperation of ExampleGroup.T
    | AddSetupOperation of ExampleGroup.TestFunc
    | AddTearDownOperation of ExampleGroup.TestFunc
    | MultipleOperations of Operation list
    static member ApplyMetaData metaData op =
        match op with
        | AddExampleOperation e ->
            e |> Example.addMetaData metaData |> AddExampleOperation
        | AddExampleGroupOperation g ->
            g |> ExampleGroup.addMetaData metaData |> AddExampleGroupOperation
        | _ -> failwith "not supported"
    static member (==>) (md, op) = Operation.ApplyMetaData md op

let applyGroup s f = function
    | AddExampleGroupOperation grp -> s grp
    | _ -> f ()

let it name func = AddExampleOperation <| Example.create name func

let describe name operations =
    let rec applyOperation grp op =
        match op with
        | AddExampleOperation example -> grp |> ExampleGroup.addExample example
        | AddExampleGroupOperation childGrp -> grp |> ExampleGroup.addChildGroup childGrp
        | AddSetupOperation f -> grp |> ExampleGroup.addSetup f
        | AddTearDownOperation f -> grp |> ExampleGroup.addTearDown f
        | MultipleOperations o -> o |> List.fold applyOperation grp

    let grp = ExampleGroup.create name
    operations |> List.fold applyOperation grp
    |> AddExampleGroupOperation
    
let context = describe
let before f = AddSetupOperation f
let after f = AddTearDownOperation f
let subject f = before (fun ctx -> ctx.SetSubject (f ctx))
let (++) = MetaData.(++)

{'fraction_non_alphanumeric': 0.07454162909528103, 'fraction_numerical': 0.0, 'mean_word_length': 3.2340966921119594, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '2035735', 'n_tokens_mistral': 893, 'n_tokens_neox': 897, 'n_words': 293}