Added more tests

This commit is contained in:
Eduard Urbach 2024-08-03 23:05:09 +02:00
parent 52d1de042c
commit a811da3477
Signed by: eduard
GPG key ID: 49226B848C78F6C8
9 changed files with 77 additions and 2 deletions

View file

@ -1,5 +1,9 @@
package token
import (
"strings"
)
// List is a slice of tokens.
type List []Token
@ -24,3 +28,14 @@ func (list List) LastIndexKind(kind Kind) int {
return -1
}
// Text returns the concatenated token text.
func (list List) Text(source []byte) string {
tmp := strings.Builder{}
for _, t := range list {
tmp.WriteString(t.Text(source))
}
return tmp.String()
}