autopep8 cleanup of Examples/test-suite/python

automated cleanup of python pep8 whitespace compliance
This commit is contained in:
Jon Schlueter 2015-05-06 08:27:35 -04:00 • committed by Jon Schlueter
commit b77f3afafb
202 changed files with 3496 additions and 3401 deletions

View file

@ -2,5 +2,4 @@ import abstract_access
d = abstract_access.D()
if d.do_x() != 1:
raise RuntimeError
raise RuntimeError

View file

@ -1,8 +1,3 @@
from abstract_typedef2 import *
from abstract_typedef2 import *
a = A_UF()

View file

@ -1,11 +1,8 @@
from abstract_typedef import *
from abstract_typedef import *
e = Engine()
a = A()
if a.write(e) != 1:
raise RuntimeError
raise RuntimeError

View file

@ -1,27 +1,26 @@
from argcargvtest import *
largs=['hi','hola','hello']
largs = ['hi', 'hola', 'hello']
if mainc(largs) != 3:
raise RuntimeError("bad main typemap")
raise RuntimeError("bad main typemap")
targs=('hi','hola')
if mainv(targs,1) != 'hola':
print(mainv(targs,1))
raise RuntimeError("bad main typemap")
targs = ('hi', 'hola')
if mainv(targs, 1) != 'hola':
print(mainv(targs, 1))
raise RuntimeError("bad main typemap")
targs=('hi', 'hola')
if mainv(targs,1) != 'hola':
raise RuntimeError("bad main typemap")
targs = ('hi', 'hola')
if mainv(targs, 1) != 'hola':
raise RuntimeError("bad main typemap")
try:
error = 0
mainv('hello',1)
error = 1
error = 0
mainv('hello', 1)
error = 1
except TypeError:
pass
pass
if error:
raise RuntimeError("bad main typemap")
raise RuntimeError("bad main typemap")
initializeApp(largs)

View file

@ -3,19 +3,16 @@ from array_member import *
f = Foo()
f.data = cvar.global_data
for i in range(0,8):
if get_value(f.data,i) != get_value(cvar.global_data,i):
for i in range(0, 8):
if get_value(f.data, i) != get_value(cvar.global_data, i):
raise RuntimeError, "Bad array assignment"
for i in range(0,8):
set_value(f.data,i,-i)
for i in range(0, 8):
set_value(f.data, i, -i)
cvar.global_data = f.data
for i in range(0,8):
if get_value(f.data,i) != get_value(cvar.global_data,i):
for i in range(0, 8):
if get_value(f.data, i) != get_value(cvar.global_data, i):
raise RuntimeError, "Bad array assignment"

View file

@ -2,19 +2,19 @@ import arrays_global
arrays_global.cvar.array_i = arrays_global.cvar.array_const_i
from arrays_global import *
from arrays_global import *
BeginString_FIX44a
cvar.BeginString_FIX44b
BeginString_FIX44c
cvar.BeginString_FIX44d
cvar.BeginString_FIX44d
cvar.BeginString_FIX44b ="12"'\0'"45"
cvar.BeginString_FIX44b = "12"'\0'"45"
cvar.BeginString_FIX44b
cvar.BeginString_FIX44d
cvar.BeginString_FIX44e
BeginString_FIX44f
test_a("hello","hi","chello","chi")
test_a("hello", "hi", "chello", "chi")
test_b("1234567","hi")
test_b("1234567", "hi")

View file

