I’ve looked at the test cases in tpl/template_test.go. I didn’t find any that set up a variable for the test.
How would I do this? Create a new htmlTemplate and parse it and examine the results? Is there something in the ACE test cases that I could use as a starting point?
It is supposed to return a string with the type of the variable. I’m using something similar to this:
func TestInspectTypeOf(t *testing.T) {
for i, this := range []struct {
v interface{}
expect interface{}
}{
{0, "int"},
{0.0, "float64"},
{"Hello, World!", "string"},
{"$foo", "string"},
{".", "*hugolib.Node"},
} {
result := InspectTypeOf(this.v)
if !reflect.DeepEqual(result, this.expect) {
t.Errorf("[%d] typeOf got %v but expected %v", i, result, this.expect)
}
}
}
The issue is that $foo and . isn’t being tested correctly because in this context they are Go strings, not Hugo variables. I looked in templates_test.go but didn’t see any functions that were setting Hugo variables.