1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-27 11:34:45 +01:00
liquid/expressions/scanner_test.go

36 lines
615 B
Go
Raw Normal View History

2017-06-25 18:36:28 +02:00
//go:generate ragel -Z scanner.rl
2017-06-26 15:33:07 +02:00
//go:generate goyacc expressions.y
2017-06-25 18:36:28 +02:00
2017-06-26 15:33:07 +02:00
package expressions
2017-06-25 18:36:28 +02:00
import (
"testing"
"github.com/stretchr/testify/require"
)
// var lexerTests = []struct{}{
// {"{{var}}", "value"},
// {"{{x}}", "1"},
// }
2017-06-25 22:21:31 +02:00
func ScanExpression(data string) ([]yySymType, error) {
l := newLexer([]byte(data))
var symbols []yySymType
var s yySymType
for {
t := l.Lex(&s)
if t == 0 {
break
}
symbols = append(symbols, s)
}
return symbols, nil
}
func TestExpressionScanner(t *testing.T) {
2017-06-25 18:36:28 +02:00
tokens, err := ScanExpression("abc > 123")
require.NoError(t, err)
2017-06-26 04:59:33 +02:00
require.Len(t, tokens, 3)
2017-06-25 22:21:31 +02:00
}