diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-30 22:09:55 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-30 22:09:55 +0000 |
commit | 75cd0c848ff1a57a6fa90b79eef180e7a33b0a42 (patch) | |
tree | 26322d11da7cc220190e0b8430565ea207eb3eab /libgo/go/html/template/clone_test.go | |
parent | 5a333029b49a1435961f5e39c5c16294da81e322 (diff) | |
download | gcc-75cd0c848ff1a57a6fa90b79eef180e7a33b0a42.tar.gz |
libgo: Update to weekly.2012-03-22.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186026 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/html/template/clone_test.go')
-rw-r--r-- | libgo/go/html/template/clone_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libgo/go/html/template/clone_test.go b/libgo/go/html/template/clone_test.go index c612775d4f0..2663cddc24b 100644 --- a/libgo/go/html/template/clone_test.go +++ b/libgo/go/html/template/clone_test.go @@ -113,3 +113,36 @@ func TestClone(t *testing.T) { t.Errorf("t3: got %q want %q", got, want) } } + +func TestTemplates(t *testing.T) { + names := []string{"t0", "a", "lhs", "rhs"} + // Some template definitions borrowed from TestClone. + const tmpl = ` + {{define "a"}}{{template "lhs"}}{{.}}{{template "rhs"}}{{end}} + {{define "lhs"}} <a href=" {{end}} + {{define "rhs"}} "></a> {{end}}` + t0 := Must(New("t0").Parse(tmpl)) + templates := t0.Templates() + if len(templates) != len(names) { + t.Errorf("expected %d templates; got %d", len(names), len(templates)) + } + for _, name := range names { + found := false + for _, tmpl := range templates { + if name == tmpl.text.Name() { + found = true + break + } + } + if !found { + t.Error("could not find template", name) + } + } +} + +// This used to crash; http://golang.org/issue/3281 +func TestCloneCrash(t *testing.T) { + t1 := New("all") + Must(t1.New("t1").Parse(`{{define "foo"}}foo{{end}}`)) + t1.Clone() +} |