Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(976)

Unified Diff: src/pkg/text/template/parse/parse_test.go

Issue 12420044: code review 12420044: text/template/parse, html/template: copy Tree.Text duri... (Closed)
Patch Set: diff -r 238939762b61 https://code.google.com/p/go Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/text/template/parse/parse.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/text/template/parse/parse_test.go
===================================================================
--- a/src/pkg/text/template/parse/parse_test.go
+++ b/src/pkg/text/template/parse/parse_test.go
@@ -332,6 +332,28 @@
}
}
+func TestErrorContextWithShallowTreeCopy(t *testing.T) {
+ tree, err := New("root").Parse("{{if true}}{{end}}", "", "", make(map[string]*Tree), nil)
+ if err != nil {
+ t.Fatalf("unexpected tree parse failure: %v", err)
+ }
+ // copy all available (exported) fields
+ treeCopy := &Tree{
+ Name: tree.Name,
+ Root: tree.Root.CopyList(),
+ ParseName: tree.ParseName,
+ Text: tree.Text,
+ }
+ wantLocation, wantContext := tree.ErrorContext(tree.Root.Nodes[0])
+ gotLocation, gotContext := treeCopy.ErrorContext(treeCopy.Root.Nodes[0])
+ if wantLocation != gotLocation {
+ t.Errorf("wrong error location want %q got %q", wantLocation, gotLocation)
+ }
+ if wantContext != gotContext {
+ t.Errorf("wrong error location want %q got %q", wantContext, gotContext)
+ }
+}
+
// All failures, and the result is a string that must appear in the error message.
var errorTests = []parseTest{
// Check line numbers are accurate.
« no previous file with comments | « src/pkg/text/template/parse/parse.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b