summaryrefslogtreecommitdiff
path: root/src/scripts
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-03-11 15:24:59 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-03-11 15:24:59 +0100
commit752a6b107018f692705c184b4952045d2130fd6f (patch)
tree892405c4f2632c01c34015ed781e07be56faa63d /src/scripts
parent6f6557e2d0709879d2eb79eff8b84e27606a156d (diff)
downloadefl-752a6b107018f692705c184b4952045d2130fd6f.tar.gz
Pyolian: add tests for Eolian_Object
Two of the new tests are failing, the problem is that now we have name clashes between Eolian_Object and Eolian_Class (at least) For the moment I spotted: - Object.name clash with Class.name - Object.type clash with Class.type Also fixed a typo in eolian_lib.py spotted by the new tests, and removed the old tests for Declaration.
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/pyolian/eolian_lib.py4
-rwxr-xr-xsrc/scripts/pyolian/test_eolian.py88
2 files changed, 69 insertions, 23 deletions
diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py
index bf333b675d..277f60afa1 100644
--- a/src/scripts/pyolian/eolian_lib.py
+++ b/src/scripts/pyolian/eolian_lib.py
@@ -98,8 +98,8 @@ lib.eolian_state_object_by_name_get.argtypes = [c_void_p, c_char_p]
lib.eolian_state_object_by_name_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_state_objects_by_file_get(const Eolian_State *state, const char *file_name);
-lib.eolian_state_object_by_file_get.argtypes = [c_void_p, c_char_p]
-lib.eolian_state_object_by_file_get.restype = c_void_p
+lib.eolian_state_objects_by_file_get.argtypes = [c_void_p, c_char_p]
+lib.eolian_state_objects_by_file_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_state_objects_get(const Eolian_State *state);
lib.eolian_state_objects_get.argtypes = [c_void_p]
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py
index 606e2624fc..41f3bf7398 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -65,6 +65,26 @@ class TestEolianState(unittest.TestCase):
self.assertIsInstance(unit, eolian.Eolian_Unit)
self.assertEqual(unit.file, 'efl_ui_win.eo')
+ def test_object_getters(self):
+ obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
+ self.assertIsInstance(obj, eolian.Object)
+ self.assertFalse(type(obj) == eolian.Object)
+ self.assertEqual(obj.full_name, 'Efl.Ui.Frame')
+
+ count = 0
+ for obj in eolian_db.objects:
+ self.assertIsInstance(obj, eolian.Object)
+ self.assertFalse(type(obj) == eolian.Object)
+ count += 1
+ self.assertGreater(count, 800)
+
+ count = 0
+ for obj in eolian_db.objects_by_file_get('efl_loop.eo'):
+ self.assertIsInstance(obj, eolian.Object)
+ self.assertFalse(type(obj) == eolian.Object)
+ count += 1
+ self.assertGreater(count, 1)
+
class TestEolianUnit(unittest.TestCase):
def test_file_get(self):
@@ -94,6 +114,22 @@ class TestEolianUnit(unittest.TestCase):
self.assertGreater(len(l), 10)
self.assertTrue(l[0].endswith('.eot'))
+ def test_object_listing(self):
+ unit = eolian_db.unit_by_file_get('efl_ui_win.eo')
+ self.assertIsNone(unit.object_by_name_get('Efl.Ui.Frame'))
+
+ obj = unit.object_by_name_get('Efl.Ui.Win')
+ self.assertIsInstance(obj, eolian.Object)
+ self.assertFalse(type(obj) == eolian.Object)
+ self.assertEqual(obj.full_name, 'Efl.Ui.Win')
+
+ count = 0
+ for obj in unit.objects:
+ self.assertIsInstance(obj, eolian.Object)
+ self.assertFalse(type(obj) == eolian.Object)
+ count += 1
+ self.assertGreater(count, 5)
+
def test_enum_listing(self):
l = list(eolian_db.enums_by_file_get('efl_ui_win.eo'))
self.assertGreater(len(l), 5)
@@ -155,15 +191,6 @@ class TestEolianUnit(unittest.TestCase):
self.assertGreater(len(l), 10)
self.assertIsInstance(l[0], eolian.Variable)
- def test_declaration_listing(self):
- l = list(eolian_db.declarations_get_by_file('eina_types.eot'))
- self.assertGreater(len(l), 10)
- self.assertIsInstance(l[0], eolian.Declaration)
-
- l = list(eolian_db.all_declarations)
- self.assertGreater(len(l), 100)
- self.assertIsInstance(l[0], eolian.Declaration)
-
def test_class_listing(self):
all_count = 0
for cls in eolian_db.classes:
@@ -237,6 +264,37 @@ class TestEolianNamespace(unittest.TestCase):
self.assertEqual(td.type, eolian.Eolian_Typedecl_Type.STRUCT)
+class TestEolianObject(unittest.TestCase):
+ def test_object_instance(self):
+ obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
+ self.assertIsInstance(obj, eolian.Class)
+ self.assertEqual(obj.full_name, 'Efl.Ui.Frame')
+
+ @unittest.expectedFailure # Object.name clash with Class.name
+ def test_name(self):
+ obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
+ self.assertEqual(obj.name, 'Efl.Ui.Frame')
+
+ @unittest.expectedFailure # Object.type clash with Class.type
+ def test_type(self):
+ obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
+ self.assertIs(obj.type, eolian.Eolian_Object_Type.CLASS)
+
+ def test_file(self):
+ obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
+ self.assertEqual(obj.file, 'efl_ui_frame.eo')
+
+ def test_line(self):
+ obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
+ self.assertIsInstance(obj.line, int)
+ self.assertGreater(obj.line, 0)
+
+ def test_column(self):
+ obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
+ self.assertIsInstance(obj.column, int)
+ self.assertGreater(obj.column, 0)
+
+
class TestEolianClass(unittest.TestCase):
def test_class(self):
cls = eolian_db.class_by_file_get('efl_loop_timer.eo')
@@ -553,18 +611,6 @@ class TestEolianType(unittest.TestCase):
self.assertEqual(cls.full_name, 'Efl.Gfx')
-class TestEolianDeclaration(unittest.TestCase):
- def test_declaration(self):
- d = eolian_db.declaration_get_by_name('Eina.File')
- self.assertIsInstance(d, eolian.Declaration)
- self.assertEqual(d.name, 'Eina.File')
- self.assertEqual(d.type, eolian.Eolian_Declaration_Type.STRUCT)
- # self.assertIsNone(d.class_) # TODO find a better test
- # self.assertIsNone(d.variable) # TODO find a better test
- self.assertIsInstance(d.data_type, eolian.Typedecl)
- self.assertEqual(d.data_type.full_name, 'Eina.File')
-
-
class TestEolianExpression(unittest.TestCase):
def test_expression_simple(self):
td = eolian_db.enum_by_name_get('Efl.Net.Http.Version')