Persimmon.Dried


Getting Started

An overview of Persimmon.Dried, how to download and use.

Getting Persimmon.Dried

Run the command below:

1: 
.\.nuget\NuGet.exe Install Persimmon.Dried -OutputDirectory tools -ExcludeVersion

The first step

open an fsx file and start with:

1: 
2: 
3: 
4: 
5: 
6: 
#r "Persimmon"
#r "Persimmon.Dried.Gen"
#r "Persimmon.Dried"

open Persimmon
open Persimmon.Dried

You can write the properties by using Prop.forAll, Arbitrary instances and function:

1: 
2: 
3: 
let ``reverse and reverse is original`` = Prop.forAll (Arb.list Arb.int) (fun xs ->
  List.rev (List.rev xs) = xs
)

Checking property

We load this definition in F# interactive and then invoke.

1: 
let prms = { Runner.Parameters.Default with Callback = Runner.createConsoleReporter 1 }
1: 
Runner.run "" prms ``reverse and reverse is original``
No output has been produced.

When a property fails, Persimmon.Dried displays a counterexample. For example, You define

1: 
2: 
3: 
let ``failure example`` = Prop.forAll (Arb.list Arb.int) (fun xs ->
  List.rev xs = xs
)

and check property

1: 
Runner.run "" prms ``failure example``
No output has been produced.

Checking properties by using Persimmon.Console

Now create a project and write the test by using property computation expression.

1: 
2: 
3: 
4: 
5: 
open FsRandom

let ``binding example`` = property "binding example" {
  apply ``reverse and reverse is original``
}

Run the command below:

1: 
2: 
.\.nuget\NuGet.exe Install Persimmon.Console -OutputDirectory packages -ExcludeVersion
.\packages\Persimmon.Console\tools\Persimmon.Console.exe 'input file path'
val ( reverse and reverse is original ) : obj

Full name: GettingStarted.( reverse and reverse is original )
type 'T list = List<'T>

Full name: Microsoft.FSharp.Collections.list<_>
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
val prms : obj

Full name: GettingStarted.prms
val ( failure example ) : obj

Full name: GettingStarted.( failure example )
val ( binding example ) : obj

Full name: GettingStarted.( binding example )
Fork me on GitHub