@ -1,341 +1,332 @@
from autodoc import *
import sys
def check(got, expected, expected_builtin = None, skip = False):
if not skip:
expect = expected
if is_python_builtin() and expected_builtin != None:
expect = expected_builtin
if expect != got:
raise RuntimeError("\n" + "Expected: [" + str(expect) + "]\n" + "Got : [" + str(got) + "]")
def check(got, expected, expected_builtin=None, skip=False):
if not skip:
expect = expected
if is_python_builtin() and expected_builtin != None:
expect = expected_builtin
if expect != got:
raise RuntimeError(
"\n" + "Expected: [" + str(expect) + "]\n" + "Got : [" + str(got) + "]")
def is_new_style_class(cls):
return hasattr(cls, "__class__")
return hasattr(cls, "__class__")
if not is_new_style_class(A):
# Missing static methods make this hard to test... skip if -classic is used!
sys.exit(0)
# Missing static methods make this hard to test... skip if -classic is
# used!
sys.exit(0)
skip = True # skip builtin check - the autodoc is missing, but it probably should not be
# skip builtin check - the autodoc is missing, but it probably should not be
skip = True
check(A.__doc__, "Proxy of C++ A class", "::A")
check(A.funk.__doc__, "just a string")
check(A.func0.__doc__,
"func0(self, arg2, hello) -> int",
"func0(arg2, hello) -> int")
"func0(self, arg2, hello) -> int",
"func0(arg2, hello) -> int")
check(A.func1.__doc__,
"func1(A self, short arg2, Tuple hello) -> int",
"func1(short arg2, Tuple hello) -> int")
"func1(A self, short arg2, Tuple hello) -> int",
"func1(short arg2, Tuple hello) -> int")
check(A.func2.__doc__,
"\n"
" func2(self, arg2, hello) -> int\n"
"\n"
" Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" "
,
"\n"
"func2(arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
"\n"
" func2(self, arg2, hello) -> int\n"
"\n"
" Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func2(arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
check(A.func3.__doc__,
"\n"
" func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" "
,
"\n"
"func3(short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
"\n"
" func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func3(short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
check(A.func0default.__doc__,
"\n"
" func0default(self, e, arg3, hello, f=2) -> int\n"
" func0default(self, e, arg3, hello) -> int\n"
" "
,
"\n"
"func0default(e, arg3, hello, f=2) -> int\n"
"func0default(e, arg3, hello) -> int\n"
""
)
"\n"
" func0default(self, e, arg3, hello, f=2) -> int\n"
" func0default(self, e, arg3, hello) -> int\n"
" ",
"\n"
"func0default(e, arg3, hello, f=2) -> int\n"
"func0default(e, arg3, hello) -> int\n"
""
)
check(A.func1default.__doc__,
"\n"
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
" "
,
"\n"
"func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
"func1default(A e, short arg3, Tuple hello) -> int\n"
""
)
"\n"
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
" ",
"\n"
"func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
"func1default(A e, short arg3, Tuple hello) -> int\n"
""
)
check(A.func2default.__doc__,
"\n"
" func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func2default(self, e, arg3, hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
" "
,
"\n"
"func2default(e, arg3, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func2default(e, arg3, hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
"\n"
" func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func2default(self, e, arg3, hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func2default(e, arg3, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func2default(e, arg3, hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
check(A.func3default.__doc__,
"\n"
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func3default(A self, A e, short arg3, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
" "
,
"\n"
"func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func3default(A e, short arg3, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
"\n"
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func3default(A self, A e, short arg3, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func3default(A e, short arg3, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
check(A.func0static.__doc__,
"\n"
" func0static(e, arg2, hello, f=2) -> int\n"
" func0static(e, arg2, hello) -> int\n"
" "
,
"\n"
"func0static(e, arg2, hello, f=2) -> int\n"
"func0static(e, arg2, hello) -> int\n"
""
)
"\n"
" func0static(e, arg2, hello, f=2) -> int\n"
" func0static(e, arg2, hello) -> int\n"
" ",
"\n"
"func0static(e, arg2, hello, f=2) -> int\n"
"func0static(e, arg2, hello) -> int\n"
""
)
check(A.func1static.__doc__,
"\n"
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
" func1static(A e, short arg2, Tuple hello) -> int\n"
" "
,
"\n"
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"func1static(A e, short arg2, Tuple hello) -> int\n"
""
)
"\n"
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
" func1static(A e, short arg2, Tuple hello) -> int\n"
" ",
"\n"
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"func1static(A e, short arg2, Tuple hello) -> int\n"
""
)
check(A.func2static.__doc__,
"\n"
" func2static(e, arg2, hello, f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func2static(e, arg2, hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" "
,
"\n"
"func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func2static(e, arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
"\n"
" func2static(e, arg2, hello, f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func2static(e, arg2, hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func2static(e, arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
check(A.func3static.__doc__,
"\n"
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" "
,
"\n"
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
"\n"
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
""
)
if sys.version_info[0:2] > (2, 4):
# Python 2.4 does not seem to work
check(A.variable_a.__doc__,
"A_variable_a_get(self) -> int",
"A.variable_a"
)
check(A.variable_b.__doc__,
"A_variable_b_get(A self) -> int",
"A.variable_b"
)
check(A.variable_c.__doc__,
"\n"
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
,
"A.variable_c"
)
check(A.variable_d.__doc__,
"\n"
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
,
"A.variable_d"
)
# Python 2.4 does not seem to work
check(A.variable_a.__doc__,
"A_variable_a_get(self) -> int",
"A.variable_a"
)
check(A.variable_b.__doc__,
"A_variable_b_get(A self) -> int",
"A.variable_b"
)
check(A.variable_c.__doc__,
"\n"
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n",
"A.variable_c"
)
check(A.variable_d.__doc__,
"\n"
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n",
"A.variable_d"
)
check(B.__doc__,
"Proxy of C++ B class",
"::B"
)
"Proxy of C++ B class",
"::B"
)
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip)
check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D", None, skip)
check(D.__init__.__doc__,
"__init__(D self, int a, int b, Hola h) -> D", None, skip)
check(E.__init__.__doc__,
"\n"
" __init__(self, a, b, h) -> E\n"
"\n"
" Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
"\n"
" "
, None, skip
)
"\n"
" __init__(self, a, b, h) -> E\n"
"\n"
" Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
"\n"
" ", None, skip
)
check(F.__init__.__doc__,
"\n"
" __init__(F self, int a, int b, Hola h) -> F\n"
"\n"
" Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
"\n"
" "
, None, skip
)
"\n"
" __init__(F self, int a, int b, Hola h) -> F\n"
"\n"
" Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
"\n"
" ", None, skip
)
check(B.funk.__doc__,
"funk(B self, int c, int d) -> int",
"funk(int c, int d) -> int")
"funk(B self, int c, int d) -> int",
"funk(int c, int d) -> int")
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
check(funkdefaults.__doc__,
"\n"
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
" "
,
"\n"
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
"funkdefaults(A e, short arg2, int c, int d) -> int\n"
""
)
"\n"
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
" ",
"\n"
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
"funkdefaults(A e, short arg2, int c, int d) -> int\n"
""
)
check(func_input.__doc__, "func_input(int * INPUT) -> int")
check(func_output.__doc__, "func_output() -> int")

