-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmap_test.go
47 lines (38 loc) · 971 Bytes
/
map_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package humanize
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
var mp = `
package maptest
type (
MAP map[int]string
)
var m map[string]int
var n map[string]int
`
func TestMap(t *testing.T) {
Convey("Map parser test", t, func() {
var p = &Package{}
f, err := ParseFile(mp, p)
So(err, ShouldBeNil)
p.Files = append(p.Files, f)
So(p.Bind(), ShouldBeNil)
Convey("facts about MAP", func() {
mp, err := p.FindType("MAP")
So(err, ShouldBeNil)
So(mp.Name, ShouldEqual, "MAP")
So(mp.Type, ShouldHaveSameTypeAs, &MapType{})
So(mp.String(), ShouldEqual, "MAP map[int]string")
mpt := mp.Type.(*MapType)
So(mpt.Key, ShouldHaveSameTypeAs, &IdentType{})
So(mpt.Value, ShouldHaveSameTypeAs, &IdentType{})
So(mpt.Package().Equal(p), ShouldBeTrue)
m, err := p.FindVariable("m")
So(err, ShouldBeNil)
n, err := p.FindVariable("n")
So(err, ShouldBeNil)
So(m.Type.Equal(n.Type), ShouldBeTrue)
})
})
}