Beispiel #1
0
        public void TestHandleLabelAndReturnLine_whenThereIsNoLabel_thenReturnTheSameLine()
        {
            var compilerModel = new CompilerModel(null, null, null);
            var line          = "test";
            var env           = new CompilerEnvironment();

            var result = compilerModel.HandleLabelAndReturnLine(line, env);

            Assert.AreSame(result, line);
            Assert.AreEqual(env.GetLabelsCount(), 0);
        }
Beispiel #2
0
        public void TestHandleLabelAndReturnLine_whenThereIsLabel_thenReturnLineWithoutLabelAndAddLabelToEnv()
        {
            var compilerModel = new CompilerModel(null, null, null);
            var line          = "la2_-s:test";
            var env           = new CompilerEnvironment();
            int address       = 67;

            env.CurrentAddress = 67;

            var result = compilerModel.HandleLabelAndReturnLine(line, env);

            Assert.IsTrue(result.Equals("test"));
            Assert.AreEqual(env.GetLabelsCount(), 1);
            Assert.AreEqual(env.GetLabelAddress("la2_-s"), address);
        }