Improve names for generators

This commit is contained in:
Sven van Heugten 2026-01-06 12:40:57 +01:00
parent d6820f5c02
commit 75e1170cf2
2 changed files with 13 additions and 13 deletions

View file

@ -22,7 +22,7 @@ let private genInteractionsListThatStartsWithTimeChanged =
[ genTimeChanged |> Gen.map List.singleton; Gen.listOf genInteraction ] [ genTimeChanged |> Gen.map List.singleton; Gen.listOf genInteraction ]
|> concatGens |> concatGens
let genInteractionListThatStartsWithTimeChangedAndEndsWith (endsWith: Interaction) = let genInitialInteractionsAndEndWith (endsWith: Interaction) =
let genNonTrivialList = let genNonTrivialList =
genInteractionsListThatStartsWithTimeChanged genInteractionsListThatStartsWithTimeChanged
|> Gen.map (fun lst -> lst @ [ endsWith ]) |> Gen.map (fun lst -> lst @ [ endsWith ])
@ -33,5 +33,5 @@ let genInteractionListThatStartsWithTimeChangedAndEndsWith (endsWith: Interactio
Gen.frequency [ 1, genTrivialList; 9, genNonTrivialList ] Gen.frequency [ 1, genTrivialList; 9, genNonTrivialList ]
| _ -> genNonTrivialList | _ -> genNonTrivialList
let genInteractionListExcept disqualifier = let genInteractionsExcept disqualifier =
genInteraction |> Gen.filter (not << disqualifier) |> Gen.listOf genInteraction |> Gen.filter (not << disqualifier) |> Gen.listOf

View file

@ -40,8 +40,8 @@ type NightLightTests() =
[<Property>] [<Property>]
let ``All lights that are on should be white or yellow during the day`` () = let ``All lights that are on should be white or yellow during the day`` () =
concatGens concatGens
[ Gen.bind genInteractionListThatStartsWithTimeChangedAndEndsWith genTimeChangedToDay [ Gen.bind genInitialInteractionsAndEndWith genTimeChangedToDay
genInteractionListExcept isTimeChangedToNight ] genInteractionsExcept isTimeChangedToNight ]
|> Arb.fromGen |> Arb.fromGen
|> Prop.forAll |> Prop.forAll
<| fun interactions -> <| fun interactions ->
@ -53,8 +53,8 @@ type NightLightTests() =
[<Property>] [<Property>]
let ``All lights that are on should be red during the night`` () = let ``All lights that are on should be red during the night`` () =
concatGens concatGens
[ Gen.bind genInteractionListThatStartsWithTimeChangedAndEndsWith genTimeChangedToNight [ Gen.bind genInitialInteractionsAndEndWith genTimeChangedToNight
genInteractionListExcept isTimeChangedToDay ] genInteractionsExcept isTimeChangedToDay ]
|> Arb.fromGen |> Arb.fromGen
|> Prop.forAll |> Prop.forAll
<| fun interactions -> <| fun interactions ->
@ -68,8 +68,8 @@ type NightLightTests() =
() ()
= =
concatGens concatGens
[ genInteractionListThatStartsWithTimeChangedAndEndsWith (HumanInteraction RemotePressedOnButton) [ genInitialInteractionsAndEndWith (HumanInteraction RemotePressedOnButton)
genInteractionListExcept ((=) (HumanInteraction RemotePressedOffButton)) ] genInteractionsExcept ((=) (HumanInteraction RemotePressedOffButton)) ]
|> Arb.fromGen |> Arb.fromGen
|> Prop.forAll |> Prop.forAll
<| fun interactions -> <| fun interactions ->
@ -86,8 +86,8 @@ type NightLightTests() =
() ()
= =
concatGens concatGens
[ genInteractionListThatStartsWithTimeChangedAndEndsWith (HumanInteraction RemotePressedOffButton) [ genInitialInteractionsAndEndWith (HumanInteraction RemotePressedOffButton)
genInteractionListExcept (fun interaction -> genInteractionsExcept (fun interaction ->
interaction = HumanInteraction RemotePressedOnButton interaction = HumanInteraction RemotePressedOnButton
|| interaction |> isTimeChangedToDay) ] || interaction |> isTimeChangedToDay) ]
|> Arb.fromGen |> Arb.fromGen
@ -105,13 +105,13 @@ type NightLightTests() =
= =
let genInitialInteractionsListThatEndsWithTransitionToDay = let genInitialInteractionsListThatEndsWithTransitionToDay =
concatGens concatGens
[ Gen.bind genInteractionListThatStartsWithTimeChangedAndEndsWith genTimeChangedToNight [ Gen.bind genInitialInteractionsAndEndWith genTimeChangedToNight
genInteractionListExcept isTimeChangedToDay genInteractionsExcept isTimeChangedToDay
Gen.map List.singleton genTimeChangedToDay ] Gen.map List.singleton genTimeChangedToDay ]
concatGens concatGens
[ genInitialInteractionsListThatEndsWithTransitionToDay [ genInitialInteractionsListThatEndsWithTransitionToDay
genInteractionListExcept ((=) (HumanInteraction RemotePressedOffButton)) ] genInteractionsExcept ((=) (HumanInteraction RemotePressedOffButton)) ]
|> Arb.fromGen |> Arb.fromGen
|> Prop.forAll |> Prop.forAll
<| fun interactions -> <| fun interactions ->