diff options
| author | Rob Pike <r@golang.org> | 2012-02-11 14:21:16 +1100 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2012-02-11 14:21:16 +1100 |
| commit | b027a0f11857636314e3e149fc785feb79420e9e (patch) | |
| tree | 974a440b1551113d01821c41d43b3910d59fd0d8 /src/pkg/text/template/parse/parse_test.go | |
| parent | ca5da31f83517780893423e46665d48149e545ee (diff) | |
| download | go-b027a0f11857636314e3e149fc785feb79420e9e.tar.xz | |
text/template/parse: deep Copy method for nodes
This will help html/template copy templates.
R=golang-dev, gri, nigeltao, r
CC=golang-dev
https://golang.org/cl/5653062
Diffstat (limited to 'src/pkg/text/template/parse/parse_test.go')
| -rw-r--r-- | src/pkg/text/template/parse/parse_test.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/pkg/text/template/parse/parse_test.go b/src/pkg/text/template/parse/parse_test.go index 13c5548abb..efa7d8be74 100644 --- a/src/pkg/text/template/parse/parse_test.go +++ b/src/pkg/text/template/parse/parse_test.go @@ -232,7 +232,7 @@ var builtins = map[string]interface{}{ "printf": fmt.Sprintf, } -func TestParse(t *testing.T) { +func testParse(doCopy bool, t *testing.T) { for _, test := range parseTests { tmpl, err := New(test.name).Parse(test.input, "", "", make(map[string]*Tree), builtins) switch { @@ -249,13 +249,27 @@ func TestParse(t *testing.T) { } continue } - result := tmpl.Root.String() + var result string + if doCopy { + result = tmpl.Root.Copy().String() + } else { + result = tmpl.Root.String() + } if result != test.result { t.Errorf("%s=(%q): got\n\t%v\nexpected\n\t%v", test.name, test.input, result, test.result) } } } +func TestParse(t *testing.T) { + testParse(false, t) +} + +// Same as TestParse, but we copy the node first +func TestParseCopy(t *testing.T) { + testParse(true, t) +} + type isEmptyTest struct { name string input string |
