Compare commits
2 commits
c09915ac60
...
56ef751145
| Author | SHA1 | Date | |
|---|---|---|---|
| 56ef751145 | |||
| eaae9fe9b8 |
5 changed files with 46 additions and 0 deletions
13
NightLight.Core.Tests/MutationCaseAttribute.fs
Normal file
13
NightLight.Core.Tests/MutationCaseAttribute.fs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
namespace Mutannot
|
||||||
|
|
||||||
|
open System
|
||||||
|
|
||||||
|
[<AttributeUsage(AttributeTargets.Method, AllowMultiple = true)>]
|
||||||
|
type MutationCaseAttribute(id: string, file: string, line: int, find: string, replace: string) =
|
||||||
|
inherit Attribute()
|
||||||
|
|
||||||
|
member _.Id = id
|
||||||
|
member _.File = file
|
||||||
|
member _.Line = line
|
||||||
|
member _.Find = find
|
||||||
|
member _.Replace = replace
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="MutationCaseAttribute.fs" />
|
||||||
<Compile Include="FakeHome.fs" />
|
<Compile Include="FakeHome.fs" />
|
||||||
<Compile Include="GenHelpers.fs" />
|
<Compile Include="GenHelpers.fs" />
|
||||||
<Compile Include="InteractionListHelpers.fs" />
|
<Compile Include="InteractionListHelpers.fs" />
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
namespace NightLight.Core.Tests
|
namespace NightLight.Core.Tests
|
||||||
|
|
||||||
|
open Mutannot
|
||||||
open NightLight.Core.Core
|
open NightLight.Core.Core
|
||||||
open NightLight.Core.Tests.InteractionListGenerators
|
open NightLight.Core.Tests.InteractionListGenerators
|
||||||
open NightLight.Core.Tests.InteractionListHelpers
|
open NightLight.Core.Tests.InteractionListHelpers
|
||||||
|
|
@ -31,6 +32,7 @@ type NightLightTests() =
|
||||||
fakeHome
|
fakeHome
|
||||||
|
|
||||||
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>]
|
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>]
|
||||||
|
[<MutationCase("all-lights-right-color-night-is-yellow", "NightLight.Core/Moods.fs", 16, "Red", "Yellow")>]
|
||||||
let ``All lights should either be off or have the right color`` (interactions: Interaction list) =
|
let ``All lights should either be off or have the right color`` (interactions: Interaction list) =
|
||||||
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
||||||
let partOfDay = getPartOfDayAfterInteractions interactions
|
let partOfDay = getPartOfDayAfterInteractions interactions
|
||||||
|
|
@ -48,6 +50,7 @@ type NightLightTests() =
|
||||||
|> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0)
|
|> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0)
|
||||||
|
|
||||||
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |], MaxTest = 500)>]
|
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |], MaxTest = 500)>]
|
||||||
|
[<MutationCase("brightness-command-off-by-one", "NightLight.Core/ZigbeeCommands.fs", 40, "Brightness b -> b", "Brightness b -> b + 1")>]
|
||||||
let ``All lights should either be off or have a brightness that fits its color`` (interactions: Interaction list) =
|
let ``All lights should either be off or have a brightness that fits its color`` (interactions: Interaction list) =
|
||||||
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
||||||
let time = getTimeAfterInteractions interactions |> _.TimeOfDay
|
let time = getTimeAfterInteractions interactions |> _.TimeOfDay
|
||||||
|
|
@ -88,6 +91,7 @@ type NightLightTests() =
|
||||||
|> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0)
|
|> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0)
|
||||||
|
|
||||||
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |], MaxTest = 500)>]
|
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |], MaxTest = 500)>]
|
||||||
|
[<MutationCase("lights-default-to-off", "NightLight.Core/NightLightStateMachine.fs", 145, "light, On", "light, Off")>]
|
||||||
let ``All lights with power should have the correct state`` (interactions: Interaction list) =
|
let ``All lights with power should have the correct state`` (interactions: Interaction list) =
|
||||||
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
||||||
|
|
||||||
|
|
|
||||||
22
flake.lock
generated
22
flake.lock
generated
|
|
@ -42,6 +42,27 @@
|
||||||
"url": "https://codeberg.org/svenvanheugten/git-check-assertions.git"
|
"url": "https://codeberg.org/svenvanheugten/git-check-assertions.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mutannot": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1777439386,
|
||||||
|
"narHash": "sha256-nTBcu7NsN1jwoXr8SoKaW+0EPb5klTU6SSWuXOeuEuA=",
|
||||||
|
"ref": "main",
|
||||||
|
"rev": "1019d3c5d04d441d12b915876110f7493270b988",
|
||||||
|
"revCount": 19,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.memcmp.org/svenvanheugten/mutannot.git"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"ref": "main",
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.memcmp.org/svenvanheugten/mutannot.git"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1773507054,
|
"lastModified": 1773507054,
|
||||||
|
|
@ -62,6 +83,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"git-check-assertions": "git-check-assertions",
|
"git-check-assertions": "git-check-assertions",
|
||||||
|
"mutannot": "mutannot",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inputs.flake-utils.follows = "flake-utils";
|
inputs.flake-utils.follows = "flake-utils";
|
||||||
};
|
};
|
||||||
|
mutannot = {
|
||||||
|
url = "git+https://git.memcmp.org/svenvanheugten/mutannot.git?ref=main";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
outputs =
|
outputs =
|
||||||
{
|
{
|
||||||
|
|
@ -14,6 +18,7 @@
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
flake-utils,
|
flake-utils,
|
||||||
git-check-assertions,
|
git-check-assertions,
|
||||||
|
mutannot,
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
flake-utils.lib.eachDefaultSystem (
|
||||||
system:
|
system:
|
||||||
|
|
@ -26,6 +31,7 @@
|
||||||
packages = [
|
packages = [
|
||||||
pkgs.dotnet-sdk_10
|
pkgs.dotnet-sdk_10
|
||||||
git-check-assertions.packages.${system}.default
|
git-check-assertions.packages.${system}.default
|
||||||
|
mutannot.packages.${system}.default
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue