mirror of https://github.com/go-python/gopy.git
bind: test type-check for struct-setters
Change-Id: Ic5a1afd53f60e5295e20cb4e4d0358fe87b1efc3
This commit is contained in:
parent
cadb7c02b1
commit
81520d13a5
|
@ -106,6 +106,21 @@ try:
|
|||
except Exception, err:
|
||||
print "caught:", err, "| err-type:",type(err)
|
||||
pass
|
||||
|
||||
try:
|
||||
hi.Person("name","2")
|
||||
print "*ERROR* no exception raised!"
|
||||
except Exception, err:
|
||||
print "caught:", err, "| err-type:",type(err)
|
||||
pass
|
||||
|
||||
try:
|
||||
hi.Person("name",2,3)
|
||||
print "*ERROR* no exception raised!"
|
||||
except Exception, err:
|
||||
print "caught:", err, "| err-type:",type(err)
|
||||
pass
|
||||
|
||||
p = hi.Person("name")
|
||||
print p
|
||||
p = hi.Person("name", 42)
|
||||
|
@ -147,13 +162,26 @@ print c
|
|||
c = hi.Couple(P2=hi.Person("p1", 42), P1=hi.Person("p2", 52))
|
||||
print c
|
||||
|
||||
## FIXME(sbinet): this needs a Py<mytype>Check - ie: issue#16
|
||||
#try:
|
||||
# hi.Couple(1)
|
||||
# print "*ERROR* no exception raised!"
|
||||
#except Exception, err:
|
||||
# print "caught:", err, "| err-type:",type(err)
|
||||
# pass
|
||||
try:
|
||||
hi.Couple(1)
|
||||
print "*ERROR* no exception raised!"
|
||||
except Exception, err:
|
||||
print "caught:", err, "| err-type:",type(err)
|
||||
pass
|
||||
|
||||
try:
|
||||
hi.Couple(1,2)
|
||||
print "*ERROR* no exception raised!"
|
||||
except Exception, err:
|
||||
print "caught:", err, "| err-type:",type(err)
|
||||
pass
|
||||
|
||||
try:
|
||||
hi.Couple(P2=1)
|
||||
print "*ERROR* no exception raised!"
|
||||
except Exception, err:
|
||||
print "caught:", err, "| err-type:",type(err)
|
||||
pass
|
||||
|
||||
### test gc
|
||||
print "--- testing GC..."
|
||||
|
|
|
@ -153,7 +153,9 @@ caught: can't work for 24 hours!
|
|||
--- p.Salary(2): 20
|
||||
--- p.Salary(24): caught: can't work for 24 hours!
|
||||
--- Person.__init__
|
||||
caught: expected string or Unicode object, int found | err-type: <type 'exceptions.TypeError'>
|
||||
caught: invalid type for 'Name' attribute | err-type: <type 'exceptions.TypeError'>
|
||||
caught: invalid type for 'Age' attribute | err-type: <type 'exceptions.TypeError'>
|
||||
caught: Person.__init__ takes at most 2 argument(s) | err-type: <type 'exceptions.TypeError'>
|
||||
hi.Person{Name="name", Age=0}
|
||||
hi.Person{Name="name", Age=42}
|
||||
hi.Person{Name="name", Age=42}
|
||||
|
@ -175,6 +177,9 @@ hi.Couple{P1=hi.Person{Name="p1", Age=42}, P2=hi.Person{Name="", Age=0}}
|
|||
hi.Couple{P1=hi.Person{Name="p1", Age=42}, P2=hi.Person{Name="p2", Age=52}}
|
||||
hi.Couple{P1=hi.Person{Name="p1", Age=42}, P2=hi.Person{Name="p2", Age=52}}
|
||||
hi.Couple{P1=hi.Person{Name="p2", Age=52}, P2=hi.Person{Name="p1", Age=42}}
|
||||
caught: invalid type for 'P1' attribute | err-type: <type 'exceptions.TypeError'>
|
||||
caught: invalid type for 'P1' attribute | err-type: <type 'exceptions.TypeError'>
|
||||
caught: invalid type for 'P2' attribute | err-type: <type 'exceptions.TypeError'>
|
||||
--- testing GC...
|
||||
--- len(objs): 100000
|
||||
--- len(vs): 100000
|
||||
|
|
Loading…
Reference in New Issue