diff options
author | Dave Andreoli <dave@gurumeditation.it> | 2018-03-11 15:24:59 +0100 |
---|---|---|
committer | Dave Andreoli <dave@gurumeditation.it> | 2018-03-11 15:24:59 +0100 |
commit | 752a6b107018f692705c184b4952045d2130fd6f (patch) | |
tree | 892405c4f2632c01c34015ed781e07be56faa63d /src/scripts | |
parent | 6f6557e2d0709879d2eb79eff8b84e27606a156d (diff) |
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.py | 4 | ||||
-rwxr-xr-x | src/scripts/pyolian/test_eolian.py | 88 |
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] | |||
98 | lib.eolian_state_object_by_name_get.restype = c_void_p | 98 | lib.eolian_state_object_by_name_get.restype = c_void_p |
99 | 99 | ||
100 | # EAPI Eina_Iterator *eolian_state_objects_by_file_get(const Eolian_State *state, const char *file_name); | 100 | # EAPI Eina_Iterator *eolian_state_objects_by_file_get(const Eolian_State *state, const char *file_name); |
101 | lib.eolian_state_object_by_file_get.argtypes = [c_void_p, c_char_p] | 101 | lib.eolian_state_objects_by_file_get.argtypes = [c_void_p, c_char_p] |
102 | lib.eolian_state_object_by_file_get.restype = c_void_p | 102 | lib.eolian_state_objects_by_file_get.restype = c_void_p |
103 | 103 | ||
104 | # EAPI Eina_Iterator *eolian_state_objects_get(const Eolian_State *state); | 104 | # EAPI Eina_Iterator *eolian_state_objects_get(const Eolian_State *state); |
105 | lib.eolian_state_objects_get.argtypes = [c_void_p] | 105 | 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): | |||
65 | self.assertIsInstance(unit, eolian.Eolian_Unit) | 65 | self.assertIsInstance(unit, eolian.Eolian_Unit) |
66 | self.assertEqual(unit.file, 'efl_ui_win.eo') | 66 | self.assertEqual(unit.file, 'efl_ui_win.eo') |
67 | 67 | ||
68 | def test_object_getters(self): | ||
69 | obj = eolian_db.object_by_name_get('Efl.Ui.Frame') | ||
70 | self.assertIsInstance(obj, eolian.Object) | ||
71 | self.assertFalse(type(obj) == eolian.Object) | ||
72 | self.assertEqual(obj.full_name, 'Efl.Ui.Frame') | ||
73 | |||
74 | count = 0 | ||
75 | for obj in eolian_db.objects: | ||
76 | self.assertIsInstance(obj, eolian.Object) | ||
77 | self.assertFalse(type(obj) == eolian.Object) | ||
78 | count += 1 | ||
79 | self.assertGreater(count, 800) | ||
80 | |||
81 | count = 0 | ||
82 | for obj in eolian_db.objects_by_file_get('efl_loop.eo'): | ||
83 | self.assertIsInstance(obj, eolian.Object) | ||
84 | self.assertFalse(type(obj) == eolian.Object) | ||
85 | count += 1 | ||
86 | self.assertGreater(count, 1) | ||
87 | |||
68 | 88 | ||
69 | class TestEolianUnit(unittest.TestCase): | 89 | class TestEolianUnit(unittest.TestCase): |
70 | def test_file_get(self): | 90 | def test_file_get(self): |
@@ -94,6 +114,22 @@ class TestEolianUnit(unittest.TestCase): | |||
94 | self.assertGreater(len(l), 10) | 114 | self.assertGreater(len(l), 10) |
95 | self.assertTrue(l[0].endswith('.eot')) | 115 | self.assertTrue(l[0].endswith('.eot')) |
96 | 116 | ||
117 | def test_object_listing(self): | ||
118 | unit = eolian_db.unit_by_file_get('efl_ui_win.eo') | ||
119 | self.assertIsNone(unit.object_by_name_get('Efl.Ui.Frame')) | ||
120 | |||
121 | obj = unit.object_by_name_get('Efl.Ui.Win') | ||
122 | self.assertIsInstance(obj, eolian.Object) | ||
123 | self.assertFalse(type(obj) == eolian.Object) | ||
124 | self.assertEqual(obj.full_name, 'Efl.Ui.Win') | ||
125 | |||
126 | count = 0 | ||
127 | for obj in unit.objects: | ||
128 | self.assertIsInstance(obj, eolian.Object) | ||
129 | self.assertFalse(type(obj) == eolian.Object) | ||
130 | count += 1 | ||
131 | self.assertGreater(count, 5) | ||
132 | |||
97 | def test_enum_listing(self): | 133 | def test_enum_listing(self): |
98 | l = list(eolian_db.enums_by_file_get('efl_ui_win.eo')) | 134 | l = list(eolian_db.enums_by_file_get('efl_ui_win.eo')) |
99 | self.assertGreater(len(l), 5) | 135 | self.assertGreater(len(l), 5) |
@@ -155,15 +191,6 @@ class TestEolianUnit(unittest.TestCase): | |||
155 | self.assertGreater(len(l), 10) | 191 | self.assertGreater(len(l), 10) |
156 | self.assertIsInstance(l[0], eolian.Variable) | 192 | self.assertIsInstance(l[0], eolian.Variable) |
157 | 193 | ||
158 | def test_declaration_listing(self): | ||
159 | l = list(eolian_db.declarations_get_by_file('eina_types.eot')) | ||
160 | self.assertGreater(len(l), 10) | ||
161 | self.assertIsInstance(l[0], eolian.Declaration) | ||
162 | |||
163 | l = list(eolian_db.all_declarations) | ||
164 | self.assertGreater(len(l), 100) | ||
165 | self.assertIsInstance(l[0], eolian.Declaration) | ||
166 | |||
167 | def test_class_listing(self): | 194 | def test_class_listing(self): |
168 | all_count = 0 | 195 | all_count = 0 |
169 | for cls in eolian_db.classes: | 196 | for cls in eolian_db.classes: |
@@ -237,6 +264,37 @@ class TestEolianNamespace(unittest.TestCase): | |||
237 | self.assertEqual(td.type, eolian.Eolian_Typedecl_Type.STRUCT) | 264 | self.assertEqual(td.type, eolian.Eolian_Typedecl_Type.STRUCT) |
238 | 265 | ||
239 | 266 | ||
267 | class TestEolianObject(unittest.TestCase): | ||
268 | def test_object_instance(self): | ||
269 | obj = eolian_db.object_by_name_get('Efl.Ui.Frame') | ||
270 | self.assertIsInstance(obj, eolian.Class) | ||
271 | self.assertEqual(obj.full_name, 'Efl.Ui.Frame') | ||
272 | |||
273 | @unittest.expectedFailure # Object.name clash with Class.name | ||
274 | def test_name(self): | ||
275 | obj = eolian_db.object_by_name_get('Efl.Ui.Frame') | ||
276 | self.assertEqual(obj.name, 'Efl.Ui.Frame') | ||
277 | |||
278 | @unittest.expectedFailure # Object.type clash with Class.type | ||
279 | def test_type(self): | ||
280 | obj = eolian_db.object_by_name_get('Efl.Ui.Frame') | ||
281 | self.assertIs(obj.type, eolian.Eolian_Object_Type.CLASS) | ||
282 | |||
283 | def test_file(self): | ||
284 | obj = eolian_db.object_by_name_get('Efl.Ui.Frame') | ||
285 | self.assertEqual(obj.file, 'efl_ui_frame.eo') | ||
286 | |||
287 | def test_line(self): | ||
288 | obj = eolian_db.object_by_name_get('Efl.Ui.Frame') | ||
289 | self.assertIsInstance(obj.line, int) | ||
290 | self.assertGreater(obj.line, 0) | ||
291 | |||
292 | def test_column(self): | ||
293 | obj = eolian_db.object_by_name_get('Efl.Ui.Frame') | ||
294 | self.assertIsInstance(obj.column, int) | ||
295 | self.assertGreater(obj.column, 0) | ||
296 | |||
297 | |||
240 | class TestEolianClass(unittest.TestCase): | 298 | class TestEolianClass(unittest.TestCase): |
241 | def test_class(self): | 299 | def test_class(self): |
242 | cls = eolian_db.class_by_file_get('efl_loop_timer.eo') | 300 | cls = eolian_db.class_by_file_get('efl_loop_timer.eo') |
@@ -553,18 +611,6 @@ class TestEolianType(unittest.TestCase): | |||
553 | self.assertEqual(cls.full_name, 'Efl.Gfx') | 611 | self.assertEqual(cls.full_name, 'Efl.Gfx') |
554 | 612 | ||
555 | 613 | ||
556 | class TestEolianDeclaration(unittest.TestCase): | ||
557 | def test_declaration(self): | ||
558 | d = eolian_db.declaration_get_by_name('Eina.File') | ||
559 | self.assertIsInstance(d, eolian.Declaration) | ||
560 | self.assertEqual(d.name, 'Eina.File') | ||
561 | self.assertEqual(d.type, eolian.Eolian_Declaration_Type.STRUCT) | ||
562 | # self.assertIsNone(d.class_) # TODO find a better test | ||
563 | # self.assertIsNone(d.variable) # TODO find a better test | ||
564 | self.assertIsInstance(d.data_type, eolian.Typedecl) | ||
565 | self.assertEqual(d.data_type.full_name, 'Eina.File') | ||
566 | |||
567 | |||
568 | class TestEolianExpression(unittest.TestCase): | 614 | class TestEolianExpression(unittest.TestCase): |
569 | def test_expression_simple(self): | 615 | def test_expression_simple(self): |
570 | td = eolian_db.enum_by_name_get('Efl.Net.Http.Version') | 616 | td = eolian_db.enum_by_name_get('Efl.Net.Http.Version') |