示例#1
0
        public void BlockWithBlock()
        {
            var sut = new SyntaxStringifyVisitor();

            sut.Visit(CreateBlock(CreateBlock()));
            sut.ToString().Should().Be("{\r\n\t{\r\n\t}\r\n}");
        }
示例#2
0
        public void FunctionDeclaration()
        {
            var sut = new SyntaxStringifyVisitor();

            sut.Visit(GetFunctionDeclaration());
            sut.ToString().Should().Be("Main\r\n{\r\n}");
        }
示例#3
0
        public static string AsString(this ISyntax node)
        {
            var visitor = new SyntaxStringifyVisitor();

            node.Accept(visitor);
            return(visitor.ToString());
        }
示例#4
0
        public void IfWithElse()
        {
            var sut       = new SyntaxStringifyVisitor();
            var condition = new Condition(new IdentifierExpression("a"), new BooleanOperator("=="),
                                          new IdentifierExpression("b"));

            sut.Visit(new IfStatement(condition, CreateBlock(), CreateBlock().Some()));
            sut.ToString().Should().Be("if (a == b)\r\n{\r\n}\r\nelse\r\n{\r\n}");
        }
示例#5
0
        public void FunctionWithIfElse()
        {
            var sut       = new SyntaxStringifyVisitor();
            var condition = new Condition(new IdentifierExpression("a"), new BooleanOperator("=="),
                                          new IdentifierExpression("b"));
            var ifStatement = new IfStatement(condition, CreateBlock(), CreateBlock().Some());
            var function    = GetFunctionDeclaration(ifStatement);

            sut.Visit(function);
            sut.ToString().Should().Be("Main\r\n{\r\n\tif (a == b)\r\n\t{\r\n\t}\r\n\telse\r\n\t{\r\n\t}\r\n}");
        }