generators library
The generator catalog, on its own.
Everything package:hegel/hegel.dart exports about making values, for
anyone who would rather prefix them than import forty names:
import 'package:hegel/hegel.dart';
import 'package:hegel/generators.dart' as gen;
final names = gen.text(minLength: 1);
property('a greeting keeps the name it was given', (tc) {
final name = tc.draw(names, name: 'name');
expect(greet(name), contains(name));
});
The same generators either way; this is a spelling, not a second API.
Pool comes with them, which is not itself a generator: it is where
pool.reusable and pool.consumed come from, and putting a pool on the
far side of an import from the generators it hands out would be a seam
across one idea.
Classes
-
DeferredGenerator<
T> - The generator deferred returns, before and after it is defined.
-
Generator<
T> -
A recipe for values of type
T. -
Pool<
T> - A set of values a stateful test made, that the engine can choose among.
- TextGenerator
- Generates strings over an alphabet.
Functions
-
bigIntegers(
{BigInt? min, BigInt? max}) → Generator< BigInt> -
Generates integers of any width between
minandmaxinclusive. -
booleans(
{double probability = 0.5}) → Generator< bool> -
Generates true with probability
probability, false otherwise. -
bytes(
{int minLength = 0, int? maxLength}) → Generator< Uint8List> -
Generates byte strings of
minLengthtomaxLengthbytes. -
characters(
{String? codec, int? minCodepoint, int? maxCodepoint, List< String> ? categories, List<String> ? excludeCategories, String? includeCharacters, String? excludeCharacters}) → TextGenerator - Generates single characters, drawn the way text draws them.
-
composite<
T> (T build(TestCase testCase)) → Generator< T> -
Generates values
buildputs together out of draws of its own. -
dates(
{DateTime? min, DateTime? max}) → Generator< DateTime> -
Generates dates between
minandmaxinclusive. -
dateTimes(
{DateTime? min, DateTime? max}) → Generator< DateTime> -
Generates dates and times between
minandmaxinclusive. -
deferred<
T> () → DeferredGenerator< T> - A generator that stands in for one not written yet.
-
domains(
{int maxLength = 255}) → Generator< String> -
Generates fully-qualified domain names of at most
maxLengthcharacters. -
doubles(
{double min = double.negativeInfinity, double max = double.infinity, bool? allowNan, bool? allowInfinity, bool excludeMin = false, bool excludeMax = false}) → Generator< double> -
Generates doubles between
minandmax. -
durations(
{Duration? min, Duration? max}) → Generator< Duration> -
Generates durations between
minandmaxinclusive. -
emails(
) → Generator< String> - Generates email addresses, per RFC 5321 and 5322.
-
fromRegex(
String pattern, {bool fullMatch = true, TextGenerator? alphabet}) → Generator< String> -
Generates strings matching
pattern, in Pythonresyntax. -
integers(
{int? min, int? max}) → Generator< int> -
Generates integers between
minandmaxinclusive. -
ipAddresses(
{InternetAddressType? type}) → Generator< InternetAddress> -
Generates IP addresses of
type, or of either kind when none is given. -
just<
T> (T value) → Generator< T> -
Generates
valueand nothing else. -
lists<
T> (Generator< T> elements, {int minLength = 0, int? maxLength, bool unique = false}) → Generator<List< T> > -
Generates lists of what
elementsgenerates. -
maps<
K, V> (Generator< K> keys, Generator<V> values, {int minLength = 0, int? maxLength}) → Generator<Map< K, V> > -
Generates maps of what
keysandvaluesgenerate. -
oneOf<
T> (List< Generator< options, {List<T> >int> ? weights}) → Generator<T> -
Generates values from whichever of
optionseach case picks. -
optional<
T> (Generator< T> value) → Generator<T?> -
Generates values from
value, or null. -
sampledFrom<
T> (List< T> values) → Generator<T> -
Generates values picked from
values. -
sets<
T> (Generator< T> elements, {int minLength = 0, int? maxLength}) → Generator<Set< T> > -
Generates sets of what
elementsgenerates. -
text(
{int minLength = 0, int? maxLength, String? codec, int? minCodepoint, int? maxCodepoint, List< String> ? categories, List<String> ? excludeCategories, String? includeCharacters, String? excludeCharacters}) → TextGenerator -
Generates strings of
minLengthtomaxLengthcharacters. -
times(
{Duration? min, Duration? max}) → Generator< Duration> -
Generates times of day between
minandmaxinclusive. -
tuple2<
A, B> (Generator< A> first, Generator<B> second) → Generator<(A, B)> -
Generates pairs of what
firstandsecondgenerate. -
tuple3<
A, B, C> (Generator< A> first, Generator<B> second, Generator<C> third) → Generator<(A, B, C)> -
Generates triples of what
first,secondandthirdgenerate. -
tuple4<
A, B, C, D> (Generator< A> first, Generator<B> second, Generator<C> third, Generator<D> fourth) → Generator<(A, B, C, D)> -
Generates quadruples of what
firsttofourthgenerate. -
urls(
) → Generator< String> - Generates http and https URLs, per RFC 3986.
-
uuids(
{int? version}) → Generator< String> - Generates UUIDs in the canonical 8-4-4-4-12 form.