Added more tests
This commit is contained in:
parent
52d1de042c
commit
a811da3477
9 changed files with 77 additions and 2 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue