12345678910111213141516171819202122232425262728293031323334353637383940 |
- package ast
- import (
- "testing"
- "code.osinet.fr/fgm/waiig15/token"
- )
- func TestString(t *testing.T) {
- // Build a program made of a single "let myBra = anotherVar;" statement.
- 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",
- },
- },
- },
- }
- programString := program.String()
- if programString != "let myVar = anotherVar;" {
- t.Errorf("program.String() wrong. got=%q", programString)
- }
- }
|