Enum values are just (integer) constants in Python and so can be used as the function default values just as well as literal numbers, account for this when checking whether function parameters can be represented in Python. Also rename is_primitive_defaultargs() to is_representable_as_pyargs() to describe better what this function does.
67 lines
1.1 KiB
Python
67 lines
1.1 KiB
Python
import default_args
|
|
|
|
ec = default_args.EnumClass()
|
|
if not ec.blah():
|
|
raise RuntimeError,"EnumClass::blah() default arguments don't work"
|
|
|
|
if default_args.Statics_staticMethod() != 60:
|
|
raise RuntimeError
|
|
|
|
if default_args.cfunc1(1) != 2:
|
|
raise RuntimeError
|
|
|
|
if default_args.cfunc2(1) != 3:
|
|
raise RuntimeError
|
|
|
|
if default_args.cfunc3(1) != 4:
|
|
raise RuntimeError
|
|
|
|
|
|
f = default_args.Foo()
|
|
|
|
f.newname()
|
|
f.newname(1)
|
|
|
|
|
|
try:
|
|
f = default_args.Foo(1)
|
|
error = 1
|
|
except:
|
|
error = 0
|
|
if error: raise RuntimeError,"Foo::Foo ignore is not working"
|
|
|
|
try:
|
|
f = default_args.Foo(1,2)
|
|
error = 1
|
|
except:
|
|
error = 0
|
|
if error: raise RuntimeError,"Foo::Foo ignore is not working"
|
|
|
|
try:
|
|
f = default_args.Foo(1,2,3)
|
|
error = 1
|
|
except:
|
|
error = 0
|
|
if error: raise RuntimeError,"Foo::Foo ignore is not working"
|
|
|
|
try:
|
|
m = f.meth(1)
|
|
error = 1
|
|
except:
|
|
error = 0
|
|
if error: raise RuntimeError,"Foo::meth ignore is not working"
|
|
|
|
try:
|
|
m = f.meth(1,2)
|
|
error = 1
|
|
except:
|
|
error = 0
|
|
if error: raise RuntimeError,"Foo::meth ignore is not working"
|
|
|
|
try:
|
|
m = f.meth(1,2,3)
|
|
error = 1
|
|
except:
|
|
error = 0
|
|
if error: raise RuntimeError,"Foo::meth ignore is not working"
|
|
|