q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=944e44b17d1f0dd1dfbdc68ac077d293d3dc1ef2

commit 944e44b17d1f0dd1dfbdc68ac077d293d3dc1ef2
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Mon Jun 1 15:24:00 2015 +0100

    eolian: tests for declaration api
---
 src/Makefile_Eolian.am            |  1 +
 src/tests/eolian/data/decl.eo     | 22 +++++++++++++++
 src/tests/eolian/eolian_parsing.c | 56 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)

diff --git a/src/Makefile_Eolian.am b/src/Makefile_Eolian.am
index 1394b2e..efe3a22 100644
--- a/src/Makefile_Eolian.am
+++ b/src/Makefile_Eolian.am
@@ -95,6 +95,7 @@ tests/eolian/data/nmsp2_class1.eo \
 tests/eolian/data/null.eo \
 tests/eolian/data/no_nmsp.eo \
 tests/eolian/data/import.eo \
+tests/eolian/data/decl.eo \
 tests/eolian/data/import_types.eot
 
 EOLIAN_TESTS_EOS_GENERATED = \
diff --git a/src/tests/eolian/data/decl.eo b/src/tests/eolian/data/decl.eo
new file mode 100644
index 0000000..c43bf28
--- /dev/null
+++ b/src/tests/eolian/data/decl.eo
@@ -0,0 +1,22 @@
+struct A {
+    foo: int;
+}
+
+enum B {
+    x
+}
+
+type C: A;
+
+var pants: B.x;
+
+class Decl {
+   methods {
+      foo {
+         params {
+            idx: int;
+         }
+         return: own(char*);
+      }
+   }
+}
diff --git a/src/tests/eolian/eolian_parsing.c 
b/src/tests/eolian/eolian_parsing.c
index 1d24434..528eda3 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -1073,6 +1073,61 @@ START_TEST(eolian_import)
 }
 END_TEST
 
+START_TEST(eolian_decl)
+{
+   const Eolian_Declaration *decl;
+   const Eolian_Type *type;
+   const Eolian_Class *class;
+   const Eolian_Variable *var;
+   Eina_Iterator *itr;
+
+   eolian_init();
+
+   fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
+
+   fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/decl.eo"));
+   fail_if(!(class = eolian_class_get_by_name("Decl")));
+
+   fail_if(!(itr = eolian_declarations_get_by_file("decl.eo")));
+
+   fail_if(!eina_iterator_next(itr, (void**)&decl));
+   fail_if(eolian_declaration_type_get(decl) == EOLIAN_DECL_UNKNOWN);
+   fail_if(strcmp(eolian_declaration_name_get(decl), "A"));
+   fail_if(!(type = eolian_declaration_data_type_get(decl)));
+   fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT);
+   fail_if(strcmp(eolian_type_name_get(type), "A"));
+
+   fail_if(!eina_iterator_next(itr, (void**)&decl));
+   fail_if(eolian_declaration_type_get(decl) == EOLIAN_DECL_UNKNOWN);
+   fail_if(strcmp(eolian_declaration_name_get(decl), "B"));
+   fail_if(!(type = eolian_declaration_data_type_get(decl)));
+   fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_ENUM);
+   fail_if(strcmp(eolian_type_name_get(type), "B"));
+
+   fail_if(!eina_iterator_next(itr, (void**)&decl));
+   fail_if(eolian_declaration_type_get(decl) == EOLIAN_DECL_UNKNOWN);
+   fail_if(strcmp(eolian_declaration_name_get(decl), "C"));
+   fail_if(!(type = eolian_declaration_data_type_get(decl)));
+   fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_ALIAS);
+   fail_if(strcmp(eolian_type_name_get(type), "C"));
+
+   fail_if(!eina_iterator_next(itr, (void**)&decl));
+   fail_if(eolian_declaration_type_get(decl) == EOLIAN_DECL_UNKNOWN);
+   fail_if(strcmp(eolian_declaration_name_get(decl), "pants"));
+   fail_if(!(var = eolian_declaration_variable_get(decl)));
+   fail_if(strcmp(eolian_variable_name_get(var), "pants"));
+
+   fail_if(!eina_iterator_next(itr, (void**)&decl));
+   fail_if(eolian_declaration_type_get(decl) == EOLIAN_DECL_UNKNOWN);
+   fail_if(strcmp(eolian_declaration_name_get(decl), "Decl"));
+   fail_if(eolian_declaration_class_get(decl) != class);
+
+   fail_if(eina_iterator_next(itr, (void**)&decl));
+
+   eolian_shutdown();
+}
+END_TEST
+
 void eolian_parsing_test(TCase *tc)
 {
    tcase_add_test(tc, eolian_simple_parsing);
@@ -1092,5 +1147,6 @@ void eolian_parsing_test(TCase *tc)
    tcase_add_test(tc, eolian_free_func);
    tcase_add_test(tc, eolian_null);
    tcase_add_test(tc, eolian_import);
+   tcase_add_test(tc, eolian_decl);
 }
 

-- 


Reply via email to