From 75e1170cf21e6adc868d52632ea92812004f1af6 Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Tue, 6 Jan 2026 12:40:57 +0100 Subject: [PATCH] Improve names for generators --- .../InteractionListGenerators.fs | 4 ++-- NightLight.Core.Tests/NightLightTests.fs | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/NightLight.Core.Tests/InteractionListGenerators.fs b/NightLight.Core.Tests/InteractionListGenerators.fs index b41e517..8ebeba9 100644 --- a/NightLight.Core.Tests/InteractionListGenerators.fs +++ b/NightLight.Core.Tests/InteractionListGenerators.fs @@ -22,7 +22,7 @@ let private genInteractionsListThatStartsWithTimeChanged = [ genTimeChanged |> Gen.map List.singleton; Gen.listOf genInteraction ] |> concatGens -let genInteractionListThatStartsWithTimeChangedAndEndsWith (endsWith: Interaction) = +let genInitialInteractionsAndEndWith (endsWith: Interaction) = let genNonTrivialList = genInteractionsListThatStartsWithTimeChanged |> Gen.map (fun lst -> lst @ [ endsWith ]) @@ -33,5 +33,5 @@ let genInteractionListThatStartsWithTimeChangedAndEndsWith (endsWith: Interactio Gen.frequency [ 1, genTrivialList; 9, genNonTrivialList ] | _ -> genNonTrivialList -let genInteractionListExcept disqualifier = +let genInteractionsExcept disqualifier = genInteraction |> Gen.filter (not << disqualifier) |> Gen.listOf diff --git a/NightLight.Core.Tests/NightLightTests.fs b/NightLight.Core.Tests/NightLightTests.fs index d0889b6..5d09395 100644 --- a/NightLight.Core.Tests/NightLightTests.fs +++ b/NightLight.Core.Tests/NightLightTests.fs @@ -40,8 +40,8 @@ type NightLightTests() = [] let ``All lights that are on should be white or yellow during the day`` () = concatGens - [ Gen.bind genInteractionListThatStartsWithTimeChangedAndEndsWith genTimeChangedToDay - genInteractionListExcept isTimeChangedToNight ] + [ Gen.bind genInitialInteractionsAndEndWith genTimeChangedToDay + genInteractionsExcept isTimeChangedToNight ] |> Arb.fromGen |> Prop.forAll <| fun interactions -> @@ -53,8 +53,8 @@ type NightLightTests() = [] let ``All lights that are on should be red during the night`` () = concatGens - [ Gen.bind genInteractionListThatStartsWithTimeChangedAndEndsWith genTimeChangedToNight - genInteractionListExcept isTimeChangedToDay ] + [ Gen.bind genInitialInteractionsAndEndWith genTimeChangedToNight + genInteractionsExcept isTimeChangedToDay ] |> Arb.fromGen |> Prop.forAll <| fun interactions -> @@ -68,8 +68,8 @@ type NightLightTests() = () = concatGens - [ genInteractionListThatStartsWithTimeChangedAndEndsWith (HumanInteraction RemotePressedOnButton) - genInteractionListExcept ((=) (HumanInteraction RemotePressedOffButton)) ] + [ genInitialInteractionsAndEndWith (HumanInteraction RemotePressedOnButton) + genInteractionsExcept ((=) (HumanInteraction RemotePressedOffButton)) ] |> Arb.fromGen |> Prop.forAll <| fun interactions -> @@ -86,8 +86,8 @@ type NightLightTests() = () = concatGens - [ genInteractionListThatStartsWithTimeChangedAndEndsWith (HumanInteraction RemotePressedOffButton) - genInteractionListExcept (fun interaction -> + [ genInitialInteractionsAndEndWith (HumanInteraction RemotePressedOffButton) + genInteractionsExcept (fun interaction -> interaction = HumanInteraction RemotePressedOnButton || interaction |> isTimeChangedToDay) ] |> Arb.fromGen @@ -105,13 +105,13 @@ type NightLightTests() = = let genInitialInteractionsListThatEndsWithTransitionToDay = concatGens - [ Gen.bind genInteractionListThatStartsWithTimeChangedAndEndsWith genTimeChangedToNight - genInteractionListExcept isTimeChangedToDay + [ Gen.bind genInitialInteractionsAndEndWith genTimeChangedToNight + genInteractionsExcept isTimeChangedToDay Gen.map List.singleton genTimeChangedToDay ] concatGens [ genInitialInteractionsListThatEndsWithTransitionToDay - genInteractionListExcept ((=) (HumanInteraction RemotePressedOffButton)) ] + genInteractionsExcept ((=) (HumanInteraction RemotePressedOffButton)) ] |> Arb.fromGen |> Prop.forAll <| fun interactions ->