Skip to content

Commit

Permalink
Add more ForAll overloads.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtschelfthout committed Feb 25, 2024
1 parent 4712907 commit 9ba133e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 7 deletions.
9 changes: 8 additions & 1 deletion examples/FsCheck.CSharpExamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,14 @@ where x > 5
ArbMap.Default.GeneratorFor<int>().Sample(10);
ArbMap.Default.GeneratorFor<int>().Sample(10, size:25);

Console.WriteLine("Press any key...");

Prop.ForAll<DoNotSize<int>>(async i =>
{
await Task.Delay(10);
return true.Collect(i.Item);
}).QuickCheck();

Console.WriteLine("Press any key...");
Console.ReadKey();
}

Expand Down
56 changes: 50 additions & 6 deletions src/FsCheck/Fluent.Prop.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open System
open System.Runtime.CompilerServices
open System.Threading.Tasks

open FsCheck
open FsCheck.FSharp
Expand All @@ -15,33 +16,57 @@ type Prop private() =

static member ForAll(arb:Arbitrary<'Value>, body:Func<'Value,bool>) = Prop.forAll arb body.Invoke

static member ForAll(arb:Arbitrary<'Value>, body:Func<'Value,Threading.Tasks.Task>) = forAll arb body.Invoke
static member ForAll(arb:Arbitrary<'Value>, body:Func<'Value,Property>) = forAll arb body.Invoke

static member ForAll(arb:Arbitrary<'Value>, body:Func<'Value,Threading.Tasks.Task<bool>>) = forAll arb body.Invoke

static member ForAll(arb:Arbitrary<'Value>, body:Func<'Value,Property>) = forAll arb body.Invoke
static member ForAll(arb:Arbitrary<'Value>, body:Func<'Value,Task>) = forAll arb body.Invoke

static member ForAll(arb:Arbitrary<'Value>, body:Func<'Value,Task<bool>>) = forAll arb body.Invoke

static member ForAll(arb:Arbitrary<'Value>, body:Func<'Value,Task<Property>>) = forAll arb body.Invoke


static member ForAll(body:Action<'Value>) = property body.Invoke

static member ForAll(body:Func<'Value,bool>) = property body.Invoke

static member ForAll(body:Func<'Value,Threading.Tasks.Task>) = property body.Invoke
static member ForAll(body:Func<'Value,Property>) = property body.Invoke

static member ForAll(body:Func<'Value,Threading.Tasks.Task<bool>>) = property body.Invoke

static member ForAll(body:Func<'Value,Property>) = property body.Invoke
static member ForAll(body:Func<'Value,Task>) = property body.Invoke

static member ForAll(body:Func<'Value,Task<bool>>) = property body.Invoke

static member ForAll(body:Func<'Value,Task<Property>>) = property body.Invoke


static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>, body:Action<'V1,'V2>) = forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> body.Invoke(v1,v2)))

static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>, body:Func<'V1,'V2,bool>) = forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> body.Invoke(v1,v2)))

static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>, body:Func<'V1,'V2,Property>) = forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> body.Invoke(v1,v2)))


static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>, body:Func<'V1,'V2, Task>) = forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> body.Invoke(v1,v2)))

static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>, body:Func<'V1,'V2,Task<bool>>) = forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> body.Invoke(v1,v2)))

static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>, body:Func<'V1,'V2,Task<Property>>) = forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> body.Invoke(v1,v2)))


static member ForAll(body:Action<'V1,'V2>) = property body.Invoke

static member ForAll(body:Func<'V1,'V2,bool>) = property body.Invoke

static member ForAll(body:Func<'V1,'V2,Property>) = property body.Invoke


static member ForAll(body:Func<'V1,'V2, Task>) = property body.Invoke

static member ForAll(body:Func<'V1,'V2,Task<bool>>) = property body.Invoke

static member ForAll(body:Func<'V1,'V2,Task<Property>>) = property body.Invoke


static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>,arb3:Arbitrary<'V3>, body:Action<'V1,'V2,'V3>) =
forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> forAll arb3 (fun v3 -> body.Invoke(v1,v2,v3))))
Expand All @@ -52,12 +77,31 @@ type Prop private() =
static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>,arb3:Arbitrary<'V3>, body:Func<'V1,'V2,'V3,Property>) =
forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> forAll arb3 (fun v3 -> body.Invoke(v1,v2,v3))))


static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>,arb3:Arbitrary<'V3>, body:Func<'V1,'V2,'V3, Task>) =
forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> forAll arb3 (fun v3 -> body.Invoke(v1,v2,v3))))

static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>,arb3:Arbitrary<'V3>, body:Func<'V1,'V2,'V3,Task<bool>>) =
forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> forAll arb3 (fun v3 -> body.Invoke(v1,v2,v3))))

static member ForAll(arb1:Arbitrary<'V1>,arb2:Arbitrary<'V2>,arb3:Arbitrary<'V3>, body:Func<'V1,'V2,'V3,Task<Property>>) =
forAll arb1 (fun v1 -> forAll arb2 (fun v2 -> forAll arb3 (fun v3 -> body.Invoke(v1,v2,v3))))


static member ForAll(body:Action<'V1,'V2,'V3>) = property body.Invoke

static member ForAll(body:Func<'V1,'V2,'V3,bool>) = property body.Invoke

static member ForAll(body:Func<'V1,'V2,'V3,Property>) = property body.Invoke


static member ForAll(body:Func<'V1,'V2,'V3,Task>) = property body.Invoke

static member ForAll(body:Func<'V1,'V2,'V3,Func<bool>>) = property body.Invoke

static member ForAll(body:Func<'V1,'V2,'V3,Func<Property>>) = property body.Invoke


/// Turns a testable type into a property.
[<Extension>]
static member ToProperty (testable:bool) =
Expand Down

0 comments on commit 9ba133e

Please sign in to comment.