diff --git a/ast.go b/chunk_ast.go similarity index 100% rename from ast.go rename to chunk_ast.go diff --git a/liquid_test.go b/chunk_parser_test.go similarity index 57% rename from liquid_test.go rename to chunk_parser_test.go index f327172..df15238 100644 --- a/liquid_test.go +++ b/chunk_parser_test.go @@ -1,5 +1,3 @@ -//go:generate ragel -Z liquid.rl - package main import ( @@ -10,13 +8,7 @@ import ( "github.com/stretchr/testify/require" ) -var tests = []struct{ in, out string }{ - {"prepost", "pre:insertion:post"}, - {"pre:insertion:post", "pre:insertion:post"}, - {"post", ":insertion:post"}, -} - -func TestLiquid(t *testing.T) { +func TestChunkParser(t *testing.T) { tokens := ScanChunks("pre{%if 1%}left{{x}}right{%endif%}post", "") // fmt.Println("tokens =", tokens) ast, err := Parse(tokens) @@ -25,10 +17,8 @@ func TestLiquid(t *testing.T) { err = ast.Render(os.Stdout, nil) require.NoError(t, err) fmt.Println() - - require.True(t, true) - return + for _, test := range chunkTests { tokens := ScanChunks(test.in, "") ast, err := Parse(tokens) @@ -38,12 +28,7 @@ func TestLiquid(t *testing.T) { } } -type chunkTest struct { - in string - expected string -} - -var chunkTests = []chunkTest{ - chunkTest{"{{var}}", "value"}, - chunkTest{"{{x}}", "1"}, +var chunkTests = []struct{in, expected string}{ + {"{{var}}", "value"}, + {"{{x}}", "1"}, }