Beispiel #1
0
        public string FromNative(string var)
        {
            if (IGen == null)
            {
                return(String.Empty);
            }

            if (ElementType != String.Empty)
            {
                string args = (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
                if (IGen.QualifiedName == "GLib.PtrArray")
                {
                    return(String.Format("({0}[]) GLib.Marshaller.PtrArrayToArray ({1}, {2}, typeof({0}))", ElementType, var, args));
                }
                else
                {
                    return(String.Format("({0}[]) GLib.Marshaller.ListPtrToArray ({1}, typeof({2}), {3}, typeof({4}))", ElementType, var, IGen.QualifiedName, args, element_ctype == "gfilename*" ? "GLib.ListBase.FilenameString" : ElementType));
                }
            }
            else if (IGen is HandleBase)
            {
                return(((HandleBase)IGen).FromNative(var, owned));
            }
            else if (is_null_term)
            {
                return(String.Format("GLib.Marshaller.NullTermPtrToStringArray ({0}, {1})", var, owned ? "true" : "false"));
            }
            else
            {
                return(IGen.FromNative(var));
            }
        }
Beispiel #2
0
    public static int Main()
    {
        //Start recording
        testLog.StartRecording();

        // create test list
        IGen[] genList = new IGen[] {
            new Gen <int>(),
            new Gen <double>(),
            new Gen <string>(),
            new Gen <object>(),
            new Gen <Exception>()
        };

        // run test
        for (int i = 0; i < genList.Length; i++)
        {
            Console.WriteLine(genList[i].ExceptionTest());
        }

        // stop recoding
        testLog.StopRecording();

        return(testLog.VerifyOutput());
    }
Beispiel #3
0
    public static int TestEntryPoint()
    {
        //Start recording
        testLog.StartRecording();

        // create test list
        IGen[] genList = new IGen[] {
            new Gen <Exception>(),
            new Gen <GenException <Exception> >(),
            new Gen <GenException <GenException <Exception> > >(),
            new Gen <GenException <GenException <GenException <Exception> > > >(),
            new Gen <GenException <GenException <GenException <GenException <Exception> > > > >(),
            new Gen <GenException <GenException <GenException <GenException <GenException <Exception> > > > > >(),
            new Gen <GenException <GenException <GenException <GenException <GenException <GenException <Exception> > > > > > >(),
            new Gen <GenException <GenException <GenException <GenException <GenException <GenException <GenException <Exception> > > > > > > >(),
            new Gen <GenException <GenException <GenException <GenException <GenException <GenException <GenException <GenException <Exception> > > > > > > > >(),
            new Gen <GenException <GenException <GenException <GenException <GenException <GenException <GenException <GenException <GenException <Exception> > > > > > > > > >()
        };

        // run test
        for (int i = 0; i < genList.Length; i++)
        {
            Console.WriteLine(genList[i].ExceptionTest());
        }

        // stop recoding
        testLog.StopRecording();

        return(testLog.VerifyOutput());
    }
Beispiel #4
0
        public string ToNative(string var)
        {
            if (IGen == null)
            {
                return(String.Empty);
            }

            if (ElementType.Length > 0)
            {
                string args = ", typeof (" + ElementType + "), " + (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
                var = "new " + IGen.QualifiedName + "(" + var + args + ")";
            }
            else if (is_null_term)
            {
                return(String.Format("GLib.Marshaller.StringArrayToNullTermPointer ({0})", var));
            }

            if (IGen is IManualMarshaler)
            {
                return((IGen as IManualMarshaler).AllocNative(var));
            }
            else if (IGen is ObjectGen && owned)
            {
                return(var + " == null ? IntPtr.Zero : " + var + ".OwnedHandle");
            }
            else if (IGen is OpaqueGen && owned)
            {
                return(var + " == null ? IntPtr.Zero : " + var + ".OwnedCopy");
            }
            else
            {
                return(IGen.CallByName(var));
            }
        }
Beispiel #5
0
        private static string PrintAndCollect <T>(IGen <T> gen)
        {
            var log = new List <string>();

            gen.Advanced.Print(seed: 0, stdout: log.Add);

            return(string.Join(Environment.NewLine, log));
        }
        public static Type ReflectGenTypeArgument(this IGen gen)
        {
            var reflectedGenType = gen
                                   .GetType()
                                   .GetInterfaces()
                                   .Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IGen <>))
                                   .SingleOrDefault();

            return(reflectedGenType.GetGenericArguments().Single());
        }
