Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz authored Jan 24, 2018
1 parent e75f89e commit f86fd17
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ It can be parametrized using its second argument.
export interface Parameters {
seed?: number; // optional, initial seed of the generator: Date.now() by default
num_runs?: number; // optional, number of runs before success: 100 by default
logger?: (v: string) => void; // optional, log output: console.log by default
}
```

Expand Down Expand Up @@ -106,6 +107,47 @@ interface Details {
function check<Ts>(property: IProperty<Ts>, params?: Parameters);
```

- `fc.sample`: sample generated values of an `Arbitrary<T>` or `Property<T>`

It builds an array containing all the values that would have been generated for the equivalent test.

It also accept `Parameters` as configuration in order to help you diagnose the shape of the inputs that will be received by your property.

```typescript
function sample<Ts>(generator: Arbitrary<Ts>): Ts[];
function sample<Ts>(generator: Arbitrary<Ts>, params: Parameters): Ts[];
function sample<Ts>(generator: Arbitrary<Ts>, num_generated: number): Ts[];

function sample<Ts>(generator: IProperty<Ts>): Ts[];
function sample<Ts>(generator: IProperty<Ts>, params: Parameters): Ts[];
function sample<Ts>(generator: IProperty<Ts>, num_generated: number): Ts[];
```

- `fc.statistics`: classify the values produced by an `Arbitrary<T>` or `Property<T>`

It provides useful statistics concerning generated values.
In order to be able to gather those statistics it has to be provided with a classifier function that can classify the generated value in zero, one or more categories (free labels).

It also accept `Parameters` as configuration in order to help you diagnose the shape of the inputs that will be received by your property.

Statistics are dumped into `console.log` but can be redirected to another source by modifying the `logger` key in `Parameters`.

```typescript
function statistics<Ts>(generator: Arbitrary<Ts>, classify: (v: Ts) => string): void;
function statistics<Ts>(generator: Arbitrary<Ts>, classify: (v: Ts) => string, params: Parameters): void;
function statistics<Ts>(generator: Arbitrary<Ts>, classify: (v: Ts) => string, num_generated: number): void;
function statistics<Ts>(generator: Arbitrary<Ts>, classify: (v: Ts) => string[]): void;
function statistics<Ts>(generator: Arbitrary<Ts>, classify: (v: Ts) => string[], params: Parameters): void;
function statistics<Ts>(generator: Arbitrary<Ts>, classify: (v: Ts) => string[], num_generated: number): void;

function statistics<Ts>(generator: IProperty<Ts>, classify: (v: Ts) => string): void;
function statistics<Ts>(generator: IProperty<Ts>, classify: (v: Ts) => string, params: Parameters): void;
function statistics<Ts>(generator: IProperty<Ts>, classify: (v: Ts) => string, num_generated: number): void;
function statistics<Ts>(generator: IProperty<Ts>, classify: (v: Ts) => string[]): void;
function statistics<Ts>(generator: IProperty<Ts>, classify: (v: Ts) => string[], params: Parameters): void;
function statistics<Ts>(generator: IProperty<Ts>, classify: (v: Ts) => string[], num_generated: number): void;
```

## Arbitraries

Arbitraries are responsible for the random generation (but deterministic) and shrink of datatypes.
Expand Down

0 comments on commit f86fd17

Please sign in to comment.