Invert helper function

This commit is contained in:
Sven van Heugten 2026-01-05 23:04:18 +01:00
parent b9a318a5f1
commit 9bc76cdf8e
2 changed files with 5 additions and 5 deletions

View file

@ -28,12 +28,12 @@ let private genInteractionsListThatStartsWithTimeChanged =
return firstInteraction :: remainingInteractions return firstInteraction :: remainingInteractions
} }
let genInteractionListContaining containingInteraction afterFilter = let genInteractionListContaining containingInteraction disqualifiedAfter =
gen { gen {
let genNonTrivialList = let genNonTrivialList =
gen { gen {
let! before = genInteractionsListThatStartsWithTimeChanged let! before = genInteractionsListThatStartsWithTimeChanged
let! after = Gen.listOf (genInteraction |> Gen.filter afterFilter) let! after = Gen.listOf (genInteraction |> Gen.filter (not << disqualifiedAfter))
return before @ containingInteraction :: after return before @ containingInteraction :: after
} }

View file

@ -26,7 +26,7 @@ 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`` () =
genTimeChangedToDay genTimeChangedToDay
|> Gen.bind (fun timeChangedToDay -> genInteractionListContaining timeChangedToDay (not << _.IsTimeChanged)) |> Gen.bind (fun timeChangedToDay -> genInteractionListContaining timeChangedToDay _.IsTimeChanged)
|> Arb.fromGen |> Arb.fromGen
|> Prop.forAll |> Prop.forAll
<| fun interactions -> <| fun interactions ->
@ -36,7 +36,7 @@ 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`` () =
genTimeChangedToNight genTimeChangedToNight
|> Gen.bind (fun timeChangedToNight -> genInteractionListContaining timeChangedToNight (not << _.IsTimeChanged)) |> Gen.bind (fun timeChangedToNight -> genInteractionListContaining timeChangedToNight _.IsTimeChanged)
|> Arb.fromGen |> Arb.fromGen
|> Prop.forAll |> Prop.forAll
<| fun interactions -> <| fun interactions ->
@ -49,7 +49,7 @@ type NightLightTests() =
= =
genInteractionListContaining genInteractionListContaining
(HumanInteraction RemotePressedOffButton) (HumanInteraction RemotePressedOffButton)
((<>) (HumanInteraction RemotePressedOnButton)) ((=) (HumanInteraction RemotePressedOnButton))
|> Arb.fromGen |> Arb.fromGen
|> Prop.forAll |> Prop.forAll
<| fun interactions -> <| fun interactions ->