Fix lang/check tests

This commit is contained in:
Nigel Tao committed 2018-01-06 17:03:36 +11:00
1 parent 087b3e8438
commit ad277871f5
1 file changed
+16 -13
+16 -13
View File
@@ -117,22 +117,26 @@ func TestCheck(tt *testing.T) {
tt.Fatalf("Check: %v", err) tt.Fatalf("Check: %v", err)
} }
funcs := c.Funcs() if len(c.funcs) != 1 {
if len(funcs) != 1 { tt.Fatalf("Funcs: got %d elements, want 1", len(c.funcs))
tt.Fatalf("Funcs: got %d elements, want 1", len(funcs))
} }
fooBar := Func{} fooBar := (*a.Func)(nil)
for _, f := range funcs { fooBarLocalVars := typeMap(nil)
for _, f := range c.funcs {
fooBar = f fooBar = f
break break
} }
for _, v := range c.localVars {
fooBarLocalVars = v
break
}
if got, want := fooBar.QQID.Str(tm), "foo.bar"; got != want { if got, want := fooBar.QQID().Str(tm), "foo.bar"; got != want {
tt.Fatalf("Funcs[0] name: got %q, want %q", got, want) tt.Fatalf("Funcs[0] name: got %q, want %q", got, want)
} }
got := [][2]string(nil) got := [][2]string(nil)
for id, typ := range fooBar.LocalVars { for id, typ := range fooBarLocalVars {
got = append(got, [2]string{ got = append(got, [2]string{
id.Str(tm), id.Str(tm),
typ.Str(tm), typ.Str(tm),
@@ -215,17 +219,16 @@ func TestConstValues(tt *testing.T) {
continue continue
} }
funcs := c.Funcs() if len(c.funcs) != 1 {
if len(funcs) != 1 { tt.Errorf("%q: Funcs: got %d elements, want 1", s, len(c.funcs))
tt.Errorf("%q: Funcs: got %d elements, want 1", s, len(funcs))
continue continue
} }
foo := Func{} foo := (*a.Func)(nil)
for _, f := range funcs { for _, f := range c.funcs {
foo = f foo = f
break break
} }
body := foo.Func.Body() body := foo.Body()
if len(body) != 1 { if len(body) != 1 {
tt.Errorf("%q: Body: got %d elements, want 1", s, len(body)) tt.Errorf("%q: Body: got %d elements, want 1", s, len(body))
continue continue