Beispiel #7
0
        public static void Equal <T>(IGen <T> expected, IGen <T> actual, int seed, int?iterations = null)
        {
            var expectedSample = expected.Select(x => JsonConvert.SerializeObject(x)).Advanced.SampleExampleSpaces(seed: seed, iterations: iterations);
            var actualSample   = actual.Select(x => JsonConvert.SerializeObject(x)).Advanced.SampleExampleSpaces(seed: seed, iterations: iterations);

            Assert.All(
                Enumerable.Zip(expectedSample, actualSample),
                (x) =>
            {
                Assert.Equal(x.First.Sample(), x.Second.Sample());
            });
        }
Beispiel #8
0
 public static T Minimum <T>(
     this IGen <T> gen,
     int iterations      = 100,
     int?seed            = null,
     int?size            = null,
     bool deepMinimum    = false,
     Func <T, bool>?pred = null) => gen.Advanced.MinimumWithMetrics <T>(
     iterations: iterations,
     seed: seed,
     size: size,
     deepMinimum: deepMinimum,
     pred: pred).Value;
Beispiel #9
0
 public static IGen <T> Unfold <T>(
     this IGen <T> gen,
     Func <T, IEnumerable <T> > shrinkValue,
     Func <T, decimal>?measureValue = null,
     Func <T, int>?identifyValue    = null)
 {
     return(gen.Unfold(value => ExampleSpaceFactory.Unfold(
                           value,
                           shrinkValue.Invoke,
                           measureValue == null ? MeasureFunc.Unmeasured <T>() : measureValue !.Invoke,
                           identifyValue == null ? IdentifyFuncs.Default <T>() : value0 => ExampleId.Primitive(identifyValue !(value0)))));
 }
Beispiel #10
0
        /// <summary>
        /// Projects each element in a generator to a new form.
        /// </summary>
        /// <typeparam name="T">The type of the generator's value.</typeparam>
        /// <typeparam name="TResult">The type of the resultant generator's value.</typeparam>
        /// <param name="gen">The generator to apply the projection to.</param>
        /// <param name="selector">A projection function to apply to each value.</param>
        /// <returns>A new generator with the projection applied.</returns>
        /// <summary>
        /// Projects each element in a generator to a new form.
        /// </summary>
        /// <typeparam name="T">The type of the generator's value.</typeparam>
        /// <typeparam name="TResult">The type of the resultant generator's value.</typeparam>
        /// <param name="gen">The generator to apply the projection to.</param>
        /// <param name="selector">A projection function to apply to each value.</param>
        /// <returns>A new generator with the projection applied.</returns>
        public static IGen <TResult> Select <T, TResult>(this IGen <T> gen, Func <T, TResult> selector)
        {
            GenInstanceTransformation <T, TResult> transformation = (instance) => {
                var sourceExampleSpace    = instance.ExampleSpace;
                var projectedExampleSpace = instance.ExampleSpace.Map(selector);

                return(GenIterationFactory.Instance(
                           instance.ReplayParameters,
                           instance.NextParameters,
                           projectedExampleSpace,
                           instance.ExampleSpaceHistory));
            };

            return(gen.TransformInstances(transformation));
        }
Beispiel #11
0
        public static IGen <T> Unfold <T>(
            this IGen <T> gen,
            Func <T, IExampleSpace <T> > unfolder)
        {
            GenInstanceTransformation <T, T> transformation = (instance) =>
            {
                return(GenIterationFactory.Instance(
                           instance.ReplayParameters,
                           instance.NextParameters,
                           unfolder(instance.ExampleSpace.Current.Value),
                           instance.ExampleSpaceHistory));
            };

            return(gen.TransformInstances(transformation));
        }
