예제 #1
0
        public void TestRel()
        {
            var isLess = new Rel(new Token('<'), new Constant(10), new Constant(100));

            Assert.AreEqual("10 < 100", isLess.ToString());

            isLess.Jumping(42, 99);
            //output:
            //        if 10 < 100 goto L42
            //        goto L99
        }
예제 #2
0
        public void RelJumpingTest()
        {
            using (var cout = new StringWriter())
            {
                Node.Cout = cout;

                var token    = new Word("<=", Tag.LE);
                var variable = new Id(new Word("x", Tag.ID), VarType.INT, 0);
                var intnode  = new Constant(3);
                var rel      = new Rel(token, variable, intnode);

                rel.Jumping(11, 22);

                var actual = cout.ToString();
                Assert.AreEqual("\tif x <= 3 goto L11\r\n\tgoto L22\r\n", actual);
            }
        }