proc/variables: Support for interface types

This commit is contained in:
aarzilli
2015-11-12 12:30:41 +01:00
committed by Derek Parker
parent 2deb7fba20
commit 48e13a9045
6 changed files with 198 additions and 26 deletions

View File

@ -399,6 +399,20 @@ func TestEvalExpression(t *testing.T) {
{"mnil[\"Malone\"]", false, "", "", "", fmt.Errorf("key not found")},
{"m1[80:]", false, "", "", "", fmt.Errorf("map index out of bounds")},
// interfaces
{"err1", true, "error(*struct main.astruct) *{A: 1, B: 2}", "", "error", nil},
{"err2", true, "error(*struct main.bstruct) *{a: main.astruct {A: 1, B: 2}}", "", "error", nil},
{"errnil", true, "error nil", "", "error", nil},
{"iface1", true, "interface {}(*struct main.astruct) *{A: 1, B: 2}", "", "interface {}", nil},
{"ifacenil", true, "interface {} nil", "", "interface {}", nil},
{"err1 == err2", false, "false", "", "", nil},
{"err1 == iface1", false, "", "", "", fmt.Errorf("mismatched types \"error\" and \"interface {}\"")},
{"errnil == nil", false, "false", "", "", nil},
{"nil == errnil", false, "false", "", "", nil},
{"err1.(*main.astruct)", false, "*struct main.astruct {A: 1, B: 2}", "", "*struct main.astruct", nil},
{"err1.(*main.bstruct)", false, "", "", "", fmt.Errorf("interface conversion: error is *struct main.astruct, not *struct main.bstruct")},
{"errnil.(*main.astruct)", false, "", "", "", fmt.Errorf("interface conversion: error is nil, not *main.astruct")},
// combined expressions
{"c1.pb.a.A", true, "1", "", "int", nil},
{"c1.sa[1].B", false, "3", "", "int", nil},