Beispiel #12
0
        public static CheckResult <T> Check <T>(
            this IGen <Test <T> > property,
            int?iterations  = null,
            int?seed        = null,
            int?size        = null,
            int?shrinkLimit = null,
            string?replay   = null,
            bool deepCheck  = true)
        {
            var resolvedIterations = iterations ?? 100;

            var(initialSize, resizeStrategy) = SizingAspects <T> .Resolve(size == null?null : new Size(size.Value), resolvedIterations);

            var initialParameters = seed == null
                ? GenParameters.Create(initialSize)
                : GenParameters.Create(Rng.Create(seed.Value), initialSize);

            var initialContext = new CheckStateContext <T>(
                property,
                resolvedIterations,
                shrinkLimit ?? 500,
                initialParameters,
                deepCheck);

            CheckState <T> initialState = replay == null
                ? new GenerationStates.Generation_Begin <T>()
                : new ReplayState <T>(replay);

            var transitions = CheckStateEnumerator.Enumerate(
                initialState,
                initialContext,
                new[] { new ResizeCheckStateTransitionDecorator <T>(resizeStrategy) });

            var transitionAggregation = AggregateTransitions(transitions);

            return(new CheckResult <T>(
                       transitionAggregation.FinalContext.CompletedIterationsUntilCounterexample,
                       transitionAggregation.FinalContext.Discards,
                       transitionAggregation.FinalContext.Shrinks + transitionAggregation.FinalContext.CompletedIterationsAfterCounterexample,
                       transitionAggregation.FinalContext.Counterexample == null
                    ? null
                    : FromCounterexampleContext(transitionAggregation.FinalContext.Counterexample),
                       transitionAggregation.Checks,
                       initialParameters,
                       transitionAggregation.FinalContext.NextParameters,
                       transitionAggregation.TerminationReason));
        }
Beispiel #13
0
        private static SpyEnumerable <IExampleSpace <T> > CreateInfiniteEnumerable(
            IGen <T> elementGen,
            GenParameters parameters,
            int?iterationLimit)
        {
            var source = elementGen.Advanced
                         .Run(parameters)
                         .WithDiscardCircuitBreaker(_ => true, iteration => iteration.IsDiscard())
                         .Select(iteration => iteration.Match <IGenInstance <T>?>(
                                     onInstance: instance => instance,
                                     onError: _ => null,
                                     onDiscard: _ => null))
                         .Where(instance => instance != null)
                         .Select(instance => instance !.ExampleSpace);

            return(new SpyEnumerable <IExampleSpace <T> >(ThrowOnLimit(source, iterationLimit)));
        }
Beispiel #14
0
 public static IGen <T> Cast <T>(this IGen gen) => new FunctionalGen <T>(parameters =>
                                                                         gen.Advanced
                                                                         .Run(parameters)
                                                                         .Select(iteration => iteration.Data.Match(
                                                                                     onInstance: instance => GenIterationFactory.Instance <T>(
                                                                                         iteration.ReplayParameters,
                                                                                         iteration.NextParameters,
                                                                                         instance.ExampleSpace.Cast <T>(),
                                                                                         instance.ExampleSpaceHistory),
                                                                                     onError: error => GenIterationFactory.Error <T>(
                                                                                         iteration.ReplayParameters,
                                                                                         iteration.NextParameters,
                                                                                         error.GenName,
                                                                                         error.Message),
                                                                                     onDiscard: discard => GenIterationFactory.Discard <T>(
                                                                                         iteration.ReplayParameters,
                                                                                         iteration.NextParameters,
                                                                                         discard.ExampleSpace))));
Beispiel #15
0
        private void mutateGen_(IGen <Neuron> gen)
        {
            var neuroGen = gen as NeuroGen;
            var shouldMutateActivationFunc = Random.Next(0, 100) >= MutatedPropability;

            if (shouldMutateActivationFunc)
            {
                var index = Random.Next(1, ActivationFunctions.AvailableActivatonFunctions.Count() + 1);
                neuroGen.Value.ActivationFunc = ActivationFunctions.AvailableActivatonFunctions.FirstOrDefault(x => x.Index == index);
            }

            var mutatedWeightsCount = Random.Next(0, neuroGen.Weights.Count / 3);

            for (int i = 0; i < mutatedWeightsCount; i++)
            {
                var nextGen = Random.Next(0, mutatedWeightsCount);
                neuroGen.Weights[nextGen] = Random.NextDouble();
            }
        }
        public static IGen <U> TransformInstances <T, U>(
            this IGen <T> gen,
            GenInstanceTransformation <T, U> transformation) =>
        gen.TransformIterations((IGenIteration <T> iteration) =>
        {
            var either = iteration.ToEither <T, U>();

            if (EitherExtension.IsLeft(either, out IGenInstance <T> instance))
            {
                return(transformation(instance));
            }
            else if (EitherExtension.IsRight(either, out IGenIteration <U> iterationConverted))
            {
                return(iterationConverted);
            }
            else
            {
                throw new Exception("Fatal: Unhandled branch");
            }
        });
