diff options
| author | Rob Pike <r@golang.org> | 2012-04-03 11:44:52 +1000 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2012-04-03 11:44:52 +1000 |
| commit | 065db4ea99f80cce6d9ed794467697955f0eaa2e (patch) | |
| tree | d22a9bc9efb8c48779e2ea98bae8eeda22f04efa /src/pkg/text/template/exec_test.go | |
| parent | d3c92b7c903064f31c6f0aec4c3be5cfd30b0e53 (diff) | |
| download | go-065db4ea99f80cce6d9ed794467697955f0eaa2e.tar.xz | |
text/template: pipelined arg was not typechecked
Without this fix, an erroneous template causes a panic; should be caught safely.
The bug did not affect correct templates.
Fixes #3267.
R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/5900065
Diffstat (limited to 'src/pkg/text/template/exec_test.go')
| -rw-r--r-- | src/pkg/text/template/exec_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/pkg/text/template/exec_test.go b/src/pkg/text/template/exec_test.go index 5446027ff7..37d25f470c 100644 --- a/src/pkg/text/template/exec_test.go +++ b/src/pkg/text/template/exec_test.go @@ -470,6 +470,9 @@ var execTests = []execTest{ {"bug7a", "{{3 2}}", "", tVal, false}, {"bug7b", "{{$x := 1}}{{$x 2}}", "", tVal, false}, {"bug7c", "{{$x := 1}}{{3 | $x}}", "", tVal, false}, + // Pipelined arg was not being type-checked. + {"bug8a", "{{3|oneArg}}", "", tVal, false}, + {"bug8b", "{{4|dddArg 3}}", "", tVal, false}, } func zeroArgs() string { @@ -480,6 +483,10 @@ func oneArg(a string) string { return "oneArg=" + a } +func dddArg(a int, b ...string) string { + return fmt.Sprintln(a, b) +} + // count returns a channel that will deliver n sequential 1-letter strings starting at "a" func count(n int) chan string { if n == 0 { @@ -504,6 +511,7 @@ func testExecute(execTests []execTest, template *Template, t *testing.T) { b := new(bytes.Buffer) funcs := FuncMap{ "count": count, + "dddArg": dddArg, "oneArg": oneArg, "typeOf": typeOf, "vfunc": vfunc, |
