Improve generator names to show that they are biased
This commit is contained in:
parent
7af3827214
commit
a9331853c0
2 changed files with 15 additions and 15 deletions
|
|
@ -17,13 +17,13 @@ let private genRemoteInteraction =
|
||||||
let private genInteraction biasTowardsLight =
|
let private genInteraction biasTowardsLight =
|
||||||
Gen.oneof [ genTimeChanged; genHumanInteraction biasTowardsLight; genRemoteInteraction ]
|
Gen.oneof [ genTimeChanged; genHumanInteraction biasTowardsLight; genRemoteInteraction ]
|
||||||
|
|
||||||
let genInteractionsExcept biasTowardsLight disqualifier =
|
let genBiasedInteractionsExcept biasTowardsLight disqualifier =
|
||||||
genInteraction biasTowardsLight
|
genInteraction biasTowardsLight
|
||||||
|> Gen.filter (not << disqualifier)
|
|> Gen.filter (not << disqualifier)
|
||||||
|> Gen.listOf
|
|> Gen.listOf
|
||||||
|
|
||||||
let genInteractions biasTowardsLight =
|
let genBiasedInteractions biasTowardsLight =
|
||||||
genInteractionsExcept biasTowardsLight (fun _ -> false)
|
genBiasedInteractionsExcept biasTowardsLight (fun _ -> false)
|
||||||
|
|
||||||
let ensureStartsWithTimeChanged (genInteractions: Gen<Interaction list>) =
|
let ensureStartsWithTimeChanged (genInteractions: Gen<Interaction list>) =
|
||||||
genInteractions
|
genInteractions
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ type NightLightTests() =
|
||||||
|
|
||||||
[<Property(Arbitrary = [| typeof<ArbitraryLight> |])>]
|
[<Property(Arbitrary = [| typeof<ArbitraryLight> |])>]
|
||||||
let ``All lights should be either off, white or yellow during the day`` (light: Light) =
|
let ``All lights should be either off, white or yellow during the day`` (light: Light) =
|
||||||
genInteractions light
|
genBiasedInteractions light
|
||||||
|> ensurePartOfDayIs Day
|
|> ensurePartOfDayIs Day
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|
|
@ -41,7 +41,7 @@ type NightLightTests() =
|
||||||
|
|
||||||
[<Property(Arbitrary = [| typeof<ArbitraryLight> |])>]
|
[<Property(Arbitrary = [| typeof<ArbitraryLight> |])>]
|
||||||
let ``All lights should be either off or red during the night`` (light: Light) =
|
let ``All lights should be either off or red during the night`` (light: Light) =
|
||||||
genInteractions light
|
genBiasedInteractions light
|
||||||
|> ensurePartOfDayIs Night
|
|> ensurePartOfDayIs Night
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|
|
@ -55,7 +55,7 @@ type NightLightTests() =
|
||||||
|
|
||||||
[<Property(Arbitrary = [| typeof<ArbitraryNonRemotelyControlledLight> |])>]
|
[<Property(Arbitrary = [| typeof<ArbitraryNonRemotelyControlledLight> |])>]
|
||||||
let ``All non-remotely controlled lights with power should be on`` (light: Light) =
|
let ``All non-remotely controlled lights with power should be on`` (light: Light) =
|
||||||
genInteractions light
|
genBiasedInteractions light
|
||||||
|> ensureLightHasPower light
|
|> ensureLightHasPower light
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|
|
@ -66,7 +66,7 @@ type NightLightTests() =
|
||||||
|
|
||||||
[<Property(Arbitrary = [| typeof<ArbitraryRemotelyControlledLight> |])>]
|
[<Property(Arbitrary = [| typeof<ArbitraryRemotelyControlledLight> |])>]
|
||||||
let ``If the remote was never used, all remote controlled lights with power should be on`` (light: Light) =
|
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
|
|> ensureLightHasPower light
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|> Arb.fromGen
|
|> 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``
|
let ``If the last button that was pressed on the remote is 'On', all remotely controlled lights with power should be on``
|
||||||
(light: Light)
|
(light: Light)
|
||||||
=
|
=
|
||||||
genInteractions light
|
genBiasedInteractions light
|
||||||
|> ensureLastRemoteInteractionIs RemotePressedOnButton
|
|> ensureLastRemoteInteractionIs RemotePressedOnButton
|
||||||
|> ensureLightHasPower light
|
|> ensureLightHasPower light
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|
|
@ -94,9 +94,9 @@ type NightLightTests() =
|
||||||
(light: Light)
|
(light: Light)
|
||||||
=
|
=
|
||||||
concatGens
|
concatGens
|
||||||
[ genInteractions light |> ensurePartOfDayIs Night
|
[ genBiasedInteractions light |> ensurePartOfDayIs Night
|
||||||
genTimeChangedToPartOfDay Day |> Gen.map List.singleton
|
genTimeChangedToPartOfDay Day |> Gen.map List.singleton
|
||||||
genInteractionsExcept light _.IsRemoteInteraction ]
|
genBiasedInteractionsExcept light _.IsRemoteInteraction ]
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|> ensureLightHasPower light
|
|> ensureLightHasPower light
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|
|
@ -110,9 +110,9 @@ type NightLightTests() =
|
||||||
(light: Light)
|
(light: Light)
|
||||||
=
|
=
|
||||||
concatGens
|
concatGens
|
||||||
[ genInteractions light
|
[ genBiasedInteractions light
|
||||||
RemoteInteraction RemotePressedOffButton |> List.singleton |> Gen.constant
|
RemoteInteraction RemotePressedOffButton |> List.singleton |> Gen.constant
|
||||||
genInteractionsExcept light (fun interaction ->
|
genBiasedInteractionsExcept light (fun interaction ->
|
||||||
interaction.IsRemoteInteraction || interaction |> isTimeChangedToPartOfDay Day) ]
|
interaction.IsRemoteInteraction || interaction |> isTimeChangedToPartOfDay Day) ]
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|> Arb.fromGen
|
|> 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``
|
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)
|
(light: Light)
|
||||||
=
|
=
|
||||||
genInteractions light
|
genBiasedInteractions light
|
||||||
|> ensureLastRemoteInteractionIs RemotePressedLeftButton
|
|> ensureLastRemoteInteractionIs RemotePressedLeftButton
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|> ensureLightHasPower light
|
|> ensureLightHasPower light
|
||||||
|
|
@ -140,9 +140,9 @@ type NightLightTests() =
|
||||||
(light: Light)
|
(light: Light)
|
||||||
=
|
=
|
||||||
concatGens
|
concatGens
|
||||||
[ genInteractions light
|
[ genBiasedInteractions light
|
||||||
RemoteInteraction RemotePressedLeftButton |> List.singleton |> Gen.constant
|
RemoteInteraction RemotePressedLeftButton |> List.singleton |> Gen.constant
|
||||||
genInteractionsExcept light (fun interaction ->
|
genBiasedInteractionsExcept light (fun interaction ->
|
||||||
interaction.IsRemoteInteraction || interaction |> isTimeChangedToPartOfDay Day) ]
|
interaction.IsRemoteInteraction || interaction |> isTimeChangedToPartOfDay Day) ]
|
||||||
|> ensureStartsWithTimeChanged
|
|> ensureStartsWithTimeChanged
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue