Table of Contents

Class Generator<T>

Namespace
Hegel
Assembly
Hegel.dll

Draws values of T from a TestCase. Implement DoDraw(TestCase) for a generator that draws through other generators or the engine primitives, or derive from PrintableGenerator<T> to print as you draw. Built-in generators are in Generators.

public abstract class Generator<T>

Type Parameters

T

The type of value drawn.

Inheritance
Generator<T>
Derived
Inherited Members

Properties

Label

The span label the engine files this generator's draws under. Defaults to a label derived from the class's full name.

public virtual ulong Label { get; }

Property Value

ulong

Methods

DoDraw(TestCase)

Draw one value. Called inside a span labelled Label: draw from another generator through DrawSilent<T>(Generator<T>), which opens its span, rather than by calling its hook.

protected abstract T DoDraw(TestCase tc)

Parameters

tc TestCase

Returns

T

Filter(Func<T, bool>)

Draw from this generator until predicate accepts the value.

public virtual PrintableGenerator<T> Filter(Func<T, bool> predicate)

Parameters

predicate Func<T, bool>

Returns

PrintableGenerator<T>

FlatMap<TResult>(Func<T, Generator<TResult>>)

Draw from this generator and then from the generator f gives for the value.

public PrintableGenerator<TResult> FlatMap<TResult>(Func<T, Generator<TResult>> f)

Parameters

f Func<T, Generator<TResult>>

Returns

PrintableGenerator<TResult>

Type Parameters

TResult

Map<TResult>(Func<T, TResult>)

Draw from this generator and apply f.

public MappedGenerator<T, TResult> Map<TResult>(Func<T, TResult> f)

Parameters

f Func<T, TResult>

Returns

MappedGenerator<T, TResult>

Type Parameters

TResult

PrintAsRepr()

This generator, printing its values with Repr(object?).

public PrintableGenerator<T> PrintAsRepr()

Returns

PrintableGenerator<T>

PrintWith(Action<T, Printer>)

This generator, printing its values with print.

public PrintableGenerator<T> PrintWith(Action<T, Printer> print)

Parameters

print Action<T, Printer>

Returns

PrintableGenerator<T>

SelectMany<TResult>(Func<T, Generator<TResult>>)

FlatMap<TResult>(Func<T, Generator<TResult>>) under the name C# query expressions use.

public PrintableGenerator<TResult> SelectMany<TResult>(Func<T, Generator<TResult>> selector)

Parameters

selector Func<T, Generator<TResult>>

Returns

PrintableGenerator<TResult>

Type Parameters

TResult

SelectMany<TOther, TResult>(Func<T, Generator<TOther>>, Func<T, TOther, TResult>)

FlatMap<TResult>(Func<T, Generator<TResult>>), combining both values with resultSelector: a query's second from.

public PrintableGenerator<TResult> SelectMany<TOther, TResult>(Func<T, Generator<TOther>> selector, Func<T, TOther, TResult> resultSelector)

Parameters

selector Func<T, Generator<TOther>>
resultSelector Func<T, TOther, TResult>

Returns

PrintableGenerator<TResult>

Type Parameters

TOther
TResult

Select<TResult>(Func<T, TResult>)

Map<TResult>(Func<T, TResult>) under the name C# query expressions use, so a select clause maps the values: from x in gen select x * 2.

public MappedGenerator<T, TResult> Select<TResult>(Func<T, TResult> selector)

Parameters

selector Func<T, TResult>

Returns

MappedGenerator<T, TResult>

Type Parameters

TResult

Where(Func<T, bool>)

Filter(Func<T, bool>) under the name C# query expressions use, so a where clause filters the values: from x in gen where x > 0 select x.

public PrintableGenerator<T> Where(Func<T, bool> predicate)

Parameters

predicate Func<T, bool>

Returns

PrintableGenerator<T>