Exemplo n.º 1
0
        public void GetStringWithoutLabel()
        {
            var loop = new ForLoopStatement("i",
                                            SqlExpression.Constant(SqlObject.BigInt(0)),
                                            SqlExpression.Constant(SqlObject.BigInt(5)),
                                            true);

            loop.Statements.Add(new ContinueStatement());

            var sql = new StringBuilder();

            sql.AppendLine("FOR i IN 0..5");
            sql.AppendLine("LOOP");
            sql.AppendLine("  CONTINUE;");
            sql.Append("END LOOP;");

            Assert.Equal(sql.ToString(), loop.ToString());
        }
Exemplo n.º 2
0
        public static void ForLoopGoto()
        {
            var loop = new ForLoopStatement("i", SqlExpression.Constant(0), SqlExpression.Reference(new ObjectName("x")));
            loop.Statements.Add(new ConditionStatement(SqlExpression.Equal(SqlExpression.VariableReference("i"), SqlExpression.Constant(3)), new SqlStatement[] {
                new GoToStatement("lbl_3")
            }));

            var sql = loop.ToString();
            var expected = new StringBuilder();
            expected.AppendLine("FOR i IN 0...x");
            expected.AppendLine("LOOP");
            expected.AppendLine("  IF :i = 3 THEN");
            expected.AppendLine("    GOTO 'lbl_3'");
            expected.AppendLine("  END IF");
            expected.Append("END LOOP");

            Assert.AreEqual(expected.ToString(), sql);
        }
        public static void ForLoopGoto()
        {
            var loop = new ForLoopStatement("i", SqlExpression.Constant(0), SqlExpression.Reference(new ObjectName("x")));

            loop.Statements.Add(new ConditionStatement(SqlExpression.Equal(SqlExpression.VariableReference("i"), SqlExpression.Constant(3)), new SqlStatement[] {
                new GoToStatement("lbl_3")
            }));

            var sql      = loop.ToString();
            var expected = new StringBuilder();

            expected.AppendLine("FOR i IN 0...x");
            expected.AppendLine("LOOP");
            expected.AppendLine("  IF :i = 3 THEN");
            expected.AppendLine("    GOTO 'lbl_3'");
            expected.AppendLine("  END IF");
            expected.Append("END LOOP");

            Assert.AreEqual(expected.ToString(), sql);
        }