View file

@ -2,30 +2,30 @@ import _callback
from callback import *
if foo(2) != 2:
raise RuntimeError
raise RuntimeError
if A_bar(2) != 4:
raise RuntimeError
raise RuntimeError
if foobar(3, _callback.foo) != foo(3):
raise RuntimeError
raise RuntimeError
if foobar(3, foo) != foo(3):
raise RuntimeError
raise RuntimeError
if foobar(3, A_bar) != A_bar(3):
raise RuntimeError
raise RuntimeError
if foobar(3, foof) != foof(3):
raise RuntimeError
raise RuntimeError
if foobar_i(3, foo_i) != foo_i(3):
raise RuntimeError
raise RuntimeError
if foobar_d(3.5, foo_d) != foo_d(3.5):
raise RuntimeError
raise RuntimeError
a = A()
if foobarm(3, a, A.foom_cb_ptr) != a.foom(3):
raise RuntimeError
raise RuntimeError

View file

@ -2,11 +2,11 @@ from char_binary import *
t = Test()
if t.strlen('hile') != 4:
print t.strlen('hile')
raise RuntimeError, "bad multi-arg typemap"
print t.strlen('hile')
raise RuntimeError, "bad multi-arg typemap"
if t.strlen('hil\0') != 4:
raise RuntimeError, "bad multi-arg typemap"
raise RuntimeError, "bad multi-arg typemap"
#
# creating a raw char*
@ -20,17 +20,16 @@ pchar_setitem(pc, 4, 0)
if t.strlen(pc) != 4:
raise RuntimeError, "bad multi-arg typemap"
raise RuntimeError, "bad multi-arg typemap"
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
raise RuntimeError, "bad pointer case"
print cvar.var_pchar
raise RuntimeError, "bad pointer case"
cvar.var_namet = pc
#if cvar.var_namet != "hola\0":
# if cvar.var_namet != "hola\0":
if cvar.var_namet != "hola":
raise RuntimeError, "bad pointer case"
raise RuntimeError, "bad pointer case"
delete_pchar(pc)

View file

@ -4,17 +4,16 @@ defaults1 = Defaults1(1000)
defaults1 = Defaults1()
if defaults1.ret(10.0) != 10.0:
raise RuntimeError
raise RuntimeError
if defaults1.ret() != -1.0:
raise RuntimeError
raise RuntimeError
defaults2 = Defaults2(1000)
defaults2 = Defaults2()
if defaults2.ret(10.0) != 10.0:
raise RuntimeError
raise RuntimeError
if defaults2.ret() != -1.0:
raise RuntimeError
raise RuntimeError

View file

