public StatementGenerator(Random random)
 {
     _random     = random;
     _expression = new ExpressionGenerator(random);
     _variable   = new VariableNameGenerator(random);
     _statements = new StatementListGenerator(random, 5);
 }
Beispiel #2
0
        public StatementList Generate()
        {
            var statements = new StatementGenerator(_random);

            if (_random.NextDouble() < 0.01)
            {
                var v = new VariableNameGenerator(_random).Generate();
                var e = new ExpressionGenerator(_random);

                return(new StatementList(
                           Enumerable.Range(0, _random.Next(1, _count)).Select(_ => new Assignment(v, e.Generate()))
                           ));
            }
            else
            {
                return(new StatementList(
                           Enumerable.Range(0, _random.Next(1, _count)).Select(_ => statements.Generate())
                           ));
            }
        }
 public ExpressionGenerator(Random random)
 {
     _random   = random;
     _variable = new VariableNameGenerator(random);
 }