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
TThe 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
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
tcTestCase
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
Returns
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
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
fFunc<T, TResult>
Returns
- MappedGenerator<T, TResult>
Type Parameters
TResult
PrintAsRepr()
This generator, printing its values with Repr(object?).
public PrintableGenerator<T> PrintAsRepr()
Returns
PrintWith(Action<T, Printer>)
This generator, printing its values with print.
public PrintableGenerator<T> PrintWith(Action<T, Printer> print)
Parameters
Returns
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
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
Returns
- PrintableGenerator<TResult>
Type Parameters
TOtherTResult
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
selectorFunc<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)