-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_test.go
63 lines (52 loc) · 884 Bytes
/
parse_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package jia
import (
"strings"
"testing"
)
const testFile = `
package main
import (
"time"
"somepkg/models"
)
type Phone string
type User struct {
Id int
Name string
Phone Phone
}
type Customer struct {
User
Id int
createdAt time.Time
Order []models.Device
}
func (c *Customer) SayHello() string {
return ""
}
func removeCustomer(customerId int) error {
// DO some
return nil
}
func FindCustomer(userId, customerId int) (*Customer, error) {
return nil, nil
}
func CreateOrder(customerId int, order models.Device) (*models.Device, error) {
return nil, nil
}
`
func TestParse(t *testing.T) {
r := strings.NewReader(testFile)
f, err := ParseFile("user.go", r)
if err != nil {
t.Error(err)
}
for _, fc := range f.Funcs {
for _, p := range fc.Params {
t.Log(p)
t.Logf("%s", p.Type)
t.Log(p.Type)
t.Log(p.TypeKind())
}
}
}