Пример #1
0
        public void Accept(CloneValue command)
        {
            if (!_variables.ContainsKey(command.SourceName) ||
                !_variables.ContainsKey(command.TargetName) ||
                _variables[command.SourceName] == null)
            {
                _isExecutable = false;
                return;
            }
            var value = _variables[command.SourceName];

            _variables[command.TargetName] = value;
        }
Пример #2
0
        public void AddCloneValue()
        {
            const string code         = @"int ione
                                  ione = 5
                                  int itwo";
            const int    indexToAdd   = 3;
            var          commandToAdd = new CloneValue("itwo", "ione");
            var          commands     = GenerateCommands(code);
            var          mutation     = GetMutationForCloneValue(commands, commandToAdd, indexToAdd);

            mutation.Transform();

            const string resultCode     = @"int ione
                                        ione = 5
                                        int itwo
                                        itwo = ione";
            var          resultCommands = GenerateCommands(resultCode);

            Assert.IsTrue(AreCollectionsEquals(commands, resultCommands));
        }
Пример #3
0
 private bool EqualsCloneValue(CloneValue x, CloneValue y)
 {
     return(x.SourceName == y.SourceName && x.TargetName == y.TargetName);
 }
Пример #4
0
 public void Accept(CloneValue command)
 {
     _builder.AppendLine($"{command.TargetName} = {command.SourceName}");
 }
Пример #5
0
        private ReplaceCommandMutation GetMutationForCloneValue(ICommandsList commands, int replaceIndex, CloneValue command)
        {
            var random = new ReplaceRandom();
            var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
            var sourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SourceName, commands);

            random.TuneCloneValue(replaceIndex, targetDeclarationIndex, sourceDeclarationIndex);
            return(new ReplaceCommandMutation(random, commands));
        }