From a9331853c069ab7e77395f1489d6d459e6972402 Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Fri, 16 Jan 2026 20:23:13 +0100 Subject: [PATCH] Improve generator names to show that they are biased --- .../InteractionListGenerators.fs | 6 ++--- NightLight.Core.Tests/NightLightTests.fs | 24 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/NightLight.Core.Tests/InteractionListGenerators.fs b/NightLight.Core.Tests/InteractionListGenerators.fs index 53dee85..85fd5dd 100644 --- a/NightLight.Core.Tests/InteractionListGenerators.fs +++ b/NightLight.Core.Tests/InteractionListGenerators.fs @@ -17,13 +17,13 @@ let private genRemoteInteraction = let private genInteraction biasTowardsLight = Gen.oneof [ genTimeChanged; genHumanInteraction biasTowardsLight; genRemoteInteraction ] -let genInteractionsExcept biasTowardsLight disqualifier = +let genBiasedInteractionsExcept biasTowardsLight disqualifier = genInteraction biasTowardsLight |> Gen.filter (not << disqualifier) |> Gen.listOf -let genInteractions biasTowardsLight = - genInteractionsExcept biasTowardsLight (fun _ -> false) +let genBiasedInteractions biasTowardsLight = + genBiasedInteractionsExcept biasTowardsLight (fun _ -> false) let ensureStartsWithTimeChanged (genInteractions: Gen) = genInteractions diff --git a/NightLight.Core.Tests/NightLightTests.fs b/NightLight.Core.Tests/NightLightTests.fs index 1f65249..6109f17 100644 --- a/NightLight.Core.Tests/NightLightTests.fs +++ b/NightLight.Core.Tests/NightLightTests.fs @@ -27,7 +27,7 @@ type NightLightTests() = [ |])>] let ``All lights should be either off, white or yellow during the day`` (light: Light) = - genInteractions light + genBiasedInteractions light |> ensurePartOfDayIs Day |> ensureStartsWithTimeChanged |> Arb.fromGen @@ -41,7 +41,7 @@ type NightLightTests() = [ |])>] let ``All lights should be either off or red during the night`` (light: Light) = - genInteractions light + genBiasedInteractions light |> ensurePartOfDayIs Night |> ensureStartsWithTimeChanged |> Arb.fromGen @@ -55,7 +55,7 @@ type NightLightTests() = [ |])>] let ``All non-remotely controlled lights with power should be on`` (light: Light) = - genInteractions light + genBiasedInteractions light |> ensureLightHasPower light |> ensureStartsWithTimeChanged |> Arb.fromGen @@ -66,7 +66,7 @@ type NightLightTests() = [ |])>] let ``If the remote was never used, all remote controlled lights with power should be on`` (light: Light) = - genInteractionsExcept light _.IsRemoteInteraction + genBiasedInteractionsExcept light _.IsRemoteInteraction |> ensureLightHasPower light |> ensureStartsWithTimeChanged |> Arb.fromGen @@ -79,7 +79,7 @@ type NightLightTests() = let ``If the last button that was pressed on the remote is 'On', all remotely controlled lights with power should be on`` (light: Light) = - genInteractions light + genBiasedInteractions light |> ensureLastRemoteInteractionIs RemotePressedOnButton |> ensureLightHasPower light |> ensureStartsWithTimeChanged @@ -94,9 +94,9 @@ type NightLightTests() = (light: Light) = concatGens - [ genInteractions light |> ensurePartOfDayIs Night + [ genBiasedInteractions light |> ensurePartOfDayIs Night genTimeChangedToPartOfDay Day |> Gen.map List.singleton - genInteractionsExcept light _.IsRemoteInteraction ] + genBiasedInteractionsExcept light _.IsRemoteInteraction ] |> ensureStartsWithTimeChanged |> ensureLightHasPower light |> Arb.fromGen @@ -110,9 +110,9 @@ type NightLightTests() = (light: Light) = concatGens - [ genInteractions light + [ genBiasedInteractions light RemoteInteraction RemotePressedOffButton |> List.singleton |> Gen.constant - genInteractionsExcept light (fun interaction -> + genBiasedInteractionsExcept light (fun interaction -> interaction.IsRemoteInteraction || interaction |> isTimeChangedToPartOfDay Day) ] |> ensureStartsWithTimeChanged |> Arb.fromGen @@ -125,7 +125,7 @@ type NightLightTests() = let ``If the last button that was pressed on the remote is 'Left', all left-side remotely controlled lights with power should be on`` (light: Light) = - genInteractions light + genBiasedInteractions light |> ensureLastRemoteInteractionIs RemotePressedLeftButton |> ensureStartsWithTimeChanged |> ensureLightHasPower light @@ -140,9 +140,9 @@ type NightLightTests() = (light: Light) = concatGens - [ genInteractions light + [ genBiasedInteractions light RemoteInteraction RemotePressedLeftButton |> List.singleton |> Gen.constant - genInteractionsExcept light (fun interaction -> + genBiasedInteractionsExcept light (fun interaction -> interaction.IsRemoteInteraction || interaction |> isTimeChangedToPartOfDay Day) ] |> ensureStartsWithTimeChanged |> Arb.fromGen