umx_compiler

UMX virtual machine "Monkey" interpreter / bytecode compiler
git clone git://bsandro.tech/umx_compiler
Log | Files | Refs | README | LICENSE

ast_test.go (587B)


      1 package ast
      2 
      3 import (
      4 	"umx_compiler/token"
      5 	"testing"
      6 )
      7 
      8 func TestString(t *testing.T) {
      9 	program := &Program{
     10 		Statements: []Statement{
     11 			&LetStatement{
     12 				Token: token.Token{Type: token.LET, Literal: "let"},
     13 				Name: &Identifier{
     14 					Token: token.Token{Type: token.IDENT, Literal: "myVar"},
     15 					Value: "myVar",
     16 				},
     17 				Value: &Identifier{
     18 					Token: token.Token{Type: token.IDENT, Literal: "anotherVar"},
     19 					Value: "anotherVar",
     20 				},
     21 			},
     22 		},
     23 	}
     24 
     25 	if program.String() != "let myVar = anotherVar;" {
     26 		t.Errorf("program.String() is wrong: '%s'", program.String())
     27 	}
     28 }