1
0
mirror of https://github.com/danog/liquid.git synced 2025-01-23 02:01:11 +01:00
liquid/expression_parser_test.go
2017-06-26 08:23:50 -04:00

36 lines
614 B
Go

//go:generate ragel -Z scanner.rl
//go:generate goyacc expression_parser.y
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
// var lexerTests = []struct{}{
// {"{{var}}", "value"},
// {"{{x}}", "1"},
// }
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) {
tokens, err := ScanExpression("abc > 123")
require.NoError(t, err)
require.Len(t, tokens, 3)
}