public void Parser_InputSmallestAddressCommandPossible_GetCorrectlyParsedInstruction() { string smallestAddressCommandPossible = "@0"; Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(smallestAddressCommandPossible); Queue <InstructionElement> instructionQueue = instruction.GetInstructionElementQueue(); Assert.AreEqual("0", instructionQueue.Dequeue().instructionElement); }
public void Parser_InputCorrectlyFormattedAddressCommand_GetCorrectlyParsedInstruction() { string correctlyFormattedAddressCommand = "@100"; Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(correctlyFormattedAddressCommand); Queue <InstructionElement> instructionQueue = instruction.GetInstructionElementQueue(); Assert.AreEqual("100", instructionQueue.Dequeue().instructionElement); }
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); }
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); }
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); }
public void Parser_InputEmptyString_ThrowException() { string emptyString = String.Empty; Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(emptyString); }
public void Parser_InputAddressCommandWithInvalidAddress_ThrowException() { string addressCommandWithInvalidAddress = "@InvalidAddress"; Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(addressCommandWithInvalidAddress); }
public void Parser_InputInvalidComputationCommandWithoutDestinationOrJump_ThrowException() { string invalidComputationCommandWithoutDestinationOrJump = "helloWorld"; Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(invalidComputationCommandWithoutDestinationOrJump); }
public void Parser_InputInvalidComputationCommandWithoutJump_ThrowException() { string invalidComputationCommandWithoutJump = "dest=#$%2"; Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(invalidComputationCommandWithoutJump); }
public void Parser_InputInvalidComputationCommandWithoutDestination_ThrowException() { string inputInvalidComputationCommandWithoutDestination = "1060;JmP"; Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(inputInvalidComputationCommandWithoutDestination); }
public void Parser_InputInvalidComputationCommand_ThrowException() { string invalidComputationCommand = "M=5+A;JUMP"; Instruction instruction = AssemblyLanguageParser.GetInstructionFromAssemblyCommand(invalidComputationCommand); }