You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
628 B
Go
30 lines
628 B
Go
package ast
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.paas.celticinfo.fr/oabrivard/monkeylang/monkey2/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())
|
|
}
|
|
}
|