Inheritance: ICommandSetter
コード例 #1
0
 public void Accept(Minus command)
 {
     var comparableCommand = _second as Minus;
     _isEqual = command.TargetName == comparableCommand.TargetName   &&
                command.FirstSource == comparableCommand.FirstSource &&
                command.SecondSource == comparableCommand.SecondSource;
 }
コード例 #2
0
ファイル: Executor.cs プロジェクト: Zhuchenko/creatures
        public void Accept(Minus command)
        {
            if (!_conditions.Peek()) return;

            var firstValue = _variables[command.FirstSource];
            var secondValue = _variables[command.SecondSource];
            _variables[command.TargetName] = firstValue - secondValue;
        }
コード例 #3
0
        public void Accept(Minus command)
        {
            if (!_variables.ContainsKey(command.FirstSource)  ||
                !_variables.ContainsKey(command.SecondSource) ||
                !_variables.ContainsKey(command.TargetName)   ||
                _variables[command.FirstSource]==null         ||
                _variables[command.SecondSource]==null)
            {
                _isExecutable = false;
                return;
            }

            var firstValue = _variables[command.FirstSource];
            var secondValue = _variables[command.SecondSource];
            _variables[command.TargetName] = firstValue - secondValue;
        }
コード例 #4
0
 public void Accept(Minus command)
 {
     _builder.AppendLine($"{command.TargetName} = {command.FirstSource} - {command.SecondSource}");
 }
コード例 #5
0
ファイル: AddMutationTest.cs プロジェクト: Confirmit/Students
 private AddCommandMutation GetMutationForMinus(ICommandsList commands, Minus command, int indexToAdd)
 {
     var random = new AddRandom();
     var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var firstSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.FirstSource, commands);
     var secondSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SecondSource, commands);
     random.TuneMinus(targetDeclarationIndex, firstSourceDeclarationIndex, secondSourceDeclarationIndex, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
コード例 #6
0
ファイル: AddMutationTest.cs プロジェクト: Confirmit/Students
        public void AddMinus()
        {
            const string code = @"int ione
                                  ione = 5
                                  int itwo
                                  itwo = 2
                                  int three
                                  int four
                                  int five";
            const int indexToAdd = 6;
            var commandToAdd = new Minus("four", "ione", "itwo");
            var commands = GenerateCommands(code);
            var mutation = GetMutationForMinus(commands, commandToAdd, indexToAdd);

            mutation.Transform();

            const string resultCode = @"int ione
                                        ione = 5
                                        int itwo
                                        itwo = 2
                                        int three
                                        int four
                                        four = ione - itwo
                                        int five";
            var resultCommands = GenerateCommands(resultCode);
            Assert.IsTrue(AreCollectionsEquals(commands, resultCommands));
        }
コード例 #7
0
 private ReplaceCommandMutation GetMutationForMinus(ICommandsList commands, int replaceIndex, Minus command)
 {
     var random = new ReplaceRandom();
     var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var firstSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.FirstSource, commands);
     var secondSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SecondSource, commands);
     random.TuneMinus(replaceIndex, targetDeclarationIndex, firstSourceDeclarationIndex, secondSourceDeclarationIndex);
     return new ReplaceCommandMutation(random, commands);
 }
コード例 #8
0
        public void ReplaceMinus()
        {
            const string code = @"int ione
                                  ione = 5
                                  int itwo
                                  itwo = 2
                                  int ithree
                                  ithree = ione
                                  itwo = ithree - ione";
            const int indexToReplace = 6;
            var commandToReplace = new Minus("ithree", "itwo", "ione");
            var commands = GenerateCommands(code);
            var mutation = GetMutationForMinus(commands, indexToReplace, commandToReplace);

            mutation.Transform();

            const string resultCode = @"int ione
                                        ione = 5
                                        int itwo
                                        itwo = 2
                                        int ithree
                                        ithree = ione
                                        ithree = itwo - ione";
            var resultCommands = GenerateCommands(resultCode);
            Assert.IsTrue(AreCollectionsEquals(commands, resultCommands));
        }