Ejemplo n.º 1
0
        public void ParseProgram_WithDoubleValues()
        {
            var expectedAst = new AstList(new IAstNode[] {
                new AstSymbol("+"),
                new AstDoubleNumber(0.1),
                new AstDoubleNumber(0.2),
            });

            AstAssert.Program(expectedAst, "(+ 0.1 0.2)");
        }
Ejemplo n.º 2
0
        public void ParseProgram_AddingTwoNumbers()
        {
            var expectedAst = new AstList(new IAstNode[] {
                new AstSymbol("add"),
                new AstIntNumber(2),
                new AstIntNumber(3),
            });

            AstAssert.Program(expectedAst, "(add 2 3)");
        }
Ejemplo n.º 3
0
        public void ParseProgram_WithStringValues()
        {
            var expectedAst = new AstList(new IAstNode[] {
                new AstSymbol("strcat"),
                new AstString("foo"),
                new AstString("bar"),
            });

            AstAssert.Program(expectedAst, "(strcat \"foo\" \"bar\")");
        }
Ejemplo n.º 4
0
        public void ParseProgram_WithNegativeNumbers()
        {
            var expectedAst = new AstList(new IAstNode[] {
                new AstSymbol("*"),
                new AstIntNumber(-3),
                new AstIntNumber(6),
            });

            AstAssert.Program(expectedAst, "(* -3 6)");
        }
Ejemplo n.º 5
0
        public void ParseProgram_WithQuote()
        {
            var expectedAst = new AstList(
                new AstSymbol("quote"), new AstList(
                    new AstIntNumber(1),
                    new AstIntNumber(2),
                    new AstIntNumber(3)
                    )
                );

            AstAssert.Program(expectedAst, "'(1 2 3)");
        }
Ejemplo n.º 6
0
        public void ParseProgram_ParsingListInList()
        {
            var expectedAst = new AstList(new IAstNode[] {
                new AstSymbol("add"),
                new AstIntNumber(2),
                new AstList(new IAstNode[] {
                    new AstSymbol("mul"),
                    new AstIntNumber(3),
                    new AstIntNumber(4),
                }),
            });

            AstAssert.Program(expectedAst, "(add 2 (mul 3 4))");
        }
Ejemplo n.º 7
0
        public void ParseProgram_ParsingMathOperation()
        {
            var expectedAst = new AstList(new IAstNode[] {
                new AstSymbol("-"),
                new AstList(new IAstNode[] {
                    new AstSymbol("+"),
                    new AstIntNumber(5),
                    new AstList(new IAstNode[] {
                        new AstSymbol("*"),
                        new AstIntNumber(2),
                        new AstIntNumber(3),
                    }),
                }),
                new AstIntNumber(3),
            });

            AstAssert.Program(expectedAst, "(- (+ 5 (* 2 3)) 3)");
        }