template: fix comments with different delimiters.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5208042
diff --git a/src/pkg/template/exec_test.go b/src/pkg/template/exec_test.go
index 57c6325..46b89fd 100644
--- a/src/pkg/template/exec_test.go
+++ b/src/pkg/template/exec_test.go
@@ -507,14 +507,21 @@
for i := 0; i < len(delimPairs); i += 2 {
text := ".Str"
left := delimPairs[i+0]
+ trueLeft := left
right := delimPairs[i+1]
+ trueRight := right
if left == "" { // default case
- text = "{{" + text
+ trueLeft = "{{"
}
if right == "" { // default case
- text = text + "}}"
+ trueRight = "}}"
}
- text = left + text + right
+ text = trueLeft + text + trueRight
+ // Now add a comment
+ text += trueLeft + "/*comment*/" + trueRight
+ // Now add an action containing a string.
+ text += trueLeft + `"` + trueLeft + `"` + trueRight
+ // At this point text looks like `{{.Str}}{{/*comment*/}}{{"{{"}}`.
tmpl, err := New("delims").Delims(left, right).Parse(text)
if err != nil {
t.Fatalf("delim %q text %q parse err %s", left, text, err)
@@ -524,8 +531,8 @@
if err != nil {
t.Fatalf("delim %q exec err %s", left, err)
}
- if b.String() != hello {
- t.Error("expected %q got %q", hello, b.String())
+ if b.String() != hello+trueLeft {
+ t.Error("expected %q got %q", hello+trueLeft, b.String())
}
}
}