From: Daniel Zaoui Date: Thu, 24 Apr 2014 12:43:37 +0000 (+0300) Subject: Eolian/Tests: add test for ctors and dtors. X-Git-Tag: v1.10.0-alpha1~95 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d80fabefe9d4e2de300fa8a1b2f60c223cb369b6;p=platform%2Fupstream%2Fefl.git Eolian/Tests: add test for ctors and dtors. --- diff --git a/src/Makefile_Eolian.am b/src/Makefile_Eolian.am index 89f169e..f9155fe 100644 --- a/src/Makefile_Eolian.am +++ b/src/Makefile_Eolian.am @@ -79,5 +79,8 @@ tests_eolian_eolian_suite_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@ endif EXTRA_DIST += \ +tests/eolian/data/base.eo \ tests/eolian/data/class_simple.eo \ -tests/eolian/data/scope.eo +tests/eolian/data/scope.eo \ +tests/eolian/data/ctor_dtor.eo + diff --git a/src/tests/eolian/data/base.eo b/src/tests/eolian/data/base.eo new file mode 100644 index 0000000..e8132b8 --- /dev/null +++ b/src/tests/eolian/data/base.eo @@ -0,0 +1,8 @@ +class Base { + methods { + constructor { + } + destructor { + } + } +} diff --git a/src/tests/eolian/data/ctor_dtor.eo b/src/tests/eolian/data/ctor_dtor.eo new file mode 100644 index 0000000..b0b1fea --- /dev/null +++ b/src/tests/eolian/data/ctor_dtor.eo @@ -0,0 +1,18 @@ +class Ctor_Dtor (Base) { + constructors { + custom_constructor_1 { + params { + @in int a; + @in char b; + } + } + custom_constructor_2 { + } + } + implements { + class::constructor; + class::destructor; + Base::constructor; + Base::destructor; + } +} diff --git a/src/tests/eolian/eolian_suite.c b/src/tests/eolian/eolian_suite.c index da1a73b..a324199 100644 --- a/src/tests/eolian/eolian_suite.c +++ b/src/tests/eolian/eolian_suite.c @@ -16,6 +16,42 @@ struct _Eolian_Test_Case void (*build)(TCase *tc); }; +START_TEST(eolian_ctor_dtor) +{ + const char *class_name = "Ctor_Dtor"; + const char *base_name = "Base"; + const Eina_List *impls = NULL; + const char *impl_class = NULL, *impl_func = NULL; + + eolian_init(); + /* Parsing */ + fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/base.eo")); + fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/ctor_dtor.eo")); + + /* Class ctor/dtor */ + fail_if(!eolian_class_ctor_enable_get(class_name)); + fail_if(!eolian_class_dtor_enable_get(class_name)); + + /* Base ctor/dtor */ + fail_if(!(impls = eolian_class_implements_list_get(class_name))); + fail_if(eina_list_count(impls) != 2); + fail_if(!eolian_implement_information_get(eina_list_nth(impls, 0), &impl_class, &impl_func, NULL)); + fail_if(strcmp(impl_class, base_name)); + fail_if(strcmp(impl_func, "constructor")); + fail_if(!eolian_implement_information_get(eina_list_nth(impls, 1), &impl_class, &impl_func, NULL)); + fail_if(strcmp(impl_class, base_name)); + fail_if(strcmp(impl_func, "destructor")); + + /* Custom ctors/dtors */ + fail_if(!eolian_class_function_find_by_name(base_name, "constructor", EOLIAN_METHOD)); + fail_if(!eolian_class_function_find_by_name(base_name, "destructor", EOLIAN_METHOD)); + fail_if(!eolian_class_function_find_by_name(class_name, "custom_constructor_1", EOLIAN_CTOR)); + fail_if(!eolian_class_function_find_by_name(class_name, "custom_constructor_2", EOLIAN_CTOR)); + + eolian_shutdown(); +} +END_TEST + START_TEST(eolian_scope) { Eolian_Function fid = NULL; @@ -149,6 +185,7 @@ END_TEST static void eolian_parsing_test(TCase *tc) { tcase_add_test(tc, eolian_simple_parsing); + tcase_add_test(tc, eolian_ctor_dtor); tcase_add_test(tc, eolian_scope); }