diff --git a/_examples/hi/hi.go b/_examples/hi/hi.go index a44f36e..35f0cd7 100644 --- a/_examples/hi/hi.go +++ b/_examples/hi/hi.go @@ -89,3 +89,22 @@ func (p *Person) Salary(h int) (int, error) { } return h * 10, nil } + +// Couple is a pair of persons +type Couple struct { + P1 Person + P2 Person +} + +// FIXME(sbinet) -- expose! +// NewCouple returns a new couple made of the p1 and p2 persons. +func newCouple(p1, p2 Person) Couple { + return Couple{ + P1: p1, + P2: p2, + } +} + +func (c *Couple) String() string { + return fmt.Sprintf("hi.Couple{P1=%v, P2=%v}", c.P1, c.P2) +} diff --git a/_examples/hi/test.py b/_examples/hi/test.py index f8c126d..7b760bc 100644 --- a/_examples/hi/test.py +++ b/_examples/hi/test.py @@ -89,3 +89,10 @@ print "--- hi.NewPerson('me', 666):", hi.NewPerson("me", 666) print "--- hi.NewPersonWithAge(666):", hi.NewPersonWithAge(666) print "--- hi.NewActivePerson(4):", hi.NewActivePerson(4) +## test Couple +print "--- c = hi.Couple()..." +c = hi.Couple() +print c + +## FIXME(sbinet) -- segfaults! +#print "--- c.P1:", c.P1 diff --git a/main_test.go b/main_test.go index 0ed81ac..38487e6 100644 --- a/main_test.go +++ b/main_test.go @@ -115,6 +115,8 @@ caught: Person.__init__ takes no argument | err-type: