diff options
Diffstat (limited to 'src/text/template/parse/lex_test.go')
-rw-r--r-- | src/text/template/parse/lex_test.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/text/template/parse/lex_test.go b/src/text/template/parse/lex_test.go index 563c4fc1cb..f6d5f285ed 100644 --- a/src/text/template/parse/lex_test.go +++ b/src/text/template/parse/lex_test.go @@ -15,6 +15,7 @@ var itemName = map[itemType]string{ itemBool: "bool", itemChar: "char", itemCharConstant: "charconst", + itemComment: "comment", itemComplex: "complex", itemDeclare: ":=", itemEOF: "EOF", @@ -90,6 +91,7 @@ var lexTests = []lexTest{ {"text", `now is the time`, []item{mkItem(itemText, "now is the time"), tEOF}}, {"text with comment", "hello-{{/* this is a comment */}}-world", []item{ mkItem(itemText, "hello-"), + mkItem(itemComment, "/* this is a comment */"), mkItem(itemText, "-world"), tEOF, }}, @@ -311,6 +313,7 @@ var lexTests = []lexTest{ }}, {"trimming spaces before and after comment", "hello- {{- /* hello */ -}} -world", []item{ mkItem(itemText, "hello-"), + mkItem(itemComment, "/* hello */"), mkItem(itemText, "-world"), tEOF, }}, @@ -389,7 +392,7 @@ var lexTests = []lexTest{ // collect gathers the emitted items into a slice. func collect(t *lexTest, left, right string) (items []item) { - l := lex(t.name, t.input, left, right) + l := lex(t.name, t.input, left, right, true) for { item := l.nextItem() items = append(items, item) @@ -529,7 +532,7 @@ func TestPos(t *testing.T) { func TestShutdown(t *testing.T) { // We need to duplicate template.Parse here to hold on to the lexer. const text = "erroneous{{define}}{{else}}1234" - lexer := lex("foo", text, "{{", "}}") + lexer := lex("foo", text, "{{", "}}", false) _, err := New("root").parseLexer(lexer) if err == nil { t.Fatalf("expected error") |