Closed jagregory closed 11 years ago
The following test fails when trying to evaluate %span= v.Val.
%span= v.Val
type testObject struct{ Val int } func TestForArrayObjectRangeConstruct(t *testing.T) { scope := make(map[string]interface{}) scope["looper"] = [5]testObject{ testObject{4}, testObject{-128}, testObject{38}, testObject{99}, testObject{1}, } expected := "<p>\n" + " <span>0</span><span>4</span>\n" + " <span>1</span><span>-128</span>\n" + " <span>2</span><span>38</span>\n" + " <span>3</span><span>99</span>\n" + " <span>4</span><span>1</span>\n" + "</p>" input := "%p\n - for i, v := range looper\n %span= i<\n %span= v.Val" engine, _ := NewEngine(input) output := engine.Render(scope) if output != expected { t.Errorf("Expected\n%s\nbut got\n%s\n", expected, output) } }
--- FAIL: TestForArrayObjectRangeConstruct (0.00 seconds) lang.go:1507: Expected <p> <span>0</span><span>4</span> <span>1</span><span>-128</span> <span>2</span><span>38</span> <span>3</span><span>99</span> <span>4</span><span>1</span> </p> but got <p> <span>0</span><span><invalid Value></span> <span>1</span><span><invalid Value></span> <span>2</span><span><invalid Value></span> <span>3</span><span><invalid Value></span> <span>4</span><span><invalid Value></span> </p>
@jagregory Thanks for finding this issue. I have made a commit to fix it. I also ensured that it works for slices, too.
Great, thanks for the timely response!
The following test fails when trying to evaluate
%span= v.Val
.