File: scanner_test.go

package info (click to toggle)
golang-github-alecthomas-kong 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 832 kB
  • sloc: sh: 32; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (3)
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)
}