@ -1,17 +1,17 @@
import complextest
a = complex(-1,2)
a = complex(-1, 2)
if complextest.Conj(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
raise RuntimeError, "bad complex mapping"
if complextest.Conjf(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
raise RuntimeError, "bad complex mapping"
v = (complex(1,2), complex(2,3), complex(4,3), 1)
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
try:
complextest.Copy_h(v)
complextest.Copy_h(v)
except:
pass
pass

View file

@ -1,15 +1,20 @@
import constant_directive
if not isinstance(constant_directive.TYPE1_CONSTANT1,constant_directive.Type1):
raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(type(constant_directive.TYPE1_CONSTANT1)))
if not isinstance(constant_directive.getType1Instance(),constant_directive.Type1):
raise RuntimeError("Failure: getType1Instance() type: {}".format(type(constant_directive.getType1Instance())))
if not isinstance(constant_directive.TYPE1_CONSTANT1, constant_directive.Type1):
raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(
type(constant_directive.TYPE1_CONSTANT1)))
if not isinstance(constant_directive.getType1Instance(), constant_directive.Type1):
raise RuntimeError("Failure: getType1Instance() type: {}".format(
type(constant_directive.getType1Instance())))
if constant_directive.TYPE1_CONSTANT1.val != 1:
raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" % constant_directive.TYPE1_CONSTANT1.val)
raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" %
constant_directive.TYPE1_CONSTANT1.val)
if constant_directive.TYPE1_CONSTANT2.val != 2:
raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" % constant_directive.TYPE1_CONSTANT2.val)
raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" %
constant_directive.TYPE1_CONSTANT2.val)
if constant_directive.TYPE1_CONSTANT3.val != 3:
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" % constant_directive.TYPE1_CONSTANT3.val)
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" %
constant_directive.TYPE1_CONSTANT3.val)

View file

@ -11,7 +11,7 @@ p = constover.test_pconst("test")
if p != "test_pconst":
print "test_pconst failed!"
error = 1
f = constover.Foo()
p = f.test("test")
if p != "test":
@ -32,7 +32,5 @@ p = f.test_pconstm("test")
if p != "test_pconstmethod":
print "member-test_pconstm failed!"
error = 1
sys.exit(error)

View file

@ -1,7 +1,7 @@
from constructor_copy import *
f1 = Foo1(3);
f11 = Foo1(f1);
f1 = Foo1(3)
f11 = Foo1(f1)
if f1.x != f11.x:
@ -24,7 +24,7 @@ bc = Bari(bi)
if (bi.x != bc.x):
raise RuntimeError
bd = Bard(5)
try:
@ -35,4 +35,3 @@ except:
if not good:
raise RuntimeError

View file

