2016-08-13 12:49:04 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2016-09-12 16:18:13 +00:00
|
|
|
func TestScan(t *testing.T) {
|
2016-12-18 15:01:45 +00:00
|
|
|
for _, test := range gEvalTests {
|
2016-09-12 16:18:13 +00:00
|
|
|
s := newScanner(strings.NewReader(test.inp))
|
2016-08-13 12:49:04 +00:00
|
|
|
|
2016-09-12 16:18:13 +00:00
|
|
|
for _, tok := range test.toks {
|
|
|
|
if s.scan(); s.tok != tok {
|
|
|
|
t.Errorf("at input '%s' expected '%s' but scanned '%s'", test.inp, tok, s.tok)
|
|
|
|
}
|
2016-08-13 12:49:04 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 16:18:13 +00:00
|
|
|
if s.scan() {
|
|
|
|
t.Errorf("at input '%s' unexpected '%s'", test.inp, s.tok)
|
|
|
|
}
|
2016-09-02 20:40:13 +00:00
|
|
|
}
|
2016-08-13 12:49:04 +00:00
|
|
|
}
|