bytebuster: (ITCrowd-Moss)
[personal profile] bytebuster
Юніт-тести від модуля FSharpx (github)

module GayBar =
    open Club
    let checkGender (p: Person) =
        match p.Gender with
        | Male -> Success p
        | _ -> Failure "Men only"

    
    let costToEnter p =
        [checkAge; checkClothes; checkSobriety; checkGender]
        |> Validation.mapM (fun check -> check p |> Choice.mapSecond NonEmptyList.singleton)
        |> Choice.map (function x::_ -> decimal x.Age + 1.5m | [] -> failwith "costToEnter")
    
[<Test>]
let part3() =
    GayBar.costToEnter { Person.Gender = Male; Age = 59; Clothes = set ["Jeans"]; Sobriety = Paralytic }
    |> shouldEqual (Failure (NonEmptyList.create "Too old!" ["Smarten up!"; "Sober up!"]))
    
    GayBar.costToEnter { Person.Gender = Male; Age = 25; Clothes = set ["Tie"]; Sobriety = Sober } |> shouldEqual (Success 26.5m)
Сторінку створено Субота, 28 Червень 2025 14:26

Травень 2025

П В С Ч П С Н
   1 234
567891011
12131415161718
192021222324 25
262728293031 
Створено з Dreamwidth Studios

За стиль дякувати