From 79405b38417ed7d4f741b50ead94fb1eb1979d91 Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Fri, 16 Jan 2026 20:25:33 +0100 Subject: [PATCH] Make biasing towards a light optional --- .../InteractionListGenerators.fs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/NightLight.Core.Tests/InteractionListGenerators.fs b/NightLight.Core.Tests/InteractionListGenerators.fs index 85fd5dd..286bfd2 100644 --- a/NightLight.Core.Tests/InteractionListGenerators.fs +++ b/NightLight.Core.Tests/InteractionListGenerators.fs @@ -5,8 +5,10 @@ open NightLight.Core.Models open NightLight.Core.Tests.TimeChangedGenerators open FsCheck -let private genHumanInteraction biasTowardsLight = - Gen.oneof [ Gen.constant biasTowardsLight; Gen.elements lights ] +let private genHumanInteraction maybeBiasTowardsLight = + match maybeBiasTowardsLight with + | Some biasTowardsLight -> Gen.oneof [ Gen.constant biasTowardsLight; Gen.elements lights ] + | None -> Gen.elements lights |> Gen.bind (fun light -> Gen.elements [ LightPoweredOn light; LightPoweredOff light ]) |> Gen.map Interaction.HumanInteraction @@ -14,11 +16,15 @@ let private genRemoteInteraction = Gen.elements [ RemotePressedOnButton; RemotePressedOffButton; RemotePressedLeftButton ] |> Gen.map RemoteInteraction -let private genInteraction biasTowardsLight = - Gen.oneof [ genTimeChanged; genHumanInteraction biasTowardsLight; genRemoteInteraction ] +let private genInteraction maybeBiasTowardsLight = + Gen.oneof + [ genTimeChanged + genHumanInteraction maybeBiasTowardsLight + genRemoteInteraction ] let genBiasedInteractionsExcept biasTowardsLight disqualifier = - genInteraction biasTowardsLight + Some biasTowardsLight + |> genInteraction |> Gen.filter (not << disqualifier) |> Gen.listOf