Boo.Lang.Parser.Tests.BooParserTestCase.TestIfElse1 C# (CSharp) Method

TestIfElse1() private method

private TestIfElse1 ( ) : void
return void
        public void TestIfElse1()
        {
            Boo.Lang.Compiler.Ast.Module module = ParseTestCase("if_else_1.boo");

            StatementCollection stmts = module.Globals.Statements;
            Assert.AreEqual(1, stmts.Count);

            IfStatement s = (IfStatement)stmts[0];
            BinaryExpression be = (BinaryExpression)s.Condition;
            Assert.AreEqual(BinaryOperatorType.Match, be.Operator);
            Assert.AreEqual("gets", ((ReferenceExpression)((MethodInvocationExpression)be.Left).Target).Name);
            Assert.AreEqual("/foo/", ((RELiteralExpression)be.Right).Value);
            Assert.AreEqual(3, s.TrueBlock.Statements.Count);
            Assert.IsNull(s.FalseBlock);

            s = (IfStatement)s.TrueBlock.Statements[2];
            be = (BinaryExpression)s.Condition;
            Assert.AreEqual("/bar/", ((RELiteralExpression)be.Right).Value);
            Assert.AreEqual(1, s.TrueBlock.Statements.Count);
            Assert.IsNotNull(s.FalseBlock);
            Assert.AreEqual(1, s.FalseBlock.Statements.Count);
            Assert.AreEqual("foobar, eh?", ((StringLiteralExpression)((MethodInvocationExpression)((ExpressionStatement)s.TrueBlock.Statements[0]).Expression).Arguments[0]).Value);
            Assert.AreEqual("nah?", ((StringLiteralExpression)((MethodInvocationExpression)((ExpressionStatement)s.FalseBlock.Statements[0]).Expression).Arguments[0]).Value);
        }