Skip to content

Commit

Permalink
Add a few missing methods to Fluent.Arbitrary.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtschelfthout committed Sep 11, 2021
1 parent 52127b5 commit 6dc45a1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions FsCheck Release Notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### 3.0.0-beta2 - To be released

* Fixed bug that caused exceptions not to be propagated to output correctly.

* Added a few missing methods in `Fluent.Arbitrary`.


### 3.0.0-beta1 - 5 September 2021

* *Backwards incompatible*: Refactor and split of the `Gen` and `Arbitrary` APIs into `FsCheck.FSharp` and `FsCheck.Fluent`. This is a first step in splitting the entire API into a functional (for F# consumers) and fluent (for C# and VB.NET consumers) interface. This should be clearer for both kinds of consumers.
Expand Down
2 changes: 1 addition & 1 deletion src/FsCheck/FSharp.Arbitrary.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module Arb =
override __.Shrinker b =
b |> a.Shrinker |> Seq.filter pred }

/// Generates 2-tuples.
let zip(t1: Arbitrary<'T1>, t2: Arbitrary<'T2>) =
let generator = Gen.zip t1.Generator t2.Generator
let shrinker (l,r) = Seq.zip (t1.Shrinker l) (t2.Shrinker r)
Expand Down
19 changes: 19 additions & 0 deletions src/FsCheck/Fluent.Arbitrary.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,23 @@ type Arb private() =
static member MapFilter (arb:Arbitrary<'T>, map: Func<_,_>, filter: Func<_,_>) =
Arb.mapFilter map.Invoke filter.Invoke arb

/// Generates 2-tuples.
[<Extension>]
static member Zip(t1: Arbitrary<'T1>, t2: Arbitrary<'T2>) =
let generator = Gen.Zip(t1.Generator, t2.Generator)
let shrinker (struct (l,r)) = Seq.map2 (fun l r -> struct (l,r)) (t1.Shrinker l) (t2.Shrinker r)
Arb.fromGenShrink(generator, shrinker)

/// Generates one-dimensional arrays.
/// The length of the generated array is between 0 and size.
/// The sum of the sizes of the elements is equal to the size of the generated array.
[<Extension>]
static member Array (elements: Arbitrary<'T>) =
Arb.array elements

/// Generates nullable values that are null 1/8 of the time.
[<Extension>]
static member Nullable (value: Arbitrary<'T>) =
Arb.nullable value


0 comments on commit 6dc45a1

Please sign in to comment.