Exemple #1
0
        public void TestDo()
        {
            var do_ = new Do();

            do_.Init(new Stmt(), new Rel(new Token('>'), new Constant(42), new Constant(99)));
            do_.Gen(10, 20);
            //output:
            //L1:	if 42 > 99 goto L10
        }
Exemple #2
0
        public void DoGenTest()
        {
            using (var cout = new StringWriter())
            {
                Node.Cout = cout;

                var variable  = new Id(new Word("x", Tag.ID), VarType.INT, 0);
                var constant  = new Constant(new Num(12), VarType.INT);
                var expresion = new Rel(Word.EQ, variable, constant);

                var donode = new Do();
                donode.Init(expresion, new Stmt());
                donode.Gen(11, 22);

                var actual = cout.ToString();
                Assert.AreEqual("L1:\r\n\tif x == 12 goto L11\r\n", actual);
            }
        }