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

Side by Side Diff: src/pkg/text/template/parse/parse_test.go

Issue 5415060: code review 5415060: text/template: new, simpler API (Closed)
Patch Set: diff -r 75348d679279 https://go.googlecode.com/hg/ Created 13 years, 3 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « src/pkg/text/template/parse/parse.go ('k') | src/pkg/text/template/template.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package parse 5 package parse
6 6
7 import ( 7 import (
8 "flag" 8 "flag"
9 "fmt" 9 "fmt"
10 "testing" 10 "testing"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 {"multidecl outside range", "{{with $v, $u := 3}}{{end}}", hasError, ""} , 229 {"multidecl outside range", "{{with $v, $u := 3}}{{end}}", hasError, ""} ,
230 {"too many decls in range", "{{range $u, $v, $w := 3}}{{end}}", hasError , ""}, 230 {"too many decls in range", "{{range $u, $v, $w := 3}}{{end}}", hasError , ""},
231 } 231 }
232 232
233 var builtins = map[string]interface{}{ 233 var builtins = map[string]interface{}{
234 "printf": fmt.Sprintf, 234 "printf": fmt.Sprintf,
235 } 235 }
236 236
237 func TestParse(t *testing.T) { 237 func TestParse(t *testing.T) {
238 for _, test := range parseTests { 238 for _, test := range parseTests {
239 » » tmpl, err := New(test.name).Parse(test.input, "", "", nil, built ins) 239 » » tmpl, err := New(test.name).Parse(test.input, "", "", make(map[s tring]*Tree), builtins)
240 switch { 240 switch {
241 case err == nil && !test.ok: 241 case err == nil && !test.ok:
242 t.Errorf("%q: expected error; got none", test.name) 242 t.Errorf("%q: expected error; got none", test.name)
243 continue 243 continue
244 case err != nil && test.ok: 244 case err != nil && test.ok:
245 t.Errorf("%q: unexpected error: %v", test.name, err) 245 t.Errorf("%q: unexpected error: %v", test.name, err)
246 continue 246 continue
247 case err != nil && !test.ok: 247 case err != nil && !test.ok:
248 // expected error, got one 248 // expected error, got one
249 if *debug { 249 if *debug {
250 fmt.Printf("%s: %s\n\t%s\n", test.name, test.inp ut, err) 250 fmt.Printf("%s: %s\n\t%s\n", test.name, test.inp ut, err)
251 } 251 }
252 continue 252 continue
253 } 253 }
254 result := tmpl.Root.String() 254 result := tmpl.Root.String()
255 if result != test.result { 255 if result != test.result {
256 t.Errorf("%s=(%q): got\n\t%v\nexpected\n\t%v", test.name , test.input, result, test.result) 256 t.Errorf("%s=(%q): got\n\t%v\nexpected\n\t%v", test.name , test.input, result, test.result)
257 } 257 }
258 } 258 }
259 } 259 }
OLDNEW
« no previous file with comments | « src/pkg/text/template/parse/parse.go ('k') | src/pkg/text/template/template.go » ('j') | no next file with comments »

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