Beispiel #17
0
        private static IExampleSpace <IEnumerable <T> > CreateInfiniteEnumerableSpace(
            IGen <T> elementGen,
            GenParameters parameters,
            int?iterationLimit)
        {
            IEnumerable <T> SealEnumerable(IEnumerable <T> source) => ThrowOnLimit(source.Repeat(), iterationLimit);

            var enumerable = CreateInfiniteEnumerable(elementGen, parameters, iterationLimit);

            IExample <IEnumerable <T> > rootExample = new Example <IEnumerable <T> >(
                ExampleId.Primitive(parameters.Rng.Seed),
                enumerable.Select(x => x.Current.Value),
                100);

            return(ExampleSpaceFactory.Delay(
                       rootExample,
                       () =>
            {
                if (enumerable.MaxIterations == 0)
                {
                    return Enumerable.Empty <IExampleSpace <IEnumerable <T> > >();
                }

                if (enumerable.MaxIterations == 1)
                {
                    var exampleSpace = enumerable.First().Map(element => SealEnumerable(new[] { element }));
                    return new[] { exampleSpace };
                }

                var exampleSpaces = enumerable.Take(enumerable.MaxIterations).ToList();

                var rootExampleExplored = ExampleSpaceFactory.Merge(
                    exampleSpaces,
                    xs => xs,
                    ShrinkTowardsLength(1),
                    (_) => 0,
                    enableSmallestExampleSpacesOptimization: false);

                return rootExampleExplored.Subspace.Select(es => es.Map(SealEnumerable));
            }));
        }
Beispiel #18
0
 public Generator(IGen requestTimeGen, IGen firstArticleGen, IGen secondArticleGen, IGen thirdArticleGen, double urgencyProb, double refuseProb,
     IGen demandModifyTimeGen, IGen articlesModifyGen, IGen firstArticleModifyGen, IGen secondArticleModifyGen, IGen thirdArticleModifyGen,
     IGen urgToStandModifyGen, IGen standToUrgModifyGen, IGen deliveryDelayGen, IGen[] deliveryElementsModifyGens)
 {
     this.uGen = new UniformGen(0, 1);
     this.requestTimeGen = requestTimeGen;
     this.firstArticleGen = firstArticleGen;
     this.secondArticleGen = secondArticleGen;
     this.thirdArticleGen = thirdArticleGen;
     this.urgencyProb = urgencyProb;
     this.refuseProb = refuseProb;
     this.demandModifyTimeGen = demandModifyTimeGen;
     this.articlesModifyGen = articlesModifyGen;
     this.firstArticleModifyGen = firstArticleModifyGen;
     this.secondArticleModifyGen = secondArticleModifyGen;
     this.thirdArticleModifyGen = thirdArticleModifyGen;
     this.urgToStandModifyGen = urgToStandModifyGen;
     this.standToUrgModifyGen = standToUrgModifyGen;
     this.deliveryDelayGen = deliveryDelayGen;
     this.deliveryElementsModifyGens = deliveryElementsModifyGens;
 }
