summaryrefslogtreecommitdiff
path: root/ast/ast_test.go
diff options
context:
space:
mode:
authorMichael Tews <michael@tews.dev>2024-12-13 07:16:00 +0100
committerMichael Tews <michael@tews.dev>2026-04-12 11:11:02 +0200
commit68ff1414130b7bdd9cbfe0e5c1fc60278f9a48fd (patch)
tree5baeea833552b3f60f2c9f5dbf7d82492e066358 /ast/ast_test.go
parent0f51131eedb73d371bcf4d4868cb784f3592d08c (diff)
feat(parser): expressions, literalsHEADmain
Signed-off-by: Michael Tews <michael@tews.dev>
Diffstat (limited to 'ast/ast_test.go')
-rw-r--r--ast/ast_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/ast/ast_test.go b/ast/ast_test.go
new file mode 100644
index 0000000..887827b
--- /dev/null
+++ b/ast/ast_test.go
@@ -0,0 +1,37 @@
+package ast
+
+import (
+ "testing"
+
+ "github.com/mewsen/interpreter/token"
+)
+
+func TestString(t *testing.T) {
+ program := &Program{
+ Statements: []Statement{
+ &LetStatement{
+ Token: token.Token{
+ Type: token.LET,
+ Literal: "let",
+ },
+ Name: &Identifier{
+ Token: token.Token{
+ Type: token.IDENT,
+ Literal: "myVar",
+ },
+ Value: "myVar",
+ },
+ Value: &Identifier{
+ Token: token.Token{
+ Type: token.IDENT,
+ Literal: "anotherVar",
+ },
+ Value: "anotherVar",
+ },
+ },
+ },
+ }
+ if program.String() != "let myVar = anotherVar;" {
+ t.Errorf("program.String() wrong. got=%q", program.String())
+ }
+}