Replace the 'initial interactions' concept with ensureStartsWithTimeChanged
This allows us to generate the case again where the list *just* contains a TimeChanged interaction.
This commit is contained in:
parent
9087efaab3
commit
cefe696f97
2 changed files with 26 additions and 17 deletions
|
|
@ -2,8 +2,8 @@ module NightLight.Core.Tests.InteractionListGenerators
|
|||
|
||||
open FsCheck.FSharp
|
||||
open NightLight.Core.Models
|
||||
open NightLight.Core.Tests.GenHelpers
|
||||
open NightLight.Core.Tests.TimeChangedGenerators
|
||||
open FsCheck
|
||||
|
||||
let private genHumanInteraction biasTowardsLight =
|
||||
let genLightInteraction =
|
||||
|
|
@ -19,17 +19,17 @@ let private genHumanInteraction biasTowardsLight =
|
|||
let private genInteraction biasTowardsLight =
|
||||
Gen.oneof [ genTimeChanged; genHumanInteraction biasTowardsLight ]
|
||||
|
||||
let genInitialInteractions biasTowardsLight =
|
||||
[ genTimeChanged |> Gen.map List.singleton
|
||||
Gen.listOf <| genInteraction biasTowardsLight ]
|
||||
|> concatGens
|
||||
|
||||
let genRandomInteractionsExcept biasTowardsLight disqualifier =
|
||||
genInteraction biasTowardsLight
|
||||
|> Gen.filter (not << disqualifier)
|
||||
|> Gen.listOf
|
||||
|
||||
let genInitialInteractionsExcept biasTowardsLight disqualifier =
|
||||
[ genTimeChanged |> Gen.map List.singleton
|
||||
genRandomInteractionsExcept biasTowardsLight disqualifier ]
|
||||
|> concatGens
|
||||
let genRandomInteractions biasTowardsLight =
|
||||
genRandomInteractionsExcept biasTowardsLight (fun _ -> false)
|
||||
|
||||
let ensureStartsWithTimeChanged (genInteractions: Gen<Interaction list>) =
|
||||
genInteractions
|
||||
|> Gen.bind (fun interactions ->
|
||||
match interactions with
|
||||
| Interaction.TimeChanged _ :: _ -> Gen.constant interactions
|
||||
| _ -> genTimeChanged |> Gen.map (fun tc -> tc :: interactions))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue