generated from goatcorp/SamplePlugin
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start moving tests to f# and property tests
- Loading branch information
Showing
6 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0-windows</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
<GenerateProgramFile>false</GenerateProgramFile> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Utils\Curry.fs" /> | ||
<None Include="Utils\UtilGenerator.fsx" /> | ||
<Compile Include="Utils\FsCheckUtils.fs" /> | ||
<Compile Include="UtilsTests.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CSharpFunctionalExtensions" Version="2.40.3" /> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="FsCheck" Version="2.16.6" /> | ||
<PackageReference Include="FsCheck.Xunit" Version="2.16.6" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1"/> | ||
<PackageReference Include="Moq" Version="4.20.70" /> | ||
<PackageReference Include="xunit" Version="2.4.2"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ScoutHelper\ScoutHelper.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module TestProject1.Utils.Curry | ||
|
||
let curry f' a b = f' (a, b) | ||
let curry2 f' a b = f' (a, b) | ||
let curry3 f' a b c = f' (a, b, c) | ||
let curry4 f' a b c d = f' (a, b, c, d) | ||
let curry5 f' a b c d e = f' (a, b, c, d, e) | ||
let curry6 f' a b c d e f = f' (a, b, c, d, e, f) | ||
let curry7 f' a b c d e f g = f' (a, b, c, d, e, f, g) | ||
let curry8 f' a b c d e f g h = f' (a, b, c, d, e, f, g, h) | ||
|
||
let uncurry f' (a, b) = f' a b | ||
let uncurry2 f' (a, b) = f' a b | ||
let uncurry3 f' (a, b, c) = f' a b c | ||
let uncurry4 f' (a, b, c, d) = f' a b c d | ||
let uncurry5 f' (a, b, c, d, e) = f' a b c d e | ||
let uncurry6 f' (a, b, c, d, e, f) = f' a b c d e f | ||
let uncurry7 f' (a, b, c, d, e, f, g) = f' a b c d e f g | ||
let uncurry8 f' (a, b, c, d, e, f, g, h) = f' a b c d e f g h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
module TestProject1.Utils.FsCheckUtils | ||
|
||
open Curry | ||
open FsCheck | ||
|
||
let gen2 a b = gen { | ||
let! a' = a | ||
let! b' = b | ||
return (a', b') | ||
} | ||
let gen3 a b c = gen { | ||
let! a' = a | ||
let! b' = b | ||
let! c' = c | ||
return (a', b', c') | ||
} | ||
let gen4 a b c d = gen { | ||
let! a' = a | ||
let! b' = b | ||
let! c' = c | ||
let! d' = d | ||
return (a', b', c', d') | ||
} | ||
let gen5 a b c d e = gen { | ||
let! a' = a | ||
let! b' = b | ||
let! c' = c | ||
let! d' = d | ||
let! e' = e | ||
return (a', b', c', d', e') | ||
} | ||
let gen6 a b c d e f = gen { | ||
let! a' = a | ||
let! b' = b | ||
let! c' = c | ||
let! d' = d | ||
let! e' = e | ||
let! f' = f | ||
return (a', b', c', d', e', f') | ||
} | ||
let gen7 a b c d e f g = gen { | ||
let! a' = a | ||
let! b' = b | ||
let! c' = c | ||
let! d' = d | ||
let! e' = e | ||
let! f' = f | ||
let! g' = g | ||
return (a', b', c', d', e', f', g') | ||
} | ||
let gen8 a b c d e f g h = gen { | ||
let! a' = a | ||
let! b' = b | ||
let! c' = c | ||
let! d' = d | ||
let! e' = e | ||
let! f' = f | ||
let! g' = g | ||
let! h' = h | ||
return (a', b', c', d', e', f', g', h') | ||
} | ||
|
||
let map2 a b = | ||
gen2 | ||
(Arb.toGen a) | ||
(Arb.toGen b) | ||
|> Arb.fromGen | ||
let map3 a b c = | ||
gen3 | ||
(Arb.toGen a) | ||
(Arb.toGen b) | ||
(Arb.toGen c) | ||
|> Arb.fromGen | ||
let map4 a b c d = | ||
gen4 | ||
(Arb.toGen a) | ||
(Arb.toGen b) | ||
(Arb.toGen c) | ||
(Arb.toGen d) | ||
|> Arb.fromGen | ||
let map5 a b c d e = | ||
gen5 | ||
(Arb.toGen a) | ||
(Arb.toGen b) | ||
(Arb.toGen c) | ||
(Arb.toGen d) | ||
(Arb.toGen e) | ||
|> Arb.fromGen | ||
let map6 a b c d e f = | ||
gen6 | ||
(Arb.toGen a) | ||
(Arb.toGen b) | ||
(Arb.toGen c) | ||
(Arb.toGen d) | ||
(Arb.toGen e) | ||
(Arb.toGen f) | ||
|> Arb.fromGen | ||
let map7 a b c d e f g = | ||
gen7 | ||
(Arb.toGen a) | ||
(Arb.toGen b) | ||
(Arb.toGen c) | ||
(Arb.toGen d) | ||
(Arb.toGen e) | ||
(Arb.toGen f) | ||
(Arb.toGen g) | ||
|> Arb.fromGen | ||
let map8 a b c d e f g h = | ||
gen8 | ||
(Arb.toGen a) | ||
(Arb.toGen b) | ||
(Arb.toGen c) | ||
(Arb.toGen d) | ||
(Arb.toGen e) | ||
(Arb.toGen f) | ||
(Arb.toGen g) | ||
(Arb.toGen h) | ||
|> Arb.fromGen | ||
|
||
let forAll2 a b f' = Prop.forAll (map2 a b) (uncurry2 f') | ||
let forAll3 a b c f' = Prop.forAll (map3 a b c) (uncurry3 f') | ||
let forAll4 a b c d f' = Prop.forAll (map4 a b c d) (uncurry4 f') | ||
let forAll5 a b c d e f' = Prop.forAll (map5 a b c d e) (uncurry5 f') | ||
let forAll6 a b c d e f f' = Prop.forAll (map6 a b c d e f) (uncurry6 f') | ||
let forAll7 a b c d e f g f' = Prop.forAll (map7 a b c d e f g) (uncurry7 f') | ||
let forAll8 a b c d e f g h f' = Prop.forAll (map8 a b c d e f g h) (uncurry8 f') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
let map = List.map | ||
|
||
let internal inc (n:int) : int list = | ||
let rec inc' cur total = | ||
match cur with | ||
| _ when cur = total -> [] | ||
| _ -> cur :: (inc' (cur + 1) total) | ||
inc' 0 n | ||
let internal inc1 n = inc n |> map ((+) 1) | ||
let internal chars n = | ||
(inc n) | ||
|> map (fun i -> char (97 + i)) | ||
|> map (fun c -> new string([|c|])) | ||
|
||
let internal printFunc n f = | ||
inc1 n | ||
|> map (fun i -> f i <| chars i) | ||
|
||
let _ = printFunc 8 <| fun i cs -> | ||
printfn | ||
"let forAll%i %s f' = Prop.forAll (map%i %s) (uncurry%i f')" | ||
i | ||
(String.concat " " cs) | ||
i | ||
(String.concat " " cs) | ||
i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module TestProject1.UtilsTests | ||
|
||
open | ||
|
||
open Xunit | ||
open FsCheck | ||
|
||
[<Fact>] | ||
let ``My test`` () = | ||
Prop.forAll |