summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-01-14 12:05:33 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-01-14 12:05:33 +0100
commit0179d34f0fe1ca879906c24d56ad717f23587431 (patch)
tree5fb6eb4c163cbc3e0f6bd2173261890f5f722fe3
parent939237ad7f0fd3a776f128b31047e182bdda2026 (diff)
Pyolian: add tests for recently added funcs
-rw-r--r--src/scripts/pyolian/eolian.py4
-rwxr-xr-xsrc/scripts/pyolian/test_eolian.py63
2 files changed, 56 insertions, 11 deletions
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index cdb269ab80..934437b773 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -1026,7 +1026,7 @@ class Implement(EolianBaseObject):
1026 return not self.is_property 1026 return not self.is_property
1027 1027
1028 1028
1029class Type(EolianBaseObject): # OK (4 TODO Unit*) 1029class Type(EolianBaseObject): # OK (1 TODO Unit*)
1030 def __repr__(self): 1030 def __repr__(self):
1031 # return "<eolian.Type '{0.full_name}', type: {0.type!s}, c_type: '{0.c_type}'>".format(self) 1031 # return "<eolian.Type '{0.full_name}', type: {0.type!s}, c_type: '{0.c_type}'>".format(self)
1032 return "<eolian.Type '{0.full_name}', type={0.type!s}>".format(self) 1032 return "<eolian.Type '{0.full_name}', type={0.type!s}>".format(self)
@@ -1107,7 +1107,7 @@ class Type(EolianBaseObject): # OK (4 TODO Unit*)
1107 return bool(lib.eolian_type_is_ptr(self._obj)) 1107 return bool(lib.eolian_type_is_ptr(self._obj))
1108 1108
1109 1109
1110class Typedecl(EolianBaseObject): # OK (2 TODO Unit*) 1110class Typedecl(EolianBaseObject): # OK (1 TODO Unit*)
1111 def __repr__(self): 1111 def __repr__(self):
1112 return "<eolian.Typedecl '{0.full_name}', type={0.type!s}>".format(self) 1112 return "<eolian.Typedecl '{0.full_name}', type={0.type!s}>".format(self)
1113 1113
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py
index 5e43f727a6..a73fe5ac16 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -65,7 +65,7 @@ class TestEolianUnit(unittest.TestCase):
65 l = list(state.all_eot_file_paths) 65 l = list(state.all_eot_file_paths)
66 self.assertGreater(len(l), 10) 66 self.assertGreater(len(l), 10)
67 self.assertTrue(l[0].endswith('.eot')) 67 self.assertTrue(l[0].endswith('.eot'))
68 68
69 l = list(state.all_eot_files) 69 l = list(state.all_eot_files)
70 self.assertGreater(len(l), 10) 70 self.assertGreater(len(l), 10)
71 self.assertTrue(l[0].endswith('.eot')) 71 self.assertTrue(l[0].endswith('.eot'))
@@ -264,7 +264,7 @@ class TestEolianFunction(unittest.TestCase):
264 self.assertEqual(f.full_c_setter_name_legacy, 'ecore_timer_delay_set') 264 self.assertEqual(f.full_c_setter_name_legacy, 'ecore_timer_delay_set')
265 self.assertIsNone(f.method_return_type) # TODO correct ? 265 self.assertIsNone(f.method_return_type) # TODO correct ?
266 self.assertIsNone(f.setter_return_type) # TODO correct ? 266 self.assertIsNone(f.setter_return_type) # TODO correct ?
267 self.assertIsNone(f.getter_return_type) # TODO correct ? 267 self.assertIsNone(f.getter_return_type) # TODO correct ?
268 self.assertFalse(f.is_legacy_only(eolian.Eolian_Function_Type.PROP_GET)) 268 self.assertFalse(f.is_legacy_only(eolian.Eolian_Function_Type.PROP_GET))
269 self.assertFalse(f.is_class) 269 self.assertFalse(f.is_class)
270 self.assertFalse(f.is_beta) 270 self.assertFalse(f.is_beta)
@@ -445,28 +445,73 @@ class TestEolianTypedecl(unittest.TestCase):
445 def test_typedecl_alias(self): 445 def test_typedecl_alias(self):
446 alias = state.typedecl_alias_get_by_name('Eina.Error') 446 alias = state.typedecl_alias_get_by_name('Eina.Error')
447 self.assertIsInstance(alias, eolian.Typedecl) 447 self.assertIsInstance(alias, eolian.Typedecl)
448 self.assertEqual(alias.type, eolian.Eolian_Typedecl_Type.ALIAS)
448 self.assertEqual(alias.name, 'Error') 449 self.assertEqual(alias.name, 'Error')
450 self.assertEqual(alias.full_name, 'Eina.Error')
451 self.assertIsInstance(alias.aliased_base, eolian.Type)
452 self.assertEqual(alias.aliased_base.name, 'int')
449 453
450 454
451class TestEolianType(unittest.TestCase): 455class TestEolianType(unittest.TestCase):
452 def test_type_regular(self): 456 def test_type_regular_builtin(self):
453 cls = state.class_get_by_name('Efl.Loop.Timer') 457 cls = state.class_get_by_name('Efl.Loop.Timer')
454 func = cls.function_get_by_name('delay') 458 func = cls.function_get_by_name('delay')
455 param = list(func.parameters)[0] 459 param = list(func.parameters)[0]
456 t = param.type 460 t = param.type # type: double
457 self.assertIsInstance(t, eolian.Type) 461 self.assertIsInstance(t, eolian.Type)
458 self.assertEqual(t.name, 'double') 462 self.assertEqual(t.name, 'double')
459 self.assertEqual(t.full_name, 'double') 463 self.assertEqual(t.full_name, 'double')
460 self.assertEqual(t.type, eolian.Eolian_Type_Type.REGULAR) 464 self.assertEqual(t.type, eolian.Eolian_Type_Type.REGULAR)
461 self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.DOUBLE) 465 self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.DOUBLE)
462 self.assertEqual(t.file, 'efl_loop_timer.eo') 466 self.assertEqual(t.file, 'efl_loop_timer.eo') # TODO is this correct ?
463 self.assertIsNone(t.base_type) # TODO find a better test 467 self.assertIsNone(t.base_type) # TODO find a better test
464 self.assertIsNone(t.next_type) # TODO find a better test 468 self.assertIsNone(t.next_type) # TODO find a better test
465 self.assertFalse(t.is_owned) 469 self.assertFalse(t.is_owned)
466 self.assertFalse(t.is_const) 470 self.assertFalse(t.is_const)
467 self.assertFalse(t.is_ptr) 471 self.assertFalse(t.is_ptr)
468 # self.assertEqual(list(t.namespaces), []) # TODO find a better test 472 self.assertEqual(list(t.namespaces), [])
469 self.assertIsNone(t.free_func) # TODO find a better test 473 self.assertIsNone(t.free_func)
474 self.assertIsNone(t.class_)
475 self.assertEqual(t, t.aliased_base) # TODO find a better test
476
477 def test_type_regular(self):
478 cls = state.class_get_by_name('Efl.Gfx')
479 func = cls.function_get_by_name('geometry')
480 param = list(func.setter_values)[0]
481 t = param.type # type: Eina.Rect
482 self.assertIsInstance(t, eolian.Type)
483 self.assertEqual(t.name, 'Rect')
484 self.assertEqual(t.full_name, 'Eina.Rect')
485 self.assertEqual(t.type, eolian.Eolian_Type_Type.REGULAR)
486 self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.INVALID)
487 self.assertEqual(t.file, 'efl_gfx.eo') # TODO is this correct ?
488 self.assertEqual(list(t.namespaces), ['Eina'])
489 self.assertEqual(t.free_func, 'eina_rectangle_free')
490 self.assertIsNone(t.class_)
491 self.assertEqual(t, t.aliased_base)
492
493 td = t.typedecl
494 self.assertIsInstance(td, eolian.Typedecl)
495 self.assertEqual(td.full_name, 'Eina.Rect')
496
497 def test_type_class(self):
498 cls = state.class_get_by_name('Efl.Content')
499 func = cls.function_get_by_name('content')
500 param = list(func.setter_values)[0]
501 t = param.type # type: Efl.Gfx (class interface)
502 self.assertIsInstance(t, eolian.Type)
503 self.assertEqual(t.name, 'Gfx')
504 self.assertEqual(t.full_name, 'Efl.Gfx')
505 self.assertEqual(t.type, eolian.Eolian_Type_Type.CLASS)
506 self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.INVALID)
507 self.assertEqual(t.file, 'efl_content.eo') # TODO is this correct ?
508 self.assertEqual(list(t.namespaces), ['Efl'])
509 self.assertEqual(t.free_func, 'efl_del')
510 self.assertEqual(t, t.aliased_base)
511
512 cls = t.class_
513 self.assertIsInstance(cls, eolian.Class)
514 self.assertEqual(cls.full_name, 'Efl.Gfx')
470 515
471 516
472class TestEolianDeclaration(unittest.TestCase): 517class TestEolianDeclaration(unittest.TestCase):
@@ -501,7 +546,7 @@ class TestEolianExpression(unittest.TestCase):
501 self.assertIsInstance(unary, eolian.Expression) 546 self.assertIsInstance(unary, eolian.Expression)
502 self.assertEqual(unary.type, eolian.Eolian_Expression_Type.DOUBLE) 547 self.assertEqual(unary.type, eolian.Eolian_Expression_Type.DOUBLE)
503 self.assertEqual(float(exp.serialize), 1.0) 548 self.assertEqual(float(exp.serialize), 1.0)
504 549
505 # TODO test_expression_binary 550 # TODO test_expression_binary
506 # exp.binary_operator # TODO find a better test (only works for BINARY expr) 551 # exp.binary_operator # TODO find a better test (only works for BINARY expr)
507 # exp.binary_lhs # TODO find a better test (only works for BINARY expr) 552 # exp.binary_lhs # TODO find a better test (only works for BINARY expr)
@@ -526,7 +571,7 @@ if __name__ == '__main__':
526 # Parse all known eo files 571 # Parse all known eo files
527 if not state.all_eot_files_parse(): 572 if not state.all_eot_files_parse():
528 raise(RuntimeError('Eolian, failed to parse all EOT files')) 573 raise(RuntimeError('Eolian, failed to parse all EOT files'))
529 574
530 if not state.all_eo_files_parse(): 575 if not state.all_eo_files_parse():
531 raise(RuntimeError('Eolian, failed to parse all EO files')) 576 raise(RuntimeError('Eolian, failed to parse all EO files'))
532 577