Esempio n. 1
0
        public void Parser_InputSmallestAddressCommandPossible_GetCorrectlyParsedInstruction()
        {
            string smallestAddressCommandPossible = "@0";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(smallestAddressCommandPossible);

            Queue <InstructionElement> instructionQueue = instruction.GetInstructionElementQueue();

            Assert.AreEqual("0", instructionQueue.Dequeue().instructionElement);
        }
Esempio n. 2
0
        public void Parser_InputCorrectlyFormattedAddressCommand_GetCorrectlyParsedInstruction()
        {
            string correctlyFormattedAddressCommand = "@100";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(correctlyFormattedAddressCommand);

            Queue <InstructionElement> instructionQueue = instruction.GetInstructionElementQueue();

            Assert.AreEqual("100", instructionQueue.Dequeue().instructionElement);
        }
Esempio n. 3
0
        public void Parser_InputValidComputationCommandWithoutSpaces_GetCorrectlyParsedInstruction()
        {
            string validComputationCommandWithoutSpaces = "MD=D+1;JLT";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(validComputationCommandWithoutSpaces);

            Queue <InstructionElement> instructionQueue = instruction.GetInstructionElementQueue();

            Assert.AreEqual("D+1", instructionQueue.Dequeue().instructionElement);

            Assert.AreEqual("MD", instructionQueue.Dequeue().instructionElement);

            Assert.AreEqual("JLT", instructionQueue.Dequeue().instructionElement);
        }
Esempio n. 4
0
        public void Parser_InputValidComputationCommandWithoutJumpOrDestination_GetCorrectlyParsedInstruction()
        {
            string validComputationCommandWithoutDestination = "A-D";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(validComputationCommandWithoutDestination);

            Queue <InstructionElement> instructionQueue = instruction.GetInstructionElementQueue();

            Assert.AreEqual("A-D", instructionQueue.Dequeue().instructionElement);

            Assert.AreEqual("", instructionQueue.Dequeue().instructionElement);

            Assert.AreEqual("", instructionQueue.Dequeue().instructionElement);
        }
Esempio n. 5
0
        public void Parser_InputValidComputationCommandWithWeirdSpacing_GetCorrectlyParsedInstruction()
        {
            string validComputationCommandWithWeirdSpacing = "A =    A+1 ;             JGE";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(validComputationCommandWithWeirdSpacing);

            Queue <InstructionElement> instructionQueue = instruction.GetInstructionElementQueue();

            Assert.AreEqual("A+1", instructionQueue.Dequeue().instructionElement);

            Assert.AreEqual("A", instructionQueue.Dequeue().instructionElement);

            Assert.AreEqual("JGE", instructionQueue.Dequeue().instructionElement);
        }
Esempio n. 6
0
        public void Parser_InputEmptyString_ThrowException()
        {
            string emptyString = String.Empty;

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(emptyString);
        }
Esempio n. 7
0
        public void Parser_InputAddressCommandWithInvalidAddress_ThrowException()
        {
            string addressCommandWithInvalidAddress = "@InvalidAddress";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(addressCommandWithInvalidAddress);
        }
Esempio n. 8
0
        public void Parser_InputInvalidComputationCommandWithoutDestinationOrJump_ThrowException()
        {
            string invalidComputationCommandWithoutDestinationOrJump = "helloWorld";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(invalidComputationCommandWithoutDestinationOrJump);
        }
Esempio n. 9
0
        public void Parser_InputInvalidComputationCommandWithoutJump_ThrowException()
        {
            string invalidComputationCommandWithoutJump = "dest=#$%2";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(invalidComputationCommandWithoutJump);
        }
Esempio n. 10
0
        public void Parser_InputInvalidComputationCommandWithoutDestination_ThrowException()
        {
            string inputInvalidComputationCommandWithoutDestination = "1060;JmP";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(inputInvalidComputationCommandWithoutDestination);
        }
Esempio n. 11
0
        public void Parser_InputInvalidComputationCommand_ThrowException()
        {
            string invalidComputationCommand = "M=5+A;JUMP";

            Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(invalidComputationCommand);
        }