diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-10-28 09:12:20 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-10-28 09:12:20 -0400 |
commit | a16e30d162c1c7408db7821e7b9513cefa09c6ca (patch) | |
tree | af752ba9ba44c547df39bb0af9bff79f610ba9d5 /src/text/template/parse/parse_test.go | |
parent | 91e4d2d57bc341dd82c98247117114c851380aef (diff) | |
parent | cf6cfba4d5358404dd890f6025e573a4b2156543 (diff) | |
download | go-git-dev.link.tar.gz |
[dev.link] all: merge branch 'master' into dev.linkdev.link
Clean merge.
Change-Id: Ia7b2808bc649790198d34c226a61d9e569084dc5
Diffstat (limited to 'src/text/template/parse/parse_test.go')
-rw-r--r-- | src/text/template/parse/parse_test.go | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/text/template/parse/parse_test.go b/src/text/template/parse/parse_test.go index d9c13c5d95..220f984777 100644 --- a/src/text/template/parse/parse_test.go +++ b/src/text/template/parse/parse_test.go @@ -250,6 +250,13 @@ var parseTests = []parseTest{ {"comment trim left and right", "x \r\n\t{{- /* */ -}}\n\n\ty", noError, `"x""y"`}, {"block definition", `{{block "foo" .}}hello{{end}}`, noError, `{{template "foo" .}}`}, + + {"newline in assignment", "{{ $x \n := \n 1 \n }}", noError, "{{$x := 1}}"}, + {"newline in empty action", "{{\n}}", hasError, "{{\n}}"}, + {"newline in pipeline", "{{\n\"x\"\n|\nprintf\n}}", noError, `{{"x" | printf}}`}, + {"newline in comment", "{{/*\nhello\n*/}}", noError, ""}, + {"newline in comment", "{{-\n/*\nhello\n*/\n-}}", noError, ""}, + // Errors. {"unclosed action", "hello{{range", hasError, ""}, {"unmatched end", "{{end}}", hasError, ""}, @@ -426,23 +433,38 @@ var errorTests = []parseTest{ // Check line numbers are accurate. {"unclosed1", "line1\n{{", - hasError, `unclosed1:2: unexpected unclosed action in command`}, + hasError, `unclosed1:2: unclosed action`}, {"unclosed2", "line1\n{{define `x`}}line2\n{{", - hasError, `unclosed2:3: unexpected unclosed action in command`}, + hasError, `unclosed2:3: unclosed action`}, + {"unclosed3", + "line1\n{{\"x\"\n\"y\"\n", + hasError, `unclosed3:4: unclosed action started at unclosed3:2`}, + {"unclosed4", + "{{\n\n\n\n\n", + hasError, `unclosed4:6: unclosed action started at unclosed4:1`}, + {"var1", + "line1\n{{\nx\n}}", + hasError, `var1:3: function "x" not defined`}, // Specific errors. {"function", "{{foo}}", hasError, `function "foo" not defined`}, - {"comment", + {"comment1", "{{/*}}", - hasError, `unclosed comment`}, + hasError, `comment1:1: unclosed comment`}, + {"comment2", + "{{/*\nhello\n}}", + hasError, `comment2:1: unclosed comment`}, {"lparen", "{{.X (1 2 3}}", hasError, `unclosed left paren`}, {"rparen", - "{{.X 1 2 3)}}", - hasError, `unexpected ")"`}, + "{{.X 1 2 3 ) }}", + hasError, `unexpected ")" in command`}, + {"rparen2", + "{{(.X 1 2 3", + hasError, `unclosed action`}, {"space", "{{`x`3}}", hasError, `in operand`}, @@ -488,7 +510,7 @@ var errorTests = []parseTest{ hasError, `missing value for parenthesized pipeline`}, {"multilinerawstring", "{{ $v := `\n` }} {{", - hasError, `multilinerawstring:2: unexpected unclosed action`}, + hasError, `multilinerawstring:2: unclosed action`}, {"rangeundefvar", "{{range $k}}{{end}}", hasError, `undefined variable`}, |