int main() { init_python_api("cc4b05b9-4ff9-4127-85b0-300298d16c3c"); setup_test_functions(); PyWorldTime * world_time = newPyWorldTime(); assert(world_time != 0); run_python_string("from server import WorldTime"); expect_python_error("WorldTime()", PyExc_TypeError); run_python_string("WorldTime(23)"); // FIXME This started failing with Python 2.7 // run_python_string("WorldTime(23.1)"); run_python_string("w=WorldTime(23)"); run_python_string("w.season"); expect_python_error("w.foo", PyExc_AttributeError); run_python_string("w.is_now('morning')"); expect_python_error("w.is_now(1)", PyExc_TypeError); run_python_string("w.seconds()"); #ifdef CYPHESIS_DEBUG run_python_string("import sabotage"); run_python_string("sabotage.null(w)"); // Hit the assert checks. expect_python_error("w.is_now('morning')", PyExc_AssertionError); expect_python_error("w.seconds()", PyExc_AssertionError); #endif // NDEBUG shutdown_python_api(); return 0; }
int main() { init_python_api("bac81904-0516-4dd0-b9d8-32e879339b96"); setup_test_functions(); run_python_string("from server import *"); run_python_string("import testprop"); run_python_string("t=Thing('1')"); expect_python_error("t.terrain", PyExc_AttributeError); run_python_string("testprop.add_properties(t)"); run_python_string("terrain = t.terrain"); expect_python_error("terrain.foo = 1", PyExc_AttributeError); expect_python_error("terrain.get_height()", PyExc_TypeError); run_python_string("terrain.get_height(0,0)"); expect_python_error("terrain.get_surface()", PyExc_TypeError); expect_python_error("terrain.get_surface('1')", PyExc_TypeError); run_python_string("from physics import *"); expect_python_error("terrain.get_surface(Point3D(0,0,0))", PyExc_TypeError); expect_python_error("terrain.get_normal()", PyExc_TypeError); run_python_string("terrain.get_normal(0,0)"); run_python_string("terrain.find_mods(Point3D(0,0,0))"); run_python_string("points = { }"); run_python_string("points['-1x-1'] = [-1, -1, -16.8]"); run_python_string("points['0x-1'] = [0, -1, -3.8]"); run_python_string("points['-1x0'] = [-1, 0, -2.8]"); run_python_string("points['-1x1'] = [-1, 1, -1.8]"); run_python_string("points['1x-1'] = [1, -1, 15.8]"); run_python_string("points['0x0'] = [0, 0, 12.8]"); run_python_string("points['1x0'] = [1, 0, 23.1]"); run_python_string("points['0x1'] = [0, 1, 14.2]"); run_python_string("points['1x1'] = [1, 1, 19.7]"); run_python_string("t.terrain = {'points': points}"); run_python_string("terrain.get_surface(Point3D(0,0,0))"); #ifdef CYPHESIS_DEBUG run_python_string("import sabotage"); // Hit the assert checks. run_python_string("method_get_height = terrain.get_height"); run_python_string("method_get_surface = terrain.get_surface"); run_python_string("method_get_normal = terrain.get_normal"); run_python_string("sabotage.null(terrain)"); expect_python_error("method_get_height(0,0)", PyExc_AssertionError); expect_python_error("method_get_surface(Point3D(0,0,0))", PyExc_AssertionError); expect_python_error("method_get_normal(0,0)", PyExc_AssertionError); #endif // NDEBUG shutdown_python_api(); return 0; }
int main() { init_python_api({&CyPy_Atlas::init, &CyPy_Physics::init, &CyPy_Common::init}); run_python_string("from physics import BBox"); run_python_string("b=BBox()"); expect_python_error("b=BBox([1])", PyExc_ValueError); run_python_string("b=BBox([1,1,1])"); run_python_string("b=BBox([1.0,1.0,1.0])"); run_python_string("b=BBox([1,1,1])"); expect_python_error("b=BBox(['1','1','1'])", PyExc_TypeError); run_python_string("from atlas import ElementList"); run_python_string("b=BBox(ElementList(1,1,1))"); expect_python_error("b=BBox(ElementList('1', '1','1'))", PyExc_TypeError); expect_python_error("b=BBox(1)", PyExc_TypeError); expect_python_error("b=BBox(1,1)", PyExc_TypeError); run_python_string("b=BBox(1,1,1)"); run_python_string("b=BBox(1.0,1.0,1.0)"); expect_python_error("b=BBox('1','1','1')", PyExc_TypeError); run_python_string("b=BBox(0.0,0.0,0.0,1.0,1.0,1.0)"); run_python_string("from physics import Point3D"); run_python_string("assert b.low_corner == Point3D(0.0,0.0,0.0)"); run_python_string("assert b.high_corner == Point3D(1.0,1.0,1.0)"); run_python_string("assert b.as_sequence() == [0.0,0.0,0.0,1.0,1.0,1.0]"); run_python_string("assert b.square_bounding_radius() > 1"); expect_python_error("b.low_corner=1", PyExc_TypeError); expect_python_error("b.low_corner=Point3D()", PyExc_ValueError); expect_python_error("b.high_corner=Point3D()", PyExc_ValueError); run_python_string("b.low_corner=Point3D(0,0,0)"); run_python_string("b.high_corner=Point3D(2,2,2)"); expect_python_error("b.other=Point3D(0,0,0)", PyExc_AttributeError); run_python_string("assert b.high_corner == Point3D(2,2,2)"); run_python_string("assert b.square_bounding_radius() > 2"); run_python_string("b2=BBox()"); run_python_string("assert not b == b2"); run_python_string("assert b != b2"); run_python_string("b2.low_corner=Point3D(0,0,0)"); run_python_string("b2.high_corner=Point3D(2,2,2)"); run_python_string("assert b == b2"); run_python_string("assert not b != b2"); run_python_string("assert not b == '0'"); shutdown_python_api(); return 0; }
int main() { init_python_api("b513b7b1-b0d8-4495-b3f0-54c2ef3f27f6"); setup_test_functions(); Entity wrld("0", 0); TestWorld tw(wrld); run_python_string("from server import *"); run_python_string("import testprop"); run_python_string("t=Thing('1')"); expect_python_error("t.line", PyExc_AttributeError); expect_python_error("t.statistics", PyExc_AttributeError); expect_python_error("t.terrain", PyExc_AttributeError); run_python_string("testprop.add_properties(t)"); run_python_string("t.line"); run_python_string("t.statistics"); run_python_string("t.terrain"); shutdown_python_api(); return 0; }
int main() { init_python_api("cb44c6cc-64fa-46c4-83d1-f43c6a2bb56c"); Entity wrld("0", 0); TestWorld tw(wrld); run_python_string("from server import World"); run_python_string("w=World()"); run_python_string("w.get_time()"); run_python_string("w.get_object('0')"); run_python_string("w.get_object('1')"); expect_python_error("w.get_object(1)", PyExc_TypeError); run_python_string("w == World()"); shutdown_python_api(); return 0; }
int main() { init_python_api("3622159a-de3c-42e6-858c-f6bd7cf8e7b1"); setup_test_functions(); PyOperation * op = newPyOperation(); assert(op != 0); op = newPyConstOperation(); assert(op != 0); run_python_string("from atlas import *"); run_python_string("o=Operation('get')"); // This should fail, but the error throwing has been disabled to // allow cooler stuff to be done from the client. // FIXME Once the client is constrained to real operations, go back // to disallowing arbitrary operation names. // expect_python_error("o=Operation('not_valid')"); run_python_string("o=Operation('not_valid')"); run_python_string("o=Operation('get', to='1', from_='1')"); expect_python_error("o=Operation('get', from_=Message({'nonid': '1'}))", PyExc_TypeError); expect_python_error("o=Operation('get', from_=Message({'id': 1}))", PyExc_TypeError); expect_python_error("o=Operation('get', to=Message({'nonid': '1'}))", PyExc_TypeError); expect_python_error("o=Operation('get', to=Message({'id': 1}))", PyExc_TypeError); run_python_string("e=Entity('1')"); run_python_string("o=Operation('get', to=e, from_=e)"); run_python_string("o=Operation('get', Entity(), to='1', from_='1')"); run_python_string("o=Operation('get', Operation('set'), to='1', from_='1')"); expect_python_error("o=Operation('get', Location(), to='1', from_='1')", PyExc_TypeError); run_python_string("o=Operation('get', Entity(), Entity(), Entity(), to='1', from_='1')"); expect_python_error("Operation('get', Message('1'))", PyExc_TypeError); run_python_string("Operation('get', Message({'objtype': 'obj', 'parents': ['thing']}))"); expect_python_error("o=Operation()", PyExc_TypeError); expect_python_error("o=Operation(1)", PyExc_TypeError); run_python_string("o=Operation('get')"); run_python_string("o.setSerialno(1)"); expect_python_error("o.setSerialno('1')", PyExc_TypeError); run_python_string("o.setRefno(1)"); expect_python_error("o.setRefno('1')", PyExc_TypeError); run_python_string("o.setTo('1')"); expect_python_error("o.setTo(1)", PyExc_TypeError); run_python_string("o.setFrom('2')"); expect_python_error("o.setFrom(2)", PyExc_TypeError); run_python_string("o.setSeconds(2)"); run_python_string("o.setSeconds(2.0)"); expect_python_error("o.setSeconds('2.0')", PyExc_TypeError); run_python_string("o.setFutureSeconds(2)"); run_python_string("o.setFutureSeconds(2.0)"); expect_python_error("o.setFutureSeconds('2.0')", PyExc_TypeError); expect_python_error("o.setArgs()", PyExc_TypeError); run_python_string("o.setArgs([])"); expect_python_error("o.setArgs(1)", PyExc_TypeError); expect_python_error("o.setArgs([1])", PyExc_TypeError); run_python_string("o.setArgs([Operation('get')])"); run_python_string("o.setArgs([Entity(parents=[\"oak\"])])"); run_python_string("o.setArgs([Message({'parents': ['root']})])"); expect_python_error("o.setArgs([Message('1')])", PyExc_TypeError); run_python_string("import types"); run_python_string("assert type(o.getSerialno()) == types.IntType"); run_python_string("assert type(o.getRefno()) == types.IntType"); run_python_string("assert type(o.getTo()) == types.StringType"); run_python_string("assert type(o.getFrom()) == types.StringType"); run_python_string("assert type(o.getSeconds()) == types.FloatType"); run_python_string("assert type(o.getFutureSeconds()) == types.FloatType"); run_python_string("assert type(o.getArgs()) == types.ListType"); run_python_string("assert type(o.get_name()) == types.StringType"); run_python_string("assert len(o) == 1"); run_python_string("o.setArgs([Operation('get'), Entity(parents=[\"oak\"]), Message({'parents': ['root'], 'objtype': 'obj'})])"); run_python_string("assert type(o[0]) == Operation"); run_python_string("assert type(o[1]) == Entity"); run_python_string("assert type(o[2]) == Message"); expect_python_error("o[3]", PyExc_IndexError); run_python_string("assert o + None == o"); expect_python_error("o + 1", PyExc_TypeError); run_python_string("assert type(o + Oplist()) == Oplist"); run_python_string("assert type(o + Operation('get')) == Oplist"); run_python_string("assert type(o.from_) == types.StringType"); run_python_string("assert type(o.to) == types.StringType"); run_python_string("assert type(o.id) == types.StringType"); expect_python_error("o.from_='1'", PyExc_TypeError); expect_python_error("o.from_=1", PyExc_TypeError); expect_python_error("o.from_=Message({'id': 1})", PyExc_TypeError); run_python_string("o.from_=Message({'id': '1'})"); expect_python_error("o.to='1'", PyExc_TypeError); expect_python_error("o.to=1", PyExc_TypeError); expect_python_error("o.to=Message({'id': 1})", PyExc_TypeError); run_python_string("o.to=Message({'id': '1'})"); expect_python_error("o.other=1", PyExc_AttributeError); #ifdef CYPHESIS_DEBUG run_python_string("import sabotage"); // Hit the assert checks. run_python_string("arg1=Message({'objtype': 'obj', 'parents': ['thing']})"); run_python_string("sabotage.null(arg1)"); expect_python_error("Operation('get', arg1)", PyExc_AssertionError); run_python_string("arg1=Entity()"); run_python_string("sabotage.null(arg1)"); expect_python_error("Operation('get', arg1)", PyExc_AssertionError); run_python_string("arg1=Operation('get')"); run_python_string("sabotage.null(arg1)"); expect_python_error("Operation('get', arg1)", PyExc_AssertionError); expect_python_error("Operation('get', Entity(), arg1)", PyExc_AssertionError); expect_python_error("Operation('get', Entity(), Entity(), arg1)", PyExc_AssertionError); run_python_string("o2=Operation('get')"); run_python_string("sabotage.null(o2)"); expect_python_error("o + o2", PyExc_AssertionError); run_python_string("sabotage.clear_parents(o)"); expect_python_error("print o.id", PyExc_AttributeError); run_python_string("ol = Oplist()"); run_python_string("sabotage.null(ol)"); expect_python_error("o + ol", PyExc_AssertionError); run_python_string("method_setSerialno=o.setSerialno"); run_python_string("method_setRefno=o.setRefno"); run_python_string("method_setTo=o.setTo"); run_python_string("method_setFrom=o.setFrom"); run_python_string("method_setSeconds=o.setSeconds"); run_python_string("method_setFutureSeconds=o.setFutureSeconds"); run_python_string("method_setArgs=o.setArgs"); run_python_string("method_getSerialno=o.getSerialno"); run_python_string("method_getRefno=o.getRefno"); run_python_string("method_getTo=o.getTo"); run_python_string("method_getFrom=o.getFrom"); run_python_string("method_getSeconds=o.getSeconds"); run_python_string("method_getFutureSeconds=o.getFutureSeconds"); run_python_string("method_getArgs=o.getArgs"); run_python_string("method_get_name=o.get_name"); run_python_string("sabotage.null(o)"); expect_python_error("print o.to", PyExc_AssertionError); expect_python_error("len(o)", PyExc_AssertionError); expect_python_error("o[0]", PyExc_AssertionError); expect_python_error("o + None", PyExc_AssertionError); expect_python_error("o.to='1'", PyExc_AssertionError); expect_python_error("method_setSerialno(1)", PyExc_AssertionError); expect_python_error("method_setRefno(1)", PyExc_AssertionError); expect_python_error("method_setTo('1')", PyExc_AssertionError); expect_python_error("method_setFrom('2')", PyExc_AssertionError); expect_python_error("method_setSeconds(2.0)", PyExc_AssertionError); expect_python_error("method_setFutureSeconds(2.0)", PyExc_AssertionError); expect_python_error("method_setArgs([])", PyExc_AssertionError); expect_python_error("method_getSerialno()", PyExc_AssertionError); expect_python_error("method_getRefno()", PyExc_AssertionError); expect_python_error("method_getTo()", PyExc_AssertionError); expect_python_error("method_getFrom()", PyExc_AssertionError); expect_python_error("method_getSeconds()", PyExc_AssertionError); expect_python_error("method_getFutureSeconds()", PyExc_AssertionError); expect_python_error("method_getArgs()", PyExc_AssertionError); expect_python_error("method_get_name()", PyExc_AssertionError); #endif // NDEBUG shutdown_python_api(); return 0; }
int main() { init_python_api("93b8eac3-9ab9-40f7-b419-d740c18c09e4"); setup_test_functions(); PyMap * map = newPyMap(); assert(map != 0); run_python_string("from server import Map"); run_python_string("from atlas import Location"); run_python_string("from atlas import Entity"); run_python_string("from atlas import Message"); run_python_string("m=Map()"); expect_python_error("m.find_by_location()", PyExc_TypeError); run_python_string("l=Location()"); expect_python_error("m.find_by_location(l)", PyExc_TypeError); expect_python_error("m.find_by_location(l, 5.0, 'foo')", PyExc_RuntimeError); expect_python_error("m.find_by_location(5, 5.0, 'foo')", PyExc_TypeError); expect_python_error("m.find_by_type()", PyExc_TypeError); expect_python_error("m.find_by_type(1)", PyExc_TypeError); run_python_string("m.find_by_type('foo')"); expect_python_error("m.add()", PyExc_TypeError); expect_python_error("m.add('2')", PyExc_TypeError); expect_python_error("m.add('2', 1.2)", PyExc_TypeError); expect_python_error("m.add(Message())", PyExc_TypeError); expect_python_error("m.add(Message(), 1.2)", PyExc_TypeError); expect_python_error("m.add(Message({'objtype': 'op', 'parents': ['get']}), 1.2)", PyExc_TypeError); expect_python_error("m.add(Message({}), 1.2)", PyExc_TypeError); expect_python_error("m.add(Message({'parents': 'get'}), 1.2)", PyExc_TypeError); run_python_string("m.add(Message({'id': '2'}), 1.2)"); run_python_string("m.add(Message({'id': '2'}), 1.2)"); expect_python_error("m.add(Entity())", PyExc_TypeError); expect_python_error("m.add(Entity('1', type='oak'))", PyExc_TypeError); run_python_string("m.add(Entity('1', type='thing'), 1.1)"); run_python_string("m.find_by_type('thing')"); expect_python_error("m.get()", PyExc_TypeError); expect_python_error("m.get(1)", PyExc_TypeError); run_python_string("m.get('1')"); run_python_string("m.get('23')"); expect_python_error("m.get_add()", PyExc_TypeError); expect_python_error("m.get_add(3)", PyExc_TypeError); run_python_string("m.get_add('3')"); run_python_string("m.update(Entity('3', type='thing'), 1.1)"); expect_python_error("m.update()", PyExc_TypeError); expect_python_error("m.delete()", PyExc_TypeError); expect_python_error("m.delete(1)", PyExc_TypeError); run_python_string("m.delete('1')"); expect_python_error("m.add_hooks_append()", PyExc_TypeError); expect_python_error("m.add_hooks_append(1)", PyExc_TypeError); run_python_string("m.add_hooks_append('add_map')"); expect_python_error("m.update_hooks_append()", PyExc_TypeError); expect_python_error("m.update_hooks_append(1)", PyExc_TypeError); run_python_string("m.update_hooks_append('update_map')"); expect_python_error("m.delete_hooks_append()", PyExc_TypeError); expect_python_error("m.delete_hooks_append(1)", PyExc_TypeError); run_python_string("m.delete_hooks_append('delete_map')"); #ifdef CYPHESIS_DEBUG run_python_string("import sabotage"); run_python_string("sabotage.null(m)"); // Hit the assert checks. expect_python_error("m.find_by_location(l, 5.0, 'foo')", PyExc_AssertionError); expect_python_error("m.find_by_type('foo')", PyExc_AssertionError); expect_python_error("m.add(Entity('1', type='thing'), 1.1)", PyExc_AssertionError); expect_python_error("m.delete('1')", PyExc_AssertionError); expect_python_error("m.get('1')", PyExc_AssertionError); expect_python_error("m.get_add('3')", PyExc_AssertionError); expect_python_error("m.add_hooks_append('add_map')", PyExc_AssertionError); expect_python_error("m.update_hooks_append('update_map')", PyExc_AssertionError); expect_python_error("m.delete_hooks_append('delete_map')", PyExc_AssertionError); #endif // NDEBUG shutdown_python_api(); return 0; }
int main() { init_python_api("df4d61a3-b435-47b7-862d-63bb27681219"); run_python_string("from physics import Point3D"); run_python_string("from atlas import Message"); run_python_string("Point3D([Message(1), Message(0), Message(0)])"); expect_python_error("Point3D([Message('1'), Message(0), Message(0)])", PyExc_TypeError); run_python_string("p=Point3D(1,0,0)"); run_python_string("p1=Point3D(0,1,0)"); run_python_string("p2=Point3D(0,1,0)"); run_python_string("print Point3D()"); expect_python_error("print Point3D('1')", PyExc_TypeError); expect_python_error("print Point3D([1])", PyExc_ValueError); run_python_string("print Point3D([1,0,0])"); run_python_string("print Point3D([1.1,0.0,0.0])"); expect_python_error("print Point3D(['1','1','1'])", PyExc_TypeError); expect_python_error("print Point3D(1.1)", PyExc_TypeError); run_python_string("print Point3D(1.1,0.0,0.0)"); expect_python_error("print Point3D('1','1','1')", PyExc_TypeError); expect_python_error("print Point3D(1.1,0.0,0.0,1.1)", PyExc_TypeError); run_python_string("print repr(p)"); run_python_string("print p.mag()"); run_python_string("print p.unit_vector_to(p1)"); expect_python_error("print p.unit_vector_to(1.0)", PyExc_TypeError); run_python_string("print p.distance(p1)"); expect_python_error("print p.distance(1.0)", PyExc_TypeError); run_python_string("print p.is_valid()"); run_python_string("print p"); run_python_string("print p.x"); run_python_string("print p.y"); run_python_string("print p.z"); run_python_string("print p[0]"); run_python_string("print p[1]"); run_python_string("print p[2]"); run_python_string("print p[-1]"); expect_python_error("print p[3]", PyExc_IndexError); run_python_string("p[0]=1.0"); run_python_string("p[1]=1.0"); run_python_string("p[2]=1.0"); expect_python_error("p[3]=1", PyExc_IndexError); run_python_string("print p == p1"); run_python_string("print p1 == p2"); run_python_string("from physics import Vector3D"); run_python_string("v=Vector3D(1,0,0)"); run_python_string("print p + v"); expect_python_error("print p + p1", PyExc_TypeError); run_python_string("print p - v"); run_python_string("print p - p1"); expect_python_error("print p - 1.0", PyExc_TypeError); run_python_string("print p == v"); shutdown_python_api(); return 0; }
int main() { init_python_api("16799987-a321-43a2-aa66-f7bc8ed8e9b2"); setup_test_functions(); run_python_string("from atlas import Message"); run_python_string("from atlas import Operation"); run_python_string("from atlas import Oplist"); run_python_string("from atlas import Location"); run_python_string("from physics import Vector3D"); run_python_string("Message()"); run_python_string("Message(1)"); run_python_string("Message(1.1)"); run_python_string("Message('1')"); run_python_string("Message([1, 1])"); run_python_string("Message((1, 1))"); run_python_string("Message({'foo': 1})"); run_python_string("Message(Message(1))"); run_python_string("Message(Operation('get'))"); run_python_string("Message(Oplist(Operation('get')))"); run_python_string("Message(Location())"); expect_python_error("Message(Vector3D())", PyExc_TypeError); run_python_string("Message([Message(1)])"); expect_python_error("Message([Vector3D()])", PyExc_TypeError); run_python_string("Message({'foo': Message(1)})"); expect_python_error("Message({'foo': Vector3D()})", PyExc_TypeError); expect_python_error("Message(1, 1)", PyExc_TypeError); run_python_string("m=Message(1)"); run_python_string("print m.get_name()"); expect_python_error("print m.foo", PyExc_AttributeError); expect_python_error("m.foo = 1", PyExc_AttributeError); run_python_string("m=Message({})"); expect_python_error("print m.foo", PyExc_AttributeError); expect_python_error("m.foo = Vector3D()", PyExc_TypeError); run_python_string("m.foo = 1"); run_python_string("print m.foo"); run_python_string("m.foo = 1.1"); run_python_string("print m.foo"); run_python_string("m.foo = '1'"); run_python_string("print m.foo"); run_python_string("m.foo = ['1']"); run_python_string("print m.foo"); run_python_string("m.foo = {'foo': 1}"); run_python_string("print m.foo"); run_python_string("m=Message(1)"); run_python_string("assert m == 1"); run_python_string("assert not m == 1.0"); run_python_string("assert not m == '1'"); run_python_string("assert not m != 1"); run_python_string("assert m != 1.0"); run_python_string("assert m != '1'"); run_python_string("assert m != 2"); run_python_string("m=Message(1.0)"); run_python_string("assert not m == 1"); run_python_string("assert m == 1.0"); run_python_string("assert not m == '1'"); run_python_string("assert m != 1"); run_python_string("assert not m != 1.0"); run_python_string("assert m != '1'"); run_python_string("assert m != 2.0"); run_python_string("m=Message('1')"); run_python_string("assert not m == 1"); run_python_string("assert not m == 1.0"); run_python_string("assert m == '1'"); run_python_string("assert m != 1"); run_python_string("assert m != 1.0"); run_python_string("assert not m != '1'"); run_python_string("assert m != '2'"); run_python_string("m=Message([])"); run_python_string("assert not m == 1"); run_python_string("assert not m == 1.0"); run_python_string("assert not m == '1'"); run_python_string("assert m != 1"); run_python_string("assert m != 1.0"); run_python_string("assert m != '1'"); run_python_string("m=Message({})"); run_python_string("assert not m == 1"); run_python_string("assert not m == 1.0"); run_python_string("assert not m == '1'"); run_python_string("assert m != 1"); run_python_string("assert m != 1.0"); run_python_string("assert m != '1'"); #ifdef CYPHESIS_DEBUG run_python_string("import sabotage"); run_python_string("get_name_method=m.get_name"); run_python_string("sabotage.null(m)"); // Hit the assert checks. expect_python_error("print get_name_method()", PyExc_AssertionError); expect_python_error("print m.foo", PyExc_AssertionError); expect_python_error("m.foo = 1", PyExc_AssertionError); #endif // NDEBUG shutdown_python_api(); return 0; }
int main() { init_python_api("c67ce8e7-d195-4806-b8e4-d905e7c9d928"); setup_test_functions(); PyRootEntity * ent = newPyRootEntity(); assert(ent != 0); run_python_string("from atlas import Entity"); run_python_string("from atlas import Location"); run_python_string("Entity('1')"); expect_python_error("Entity(1)", PyExc_TypeError); expect_python_error("Entity('1', location='loc')", PyExc_TypeError); run_python_string("l=Location()"); run_python_string("Entity('1', location=l)"); run_python_string("Entity('1', pos=())"); run_python_string("Entity('1', pos=[])"); expect_python_error("Entity('1', pos=(1,1.0,'1'))", PyExc_TypeError); expect_python_error("Entity('1', pos=[1,1.0,'1'])", PyExc_TypeError); run_python_string("Entity('1', tasks=[{'name': 'twist', 'param': 'value'}])"); expect_python_error("Entity('1', pos=1)", PyExc_TypeError); expect_python_error("Entity('1', parent=1)", PyExc_TypeError); run_python_string("Entity('1', parent='0')"); expect_python_error("Entity('1', type=1)", PyExc_TypeError); run_python_string("Entity('1', type='pig')"); run_python_string("Entity('1', other=1)"); expect_python_error("Entity('1', other=set([1,1]))", PyExc_TypeError); run_python_string("e=Entity()"); run_python_string("e.get_name()"); run_python_string("e.name"); run_python_string("e.id"); expect_python_error("e.foo", PyExc_AttributeError); run_python_string("e.name='Bob'"); expect_python_error("e.name=1", PyExc_TypeError); run_python_string("e.foo='Bob'"); run_python_string("e.bar=1"); run_python_string("e.baz=[1,2.0,'three']"); run_python_string("e.qux={'mim': 23}"); run_python_string("e.ptr=set([1,2])"); run_python_string("e.foo"); run_python_string("e.ptr"); #ifdef CYPHESIS_DEBUG run_python_string("import sabotage"); // Hit the assert checks. run_python_string("get_name_methd=e.get_name"); run_python_string("sabotage.null(e)"); expect_python_error("get_name_methd()", PyExc_AssertionError); expect_python_error("e.name", PyExc_AssertionError); expect_python_error("e.name='Bob'", PyExc_AssertionError); #endif // NDEBUG shutdown_python_api(); return 0; }
int main() { init_python_api("3f71a0b3-8b4c-4efc-9835-e32928c049c3"); setup_test_functions(); run_python_string("import atlas"); run_python_string("import server"); run_python_string("import physics"); run_python_string("physics.Shape()"); expect_python_error("physics.Shape(object(), object())", PyExc_TypeError); run_python_string("s = physics.Shape({'type': 'polygon'," "'points': [[ 0.0, 0.0 ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]] })"); expect_python_error("physics.Shape({})", PyExc_TypeError); expect_python_error("physics.Shape(object())", PyExc_TypeError); expect_python_error("physics.Shape({'type': 'polygon'," "'data': object()," "'points': [[ 0.0, 0.0 ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]] })", PyExc_TypeError); run_python_string("physics.Shape(atlas.Message({'type': 'polygon'," "'points': [[ 0.0, 0.0 ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]] }))"); expect_python_error("physics.Shape(atlas.Message('foo'))", PyExc_TypeError); expect_python_error("physics.Shape(atlas.Message({'type': 'polygon'," "'points': [[ 0.0, 0.0 ]," "[ 1.0 ]," "[ 1.0, 1.0 ]] }))", PyExc_TypeError); run_python_string("s.area()"); run_python_string("s.footprint()"); run_python_string("s.as_data()"); run_python_string("repr(s)"); run_python_string("assert(len(s) == 3)"); run_python_string("s *= 5.0"); expect_python_error("s *= 5", PyExc_TypeError); // Can't send attributes yet expect_python_error("s.points = [[ 0.0, 0.0 ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]]", PyExc_AttributeError); //////////////////////////////// Box ///////////////////////////////// run_python_string("b = physics.Box()"); expect_python_error("physics.Box([[ 0.0, 0.0 ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]])", PyExc_TypeError); run_python_string("b.area()"); run_python_string("b.centre()"); run_python_string("b.footprint()"); run_python_string("b.low_corner()"); run_python_string("b.high_corner()"); run_python_string("b.extrude(0, 1)"); expect_python_error("b.extrude()", PyExc_TypeError); run_python_string("d = b.as_data()"); run_python_string("repr(b)"); run_python_string("assert(len(b) == 4)"); run_python_string("b[0]"); run_python_string("b[1]"); run_python_string("b[2]"); run_python_string("b[3]"); expect_python_error("b[4]", PyExc_IndexError); run_python_string("b *= 5.0"); /////////////////////////////// Course /////////////////////////////// run_python_string("c = physics.Course()"); run_python_string("c.area()"); run_python_string("c.centre()"); run_python_string("c.footprint()"); run_python_string("c.low_corner()"); run_python_string("c.high_corner()"); run_python_string("c.as_data()"); run_python_string("repr(c)"); run_python_string("assert(len(c) == 0)"); expect_python_error("c[0]", PyExc_IndexError); run_python_string("c *= 5.0"); //////////////////////////////// Line //////////////////////////////// expect_python_error("physics.Line()", PyExc_TypeError); run_python_string("l = physics.Line([[ 0.0, 0.0 ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]])"); run_python_string("l.area()"); run_python_string("l.centre()"); run_python_string("l.footprint()"); run_python_string("l.low_corner()"); run_python_string("l.high_corner()"); run_python_string("d = l.as_data()"); run_python_string("repr(l)"); run_python_string("len(l)"); run_python_string("l *= 5.0"); ////////////////////////////// Polygon /////////////////////////////// expect_python_error("physics.Polygon()", PyExc_TypeError); expect_python_error("physics.Polygon(object())", PyExc_TypeError); expect_python_error("physics.Polygon([[ object(), object() ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]])", PyExc_TypeError); // One vector too short expect_python_error("physics.Polygon([[ 0.0, 0.0 ]," "[ 1.0 ]," "[ 1.0, 1.0 ]])", PyExc_TypeError); // Sequence too short for complete polygon expect_python_error("physics.Polygon([[ 0.0, 0.0 ]," "[ 1.0, 1.0 ]])", PyExc_TypeError); run_python_string("physics.Polygon(atlas.Message([[ 0.0, 0.0 ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]]))"); expect_python_error("physics.Polygon(atlas.Message('foo'))", PyExc_TypeError); run_python_string("p = physics.Polygon([[ 0.0, 0.0 ]," "[ 1.0, 0.0 ]," "[ 1.0, 1.0 ]])"); run_python_string("p.area()"); run_python_string("p.centre()"); run_python_string("p.footprint()"); run_python_string("p.low_corner()"); run_python_string("p.high_corner()"); run_python_string("d = p.as_data()"); run_python_string("repr(p)"); run_python_string("len(p)"); run_python_string("p *= 5.0"); #ifdef CYPHESIS_DEBUG run_python_string("import sabotage"); // Hit the assert checks. run_python_string("s=physics.Shape()"); run_python_string("sabotage.null(s)"); #endif // NDEBUG shutdown_python_api(); return 0; }