github.com/alecthomas/kong@v0.9.1-0.20240410131203-2ab5733f1179/scanner_test.go (about)

     1  package kong
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/alecthomas/assert/v2"
     7  )
     8  
     9  func TestScannerTake(t *testing.T) {
    10  	s := Scan("a", "b", "c", "-")
    11  	assert.Equal(t, "a", s.Pop().Value)
    12  	assert.Equal(t, "b", s.Pop().Value)
    13  	assert.Equal(t, "c", s.Pop().Value)
    14  	hyphen := s.Pop()
    15  	assert.Equal(t, PositionalArgumentToken, hyphen.InferredType())
    16  	assert.Equal(t, EOLToken, s.Pop().Type)
    17  }
    18  
    19  func TestScannerPeek(t *testing.T) {
    20  	s := Scan("a", "b", "c")
    21  	assert.Equal(t, s.Peek().Value, "a")
    22  	assert.Equal(t, s.Pop().Value, "a")
    23  	assert.Equal(t, s.Peek().Value, "b")
    24  	assert.Equal(t, s.Pop().Value, "b")
    25  	assert.Equal(t, s.Peek().Value, "c")
    26  	assert.Equal(t, s.Pop().Value, "c")
    27  	assert.Equal(t, s.Peek().Type, EOLToken)
    28  }