summaryrefslogtreecommitdiff
path: root/libgo/go/html/template/clone_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/html/template/clone_test.go')
-rw-r--r--libgo/go/html/template/clone_test.go32
1 files changed, 17 insertions, 15 deletions
diff --git a/libgo/go/html/template/clone_test.go b/libgo/go/html/template/clone_test.go
index ed1698acd8b..39788173b99 100644
--- a/libgo/go/html/template/clone_test.go
+++ b/libgo/go/html/template/clone_test.go
@@ -7,8 +7,6 @@ package template
import (
"bytes"
"testing"
- "text/template"
- "text/template/parse"
)
func TestClone(t *testing.T) {
@@ -48,15 +46,20 @@ func TestClone(t *testing.T) {
}
for _, test := range tests {
- s := template.Must(template.New("s").Parse(test.input))
- d := template.New("d")
- d.Tree = &parse.Tree{Name: d.Name(), Root: cloneList(s.Root)}
+ s, err := New("s").Parse(test.input)
+ if err != nil {
+ t.Errorf("input=%q: unexpected parse error %v", test.input, err)
+ }
+
+ d, _ := New("d").Parse(test.input)
+ // Hack: just replace the root of the tree.
+ d.text.Root = cloneList(s.text.Root)
- if want, got := s.Root.String(), d.Root.String(); want != got {
+ if want, got := s.text.Root.String(), d.text.Root.String(); want != got {
t.Errorf("want %q, got %q", want, got)
}
- err := escape(d)
+ err = escapeTemplates(d, "d")
if err != nil {
t.Errorf("%q: failed to escape: %s", test.input, err)
continue
@@ -73,18 +76,17 @@ func TestClone(t *testing.T) {
data := []string{"foo", "<bar>", "baz"}
- // Make sure escaping d did not affect s.
var b bytes.Buffer
- s.Execute(&b, data)
- if got := b.String(); got != test.want {
- t.Errorf("%q: want %q, got %q", test.input, test.want, got)
- continue
+ d.Execute(&b, data)
+ if got := b.String(); got != test.wantClone {
+ t.Errorf("input=%q: want %q, got %q", test.input, test.wantClone, got)
}
+ // Make sure escaping d did not affect s.
b.Reset()
- d.Execute(&b, data)
- if got := b.String(); got != test.wantClone {
- t.Errorf("%q: want %q, got %q", test.input, test.wantClone, got)
+ s.text.Execute(&b, data)
+ if got := b.String(); got != test.want {
+ t.Errorf("input=%q: want %q, got %q", test.input, test.want, got)
}
}
}