Inheritance: ICommandWithArgument
 public void Accept(Print command)
 {
     _builder.AppendLine($"print {command.Variable}");
 }
示例#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);
 }
示例#3
0
        public void Accept(Print command)
        {
            if (!_conditions.Peek()) return;

            var value = _variables[command.Variable];
            _console.AppendLine(value.ToString());
        }
示例#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;
 }
示例#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);
 }
示例#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));
        }
示例#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());
        }