summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Eolian.am1
-rw-r--r--src/tests/eolian/data/decl.eo22
-rw-r--r--src/tests/eolian/eolian_parsing.c56
3 files changed, 79 insertions, 0 deletions
diff --git a/src/Makefile_Eolian.am b/src/Makefile_Eolian.am
index 1394b2e863..efe3a22395 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 0000000000..c43bf28988
--- /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 1d24434739..528eda3425 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);
}