-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlexer_test.go
42 lines (39 loc) · 902 Bytes
/
lexer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package wfobj
import (
"testing"
)
func discard(ch <-chan *Token, done chan []*Token, t *testing.T) {
buff := make([]*Token, 0)
for tok := range ch {
// enable for debugging
//t.Logf("Token: %v", tok)
buff = append(buff, tok)
}
done <- buff
}
func TestParser(t *testing.T) {
for _, test := range testdata {
if test.ignore {
continue
}
t.Logf("Title: %v", test.title)
p := NewLiteralParser(test.objlit)
//p.Debug = &PrintState{}
done := make(chan []*Token)
go discard(p.Tokens, done, t)
err := p.Parse()
if err != nil {
t.Errorf("Unable to parse the cube.obj file. %v", err)
}
tmp := <-done
if len(tmp) != len(test.tokens) {
t.Errorf("Expecting %v tokens but got %v", len(test.tokens), len(tmp))
continue
}
for i, tok := range tmp {
if tok.Kind != test.tokens[i].Kind {
t.Errorf("Expecting %v but got %v", test.tokens[i], tok)
}
}
}
}