예제 #1
0
        public void GivenAllLineComponents_TokenizeLine_Succeeds()
        {
            var splitter = new SourceLineTokenizer();
            var expected = new TokenizedSourceLine(
                label: new LabelDefinition("_MaiN_"),
                instruction: new SourceInstruction(
                    "AnD",
                    new RegisterOperand(Registers.RegisterNumber.T0),
                    new RegisterOperand(Registers.RegisterNumber.T1),
                    new ImmediateOperand(3260)
                    )
                );

            Assert.AreEqual(
                expected,
                splitter.TokenizeLine("_MaiN_: AnD $t0, $t1, 3260 #:$#$:comment:$#$:"));
            Assert.AreEqual(
                expected,
                splitter.TokenizeLine("_MaiN_:AnD $t0,$t1,3260#:$#$:comment:$#$:"));
            Assert.AreEqual(
                expected,
                splitter.TokenizeLine("  _MaiN_  :  AnD  $t0  ,  $t1  ,  3260  #  :$#$:comment:$#$:  "));
        }
예제 #2
0
        public void GivenInstructionWithExtraFormatting_TokenizeLine_Succeeds()
        {
            var splitter = new SourceLineTokenizer();
            var expected = new TokenizedSourceLine(
                label: null,
                instruction: new SourceInstruction(
                    "and",
                    new RegisterOperand(Registers.RegisterNumber.T0),
                    new RegisterOperand(Registers.RegisterNumber.T1)
                    )
                );

            Assert.AreEqual(expected, splitter.TokenizeLine("and $t0 $t1"));
            Assert.AreEqual(expected, splitter.TokenizeLine("and $t0  $t1"));
            Assert.AreEqual(expected, splitter.TokenizeLine("and $t0, $t1"));
            Assert.AreEqual(expected, splitter.TokenizeLine("and $t0 , $t1"));
            Assert.AreEqual(expected, splitter.TokenizeLine("and $t0 ,$t1"));
            Assert.AreEqual(expected, splitter.TokenizeLine("and $t0,$t1"));
        }