Inheritance: ICommandWithArgument
 public void Accept(Print command)
 {
     _builder.AppendLine($"print {command.Variable}");
 }
Esempio n. 2
0
 private AddCommandMutation GetMutationForPrint(ICommandsList commands, Print command, int indexToAdd)
 {
     var random = new AddRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.Variable, commands);
     random.TunePrint(declarationIndex, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Esempio n. 3
0
        public void Accept(Print command)
        {
            if (!_conditions.Peek()) return;

            var value = _variables[command.Variable];
            _console.AppendLine(value.ToString());
        }
Esempio n. 4
0
        public void AddPrint()
        {
            const string code = @"int ione
                                  ione = 5
                                  int itwo
                                  itwo = 2";
            const int indexToAdd = 4;
            var commandToAdd = new Print("itwo");
            var commands = GenerateCommands(code);
            var mutation = GetMutationForPrint(commands, commandToAdd, indexToAdd);

            mutation.Transform();

            const string resultCode = @"int ione
                                       ione = 5
                                       int itwo
                                       itwo = 2
                                       print itwo";
            var resultCommands = GenerateCommands(resultCode);
            Assert.IsTrue(AreCollectionsEquals(commands, resultCommands));
        }
 public void Accept(Print command)
 {
     _isEqual = command.Variable == (_second as Print).Variable;
 }
Esempio n. 6
0
 private ReplaceCommandMutation GetMutationForPrint(ICommandsList commands, int replaceIndex, Print command)
 {
     var random = new ReplaceRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.Variable, commands);
     random.TunePrint(replaceIndex, declarationIndex);
     return new ReplaceCommandMutation(random, commands);
 }
Esempio n. 7
0
        public void ReplacePrint()
        {
            const string code = @"int ione
                                  ione = 5
                                  int itwo
                                  int ithree
                                  ithree = ione
                                  print ithree";
            const int indexToReplace = 5;
            var commandToReplace = new Print("ione");
            var commands = GenerateCommands(code);
            var mutation = GetMutationForPrint(commands, indexToReplace, commandToReplace);

            mutation.Transform();

            const string resultCode = @"int ione
                                        ione = 5
                                        int itwo
                                        int ithree
                                        ithree = ione
                                        print ione";
            var resultCommands = GenerateCommands(resultCode);
            Assert.IsTrue(AreCollectionsEquals(commands, resultCommands));
        }
Esempio n. 8
0
        public void Accept(Print command)
        {
            if (!_variables.ContainsKey(command.Variable) ||
                _variables[command.Variable]==null)
            {
                _isExecutable = false;
                return;
            }

            var value = _variables[command.Variable];
            _console.AppendLine(value.ToString());
        }