Skip to content

Commit

Permalink
#20 - add test file for ast
Browse files Browse the repository at this point in the history
  • Loading branch information
danilopedraza committed Feb 29, 2024
1 parent 37767ae commit ed25697
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ast/antlr_ast_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ast

import (
"lang/parsing"
"testing"

"github.com/antlr4-go/antlr/v4"
"github.com/stretchr/testify/assert"
)

func TestIntEval(t *testing.T) {
input := antlr.NewInputStream("1")
lexer := parsing.NewlangLexer(input)
stream := antlr.NewCommonTokenStream(lexer, 0)
p := parsing.NewlangParser(stream)
tree := p.Exp().(*parsing.IntegerContext)
walker := &CSTWalker{}

assert.Equal(t, Integer{1}, walker.VisitInteger(tree), "'1' should give a Integer node with value 1")
}

0 comments on commit ed25697

Please sign in to comment.