Files
monkey/ast/ast_test.go
Chuck Smith 6282075e66
Some checks failed
Build / build (push) Successful in 10m26s
Test / build (push) Failing after 16m44s
bind expression (:=) instead of let
2024-03-21 17:43:03 -04:00

31 lines
673 B
Go

package ast
import (
"github.com/stretchr/testify/assert"
"monkey/token"
"testing"
)
func TestString(t *testing.T) {
program := &Program{
Statements: []Statement{
&ExpressionStatement{
Token: token.Token{Type: token.IDENT, Literal: "myVar"},
Expression: &BindExpression{
Token: token.Token{Type: token.BIND, Literal: ":="},
Left: &Identifier{
Token: token.Token{Type: token.IDENT, Literal: "myVar"},
Value: "myVar",
},
Value: &Identifier{
Token: token.Token{Type: token.IDENT, Literal: "anotherVar"},
Value: "anotherVar",
},
},
},
},
}
assert.Equal(t, "myVar:=anotherVar", program.String())
}