@ -1,143 +1,142 @@
import contract
contract.test_preassert(1,2)
contract.test_preassert(1, 2)
try:
contract.test_preassert(-1)
print "Failed! Preassertions are broken"
contract.test_preassert(-1)
print "Failed! Preassertions are broken"
except:
pass
pass
contract.test_postassert(3)
try:
contract.test_postassert(-3)
print "Failed! Postassertions are broken"
contract.test_postassert(-3)
print "Failed! Postassertions are broken"
except:
pass
pass
contract.test_prepost(2,3)
contract.test_prepost(5,-4)
contract.test_prepost(2, 3)
contract.test_prepost(5, -4)
try:
contract.test_prepost(-3,4)
print "Failed! Preassertions are broken"
contract.test_prepost(-3, 4)
print "Failed! Preassertions are broken"
except:
pass
pass
try:
contract.test_prepost(4,-10)
print "Failed! Postassertions are broken"
contract.test_prepost(4, -10)
print "Failed! Postassertions are broken"
except:
pass
pass
f = contract.Foo()
f.test_preassert(4,5)
f.test_preassert(4, 5)
try:
f.test_preassert(-2,3)
print "Failed! Method preassertion."
f.test_preassert(-2, 3)
print "Failed! Method preassertion."
except:
pass
pass
f.test_postassert(4)
try:
f.test_postassert(-4)
print "Failed! Method postassertion"
f.test_postassert(-4)
print "Failed! Method postassertion"
except:
pass
pass
f.test_prepost(3,4)
f.test_prepost(4,-3)
f.test_prepost(3, 4)
f.test_prepost(4, -3)
try:
f.test_prepost(-4,2)
print "Failed! Method preassertion."
f.test_prepost(-4, 2)
print "Failed! Method preassertion."
except:
pass
pass
try:
f.test_prepost(4,-10)
print "Failed! Method postassertion."
f.test_prepost(4, -10)
print "Failed! Method postassertion."
except:
pass
pass
contract.Foo_stest_prepost(4,0)
contract.Foo_stest_prepost(4, 0)
try:
contract.Foo_stest_prepost(-4,2)
print "Failed! Static method preassertion"
contract.Foo_stest_prepost(-4, 2)
print "Failed! Static method preassertion"
except:
pass
pass
try:
contract.Foo_stest_prepost(4,-10)
print "Failed! Static method posteassertion"
contract.Foo_stest_prepost(4, -10)
print "Failed! Static method posteassertion"
except:
pass
pass
b = contract.Bar()
try:
b.test_prepost(2,-4)
print "Failed! Inherited preassertion."
b.test_prepost(2, -4)
print "Failed! Inherited preassertion."
except:
pass
pass
d = contract.D()
try:
d.foo(-1,1,1,1,1)
print "Failed! Inherited preassertion (D)."
d.foo(-1, 1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.foo(1,-1,1,1,1)
print "Failed! Inherited preassertion (D)."
d.foo(1, -1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.foo(1,1,-1,1,1)
print "Failed! Inherited preassertion (D)."
d.foo(1, 1, -1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.foo(1,1,1,-1,1)
print "Failed! Inherited preassertion (D)."
d.foo(1, 1, 1, -1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.foo(1,1,1,1,-1)
print "Failed! Inherited preassertion (D)."
d.foo(1, 1, 1, 1, -1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(-1,1,1,1,1)
print "Failed! Inherited preassertion (D)."
d.bar(-1, 1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(1,-1,1,1,1)
print "Failed! Inherited preassertion (D)."
d.bar(1, -1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(1,1,-1,1,1)
print "Failed! Inherited preassertion (D)."
d.bar(1, 1, -1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(1,1,1,-1,1)
print "Failed! Inherited preassertion (D)."
d.bar(1, 1, 1, -1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(1,1,1,1,-1)
print "Failed! Inherited preassertion (D)."
d.bar(1, 1, 1, 1, -1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
#Namespace
# Namespace
my = contract.myClass(1)
try:
my = contract.myClass(0)
print "Failed! constructor preassertion"
my = contract.myClass(0)
print "Failed! constructor preassertion"
except:
pass
pass

View file

@ -2,12 +2,13 @@ import cpp11_alternate_function_syntax
a = cpp11_alternate_function_syntax.SomeStruct()
res = a.addNormal(4,5)
res = a.addNormal(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ", res, " should be 9.")
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ",
res, " should be 9.")
res = a.addAlternate(4,5)
res = a.addAlternate(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.")
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ",
res, " should be 9.")

View file

@ -3,17 +3,16 @@ import cpp11_decltype
a = cpp11_decltype.A()
a.i = 5
if a.i != 5:
raise RuntimeError, "Assignment to a.i failed."
raise RuntimeError, "Assignment to a.i failed."
a.j = 10
if a.j != 10:
raise RuntimeError, "Assignment to a.j failed."
raise RuntimeError, "Assignment to a.j failed."
b = a.foo(5)
if b != 10:
raise RuntimeError, "foo(5) should return 10."
raise RuntimeError, "foo(5) should return 10."
b = a.foo(6)
if b != 0:
raise RuntimeError, "foo(6) should return 0."
raise RuntimeError, "foo(6) should return 0."

View file

@ -1,7 +1,9 @@
import cpp11_function_objects
import sys
class Test1(cpp11_function_objects.Test):
def __init__(self):
cpp11_function_objects.Test.__init__(self)
@ -10,14 +12,17 @@ class Test1(cpp11_function_objects.Test):
t = cpp11_function_objects.Test()
if t.value != 0:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
raise RuntimeError(
"Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
t(1,2) # adds numbers and sets value
t(1, 2) # adds numbers and sets value
if t.value != 3:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
raise RuntimeError(
"Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
t2 = Test1()
a = cpp11_function_objects.testit1(t2, 4,3)
a = cpp11_function_objects.testit1(t2, 4, 3)
if a != 12:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))
raise RuntimeError(
"Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))

View file

@ -1,4 +1,3 @@
import cpp11_initializer_list_extend
c = cpp11_initializer_list_extend.Container( [10, 20, 30, 40] )
c = cpp11_initializer_list_extend.Container([10, 20, 30, 40])

View file

@ -2,4 +2,3 @@ import cpp11_initializer_list
a = cpp11_initializer_list.A()
a = cpp11_initializer_list.A(11.1)

Some files were not shown because too many files have changed in this diff Show more