Source file
src/go/types/methodlist_test.go
1
2
3
4
5 package types
6
7 import (
8 "go/token"
9 "testing"
10 )
11
12 func TestLazyMethodList(t *testing.T) {
13 l := newLazyMethodList(2)
14
15 if got := l.Len(); got != 2 {
16 t.Fatalf("Len() = %d, want 2", got)
17 }
18
19 f0 := NewFunc(token.NoPos, nil, "f0", nil)
20 f1 := NewFunc(token.NoPos, nil, "f1", nil)
21
22
23
24 steps := []struct {
25 index int
26 resolve *Func
27 want *Func
28 }{
29 {0, f0, f0},
30 {0, f1, f0},
31 {1, f1, f1},
32 {1, f0, f1},
33 }
34
35 for i, step := range steps {
36 got := l.At(step.index, func() *Func { return step.resolve })
37 if got != step.want {
38 t.Errorf("step %d: At(%d, ...) = %s, want %s", i, step.index, got.Name(), step.want.Name())
39 }
40 }
41 }
42
View as plain text