Commit fa7be65b authored by Russ Cox's avatar Russ Cox

template bug

--- FAIL: template.TestAll
	for "{.section data}{.end} {header}\n": expected " 77\n" got " {header}\n"

R=r
DELTA=20  (14 added, 0 deleted, 6 changed)
OCL=27395
CL=27402
parent 6d617a88
......@@ -34,8 +34,8 @@ type S struct {
var t1 = T{ "ItemNumber1", "ValueNumber1" }
var t2 = T{ "ItemNumber2", "ValueNumber2" }
func uppercase(v reflect.Value) string {
s := reflect.Indirect(v).(reflect.StringValue).Get();
func uppercase(v interface{}) string {
s := v.(string);
t := "";
for i := 0; i < len(s); i++ {
c := s[i];
......@@ -47,14 +47,21 @@ func uppercase(v reflect.Value) string {
return t;
}
func plus1(v reflect.Value) string {
i := reflect.Indirect(v).(reflect.IntValue).Get();
func plus1(v interface{}) string {
i := v.(int);
return fmt.Sprint(i + 1);
}
func writer(f func(interface{}) string) (func(io.Write, interface{}, string)) {
return func(w io.Write, v interface{}, format string) {
io.WriteString(w, f(v));
}
}
var formatters = FormatterMap {
"uppercase" : uppercase,
"+1" : plus1,
"uppercase" : writer(uppercase),
"+1" : writer(plus1),
}
var tests = []*Test {
......@@ -149,6 +156,13 @@ var tests = []*Test {
"HEADER=78\n"
"Header=77\n"
},
// Bugs
// &Test{
// "{.section data}{.end} {header}\n",
//
// " 77\n"
// },
}
func TestAll(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment