2016-09-12 16:19:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParse(t *testing.T) {
|
2016-12-18 15:01:45 +00:00
|
|
|
for _, test := range gEvalTests {
|
2016-09-12 16:19:47 +00:00
|
|
|
p := newParser(strings.NewReader(test.inp))
|
|
|
|
|
|
|
|
for _, expr := range test.exprs {
|
|
|
|
if p.parse(); !reflect.DeepEqual(p.expr, expr) {
|
|
|
|
t.Errorf("at input '%s' expected '%s' but parsed '%s'", test.inp, expr, p.expr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if p.parse(); p.expr != nil {
|
|
|
|
t.Errorf("at input '%s' unexpected '%s'", test.inp, p.expr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|