forked from alecthomas/kong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scanner_test.go
28 lines (24 loc) · 712 Bytes
/
scanner_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
package kong
import (
"testing"
"github.com/alecthomas/assert/v2"
)
func TestScannerTake(t *testing.T) {
s := Scan("a", "b", "c", "-")
assert.Equal(t, "a", s.Pop().Value)
assert.Equal(t, "b", s.Pop().Value)
assert.Equal(t, "c", s.Pop().Value)
hyphen := s.Pop()
assert.Equal(t, PositionalArgumentToken, hyphen.InferredType())
assert.Equal(t, EOLToken, s.Pop().Type)
}
func TestScannerPeek(t *testing.T) {
s := Scan("a", "b", "c")
assert.Equal(t, s.Peek().Value, "a")
assert.Equal(t, s.Pop().Value, "a")
assert.Equal(t, s.Peek().Value, "b")
assert.Equal(t, s.Pop().Value, "b")
assert.Equal(t, s.Peek().Value, "c")
assert.Equal(t, s.Pop().Value, "c")
assert.Equal(t, s.Peek().Type, EOLToken)
}