aboutsummaryrefslogtreecommitdiff
path: root/ast/ast_test.go
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-11-03 14:38:47 +0000
committerBobby <[email protected]>2023-11-03 14:38:47 +0000
commit15f9a15757322221d8bf9a3ecd5d8ce8490ebda6 (patch)
tree1b3e5008cca84aa614d70b4e5c553a329ef47c7d /ast/ast_test.go
parenta2480336996a7b1be082386e8db1c59ed6509b2a (diff)
downloadmana-15f9a15757322221d8bf9a3ecd5d8ce8490ebda6.tar.xz
mana-15f9a15757322221d8bf9a3ecd5d8ce8490ebda6.zip
ast:String() method and tests
Diffstat (limited to 'ast/ast_test.go')
-rw-r--r--ast/ast_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/ast/ast_test.go b/ast/ast_test.go
new file mode 100644
index 0000000..e16cc11
--- /dev/null
+++ b/ast/ast_test.go
@@ -0,0 +1,28 @@
+package ast
+
+import (
+ "mana/tokens"
+ "testing"
+)
+
+func TestString(t *testing.T) {
+ var program = &Program{
+ Statements: []Statement{
+ &LetStatement{
+ Token: tokens.Token{Type: tokens.LET, Literal: "let"},
+ Name: &Identifier{
+ Token: tokens.Token{Type: tokens.IDENT, Literal: "myVar"},
+ Value: "myVar",
+ },
+ Value: &Identifier{
+ Token: tokens.Token{Type: tokens.IDENT, Literal: "anotherVar"},
+ Value: "anotherVar",
+ },
+ },
+ },
+ }
+
+ if program.String() != "let myVar = anotherVar;" {
+ t.Errorf("program.String() wrong. got=%q", program.String())
+ }
+}