Beispiel #19
0
        /// <summary>
        /// Filters a generator's values based on a predicate. Does not alter the structure of the stream. Instead,
        /// it replaces the filtered value with a token, which enables discard counting whilst running the generator.
        /// </summary>
        /// <param name="gen">The generator to apply the predicate to.</param>
        /// <param name="pred">A predicate function that tests each value.</param>
        /// <returns>A new generator with the filter applied.</returns>
        public static IGen <T> Where <T>(this IGen <T> gen, Func <T, bool> pred)
        {
            GenInstanceTransformation <T, T> applyPredicateToInstance = (instance) =>
            {
                var filteredExampleSpace = instance.ExampleSpace.Filter(pred);
                if (filteredExampleSpace == null)
                {
                    return(GenIterationFactory.Discard <T>(
                               instance.ReplayParameters,
                               instance.NextParameters,
                               instance.ExampleSpace));
                }

                return(GenIterationFactory.Instance(
                           instance.ReplayParameters,
                           instance.NextParameters,
                           filteredExampleSpace,
                           instance.ExampleSpaceHistory));
            };

            GenStreamTransformation <T, T> resizeAndTerminateAfterConsecutiveDiscards = (stream) =>
            {
                const int MaxConsecutiveDiscards = 10;

                return(stream
                       .WithConsecutiveDiscardCount(_ => true, iteration => iteration.IsDiscard())
                       .Select((x) =>
                {
                    var(iteration, consecutiveDiscardCount) = x;

                    if (consecutiveDiscardCount >= MaxConsecutiveDiscards)
                    {
                        var resizedIteration = GenIterationFactory.Discard <T>(
                            iteration.ReplayParameters,
                            iteration.NextParameters.With(size: iteration.NextParameters.Size.BigIncrement()),
                            iteration.Data.Discard !.ExampleSpace);

                        return (iteration: resizedIteration, consecutiveDiscardCount);
                    }
Beispiel #20
0
        internal static IGen <T> SelectError <T>(this IGen <T> gen, Func <IGenErrorData, IGenErrorData> errorSelector)
        {
            IGenIteration <T> SelectError(IGenError <T> error)
            {
                var selectedErrorData = errorSelector(error);

                return(GenIterationFactory.Error <T>(
                           error.ReplayParameters,
                           error.NextParameters,
                           selectedErrorData.GenName,
                           selectedErrorData.Message));
            }

            GenIterationTransformation <T, T> transformation = (iteration) =>
            {
                return(iteration.Match(
                           onError: error => SelectError(error),
                           onInstance: instance => instance,
                           onDiscard: discard => discard));
            };

            return(gen.TransformIterations(transformation));
        }
Beispiel #21
0
        public static void Assert <T>(
            this IGen <Test <T> > property,
            int?iterations  = null,
            int?seed        = null,
            int?size        = null,
            int?shrinkLimit = null,
            string?replay   = null,
            bool deepCheck  = true,
            Func <string, string>?formatReproduction = null,
            Func <string, string>?formatMessage      = null)
        {
            var checkResult = property.Check(iterations: iterations, seed: seed, size: size, shrinkLimit: shrinkLimit, replay: replay, deepCheck: deepCheck);

            if (checkResult.Falsified)
            {
                throw new PropertyFailedException(
                          BoxCounterexample(checkResult.Counterexample !),
                          checkResult.Iterations,
                          checkResult.Shrinks,
                          formatReproduction,
                          formatMessage);
            }
        }
        public string FromNative(string var)
        {
            if (IGen == null)
            {
                return(String.Empty);
            }

            if (ElementType != String.Empty)
            {
                string args = (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
                if (IGen.QualifiedName == "GLib.PtrArray")
                {
                    return(String.Format("({0}[]) GLib.Marshaller.PtrArrayToArray ({1}, {2}, typeof({0}))", ElementType, var, args));
                }
                else
                {
                    return(String.Format("({0}[]) GLib.Marshaller.ListPtrToArray ({1}, typeof({2}), {3}, typeof({4}))", ElementType, var, IGen.QualifiedName, args, element_ctype == "gfilename*" ? "GLib.ListBase.FilenameString" : ElementType));
                }
            }
            else if (IGen is IOwnable)
            {
                return(((IOwnable)IGen).FromNative(var, owned));
            }
            else if (is_null_term)
            {
                return(String.Format("Gst.Marshaller.NullTermPtrToStringArray ({0}, {1})", var, owned ? "true" : "false"));
            }
            else if (is_array)
            {
                return(String.Format("({0}) GLib.Marshaller.ArrayPtrToArray ({1}, typeof ({2}), (int){3}native_{4}, true)", CSType, var, IGen.QualifiedName, CountParameter.CSType == "int" ? String.Empty : "(" + CountParameter.CSType + ")", CountParameter.Name));
            }
            else
            {
                return(IGen.FromNative(var));
            }
        }
 private static IGen <ImmutableList <T> > CreateImmutableListGen <T>(IGen <T> elementGen) => CreateIReadOnlyListGen(elementGen).Select(x => x.ToImmutableList());
Beispiel #24
0
 /// <summary>
 /// Creates a generator that produces lists, the elements of which are produced by the given generator. By
 /// default, the generator produces lists ranging from count 0 to 20 - but this can be configured using the
 /// builder methods on <see cref="IListGen{T}"/>.
 /// </summary>
 /// <param name="elementGen">The generator used to produce the elements of the list.</param>
 /// <returns>The new generator.</returns>
 public static IListGen <T> ListOf <T>(this IGen <T> gen) => Gen.List(gen);
Beispiel #25
0
 /// <summary>
 /// Creates a generator that produces lists, the elements of which are produced by the given generator. By
 /// default, the generator produces lists ranging from count 0 to 20 - but this can be configured using the
 /// builder methods on <see cref="IListGen{T}"/>.
 /// </summary>
 /// <param name="elementGen">The generator used to produce the elements of the list.</param>
 /// <returns>The new generator.</returns>
 public static IListGen <T> List <T>(IGen <T> elementGen) => new ListGen <T>(
     ElementGen: elementGen,
     Count: RangeIntention.Unspecified(),
     Bias: null,
     EnableCountLimit: null);
Beispiel #26
0
 public static ISetGen <T> Set <T>(IGen <T> elementGen) => new SetGen <T>(
     ElementGen: elementGen,
     Count: RangeIntention.Unspecified());
Beispiel #27
0
 /// <summary>
 /// Creates a generator that produces sets, the elements of which are produced by the given generator. By
 /// default, the generator produces sets ranging from count 0 to 20 - but this can be configured using the
 /// builder methods on <see cref="ISetGen{T}"/>.
 /// </summary>
 /// <param name="elementGen">The generator used to produce the elements of the set.</param>
 /// <returns>The new generator.</returns>
 public static ISetGen <T> SetOf <T>(this IGen <T> gen) => Gen.Set(gen);
Beispiel #28
0
 private void Main_Load(object sender, EventArgs e)
 {
     notifyIcon1.Visible = true;
     _requestSuccess = true;
     _Sctime = ConfigurationManager.AppSettings["ScTime"].ToString();
     _Smtime = ConfigurationManager.AppSettings["SmTime"].ToString();
     _GetPriceTime = ConfigurationManager.AppSettings["GetPrice"].ToString();
     Sctime.Interval = TimeHelper.ConvertHToMs(_Sctime);
     Smtime.Interval = TimeHelper.ConvertSToMs(_Smtime);
     igen = new Gen();
     igen.ScanAndInsertHandler += new ScanAndInsert(igen_ScanAndInsertHandler);
     igen.PostDataHandler += new PostData(igen_PostData);
     RequesTime.Start();
     this.ShowInTaskbar = false;
     Smtime.Start();
     Sctime.Start();
 }
Beispiel #29
0
 public InfiniteGen(IGen <T> elementGen)
     : this(elementGen, 1000)
 {
 }
Beispiel #30
0
 public InfiniteGen(IGen <T> elementGen, int?iterationLimit)
 {
     _elementGen     = elementGen;
     _iterationLimit = iterationLimit;
 }
Beispiel #31
0
 /// <summary>
 /// Creates a generator that produces infinite enumerables, the elements of which are produced by the given
 /// generator. Infinite enumerables are supported by this generator, but by default there is a limit of 1000
 /// elements in place - and the iterator will throw if that limit is exceeded. This is a pragmatic limit to
 /// avert confusion of cases where the consuming code trys to enumerate an infinite enumerable (and
 /// consequently hangs forever).
 /// </summary>
 /// <param name="elementGen">The generator used to produce the elements of the list.</param>
 /// <param name="iterationLimit">The hard iteration limit that should be applied to the generator.</param>
 /// <returns>The new generator.</returns>
 public static IGen <IEnumerable <T> > InfiniteOf <T>(this IGen <T> elementGen, int?iterationLimit = 1000) =>
 Gen.Infinite(elementGen, iterationLimit);
Beispiel #32
0
 /// <summary>
 /// Creates a generator that produces infinite enumerables, the elements of which are produced by the given
 /// generator. Infinite enumerables are supported by this generator, but by default there is a limit of 1000
 /// elements in place - and the iterator will throw if that limit is exceeded. This is a pragmatic limit to
 /// avert confusion of cases where the consuming code trys to enumerate an infinite enumerable (and
 /// consequently hangs forever).
 /// </summary>
 /// <param name="elementGen">The generator used to produce the elements of the list.</param>
 /// <param name="iterationLimit">The hard iteration limit that should be applied to the generator.</param>
 /// <returns>The new generator.</returns>
 public static IGen <IEnumerable <T> > Infinite <T>(IGen <T> elementGen, int?iterationLimit = 1000) =>
 new InfiniteGen <T>(elementGen, iterationLimit);