aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2018-11-07 17:50:22 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2018-11-07 17:52:25 +0100
commit67e99418d6a966c0615e616ac6b4ff76ade4d23b (patch)
treea5c4a2cc8699846352514b05db90fc5d6e4732de
parenteolian aux: add documentation (diff)
downloadefl-devs/q66/eolian_aux.tar.gz
eolian_aux: add testsdevs/q66/eolian_aux
-rw-r--r--src/tests/eolian_aux/data/a.eo12
-rw-r--r--src/tests/eolian_aux/data/b.eo2
-rw-r--r--src/tests/eolian_aux/data/c.eo9
-rw-r--r--src/tests/eolian_aux/eolian_aux.c137
-rw-r--r--src/tests/eolian_aux/meson.build2
5 files changed, 161 insertions, 1 deletions
diff --git a/src/tests/eolian_aux/data/a.eo b/src/tests/eolian_aux/data/a.eo
new file mode 100644
index 0000000000..f610fcb998
--- /dev/null
+++ b/src/tests/eolian_aux/data/a.eo
@@ -0,0 +1,12 @@
+class A(C) {
+ methods {
+ baz {}
+ }
+ events {
+ test2: void;
+ }
+ implements {
+ C.foo;
+ C.bar;
+ }
+}
diff --git a/src/tests/eolian_aux/data/b.eo b/src/tests/eolian_aux/data/b.eo
new file mode 100644
index 0000000000..3b00c23308
--- /dev/null
+++ b/src/tests/eolian_aux/data/b.eo
@@ -0,0 +1,2 @@
+class B(C) {
+}
diff --git a/src/tests/eolian_aux/data/c.eo b/src/tests/eolian_aux/data/c.eo
new file mode 100644
index 0000000000..999c5cda38
--- /dev/null
+++ b/src/tests/eolian_aux/data/c.eo
@@ -0,0 +1,9 @@
+class C {
+ methods {
+ foo {}
+ bar {}
+ }
+ events {
+ test: void;
+ }
+}
diff --git a/src/tests/eolian_aux/eolian_aux.c b/src/tests/eolian_aux/eolian_aux.c
index 32140f369d..1a5460d4b4 100644
--- a/src/tests/eolian_aux/eolian_aux.c
+++ b/src/tests/eolian_aux/eolian_aux.c
@@ -2,8 +2,145 @@
# include <config.h>
#endif
+#include <Eolian_Aux.h>
+
#include "eolian_aux_suite.h"
+EFL_START_TEST(eolian_aux_children)
+{
+ Eolian_State *eos = eolian_state_new();
+
+ fail_if(!eolian_state_directory_add(eos, TESTS_SRC_DIR"/data"));
+ fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/a.eo"));
+ fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/b.eo"));
+
+ Eina_Hash *chash = eolian_aux_state_class_children_find(eos);
+ fail_if(!chash);
+
+ const Eolian_Class *acl = eolian_state_class_by_name_get(eos, "A");
+ fail_if(!acl);
+
+ const Eolian_Class *bcl = eolian_state_class_by_name_get(eos, "B");
+ fail_if(!bcl);
+
+ const Eolian_Class *ccl = eolian_state_class_by_name_get(eos, "C");
+ fail_if(!ccl);
+
+ Eina_List *cl = eina_hash_find(chash, &ccl);
+ fail_if(!cl);
+
+ fail_if(eina_list_count(cl) != 2);
+ if (eina_list_nth(cl, 0) == bcl)
+ fail_if(eina_list_nth(cl, 1) != acl);
+ else
+ {
+ fail_if(eina_list_nth(cl, 0) != acl);
+ fail_if(eina_list_nth(cl, 1) != bcl);
+ }
+
+ eina_hash_free(chash);
+ eolian_state_free(eos);
+}
+EFL_END_TEST
+
+EFL_START_TEST(eolian_aux_implements)
+{
+ Eolian_State *eos = eolian_state_new();
+
+ fail_if(!eolian_state_directory_add(eos, TESTS_SRC_DIR"/data"));
+ fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/a.eo"));
+ fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/b.eo"));
+
+ Eina_Hash *chash = eolian_aux_state_class_children_find(eos);
+ fail_if(!chash);
+
+ const Eolian_Class *ccl = eolian_state_class_by_name_get(eos, "C");
+ fail_if(!ccl);
+
+ const Eolian_Function *fn = eolian_class_function_by_name_get(ccl, "foo", EOLIAN_METHOD);
+ fail_if(!fn);
+
+ Eina_List *imps = eolian_aux_function_all_implements_get(fn, chash);
+ fail_if(!imps);
+ fail_if(eina_list_count(imps) != 2);
+
+ eina_list_free(imps);
+ eina_hash_free(chash);
+ eolian_state_free(eos);
+}
+EFL_END_TEST
+
+EFL_START_TEST(eolian_aux_callables)
+{
+ Eolian_State *eos = eolian_state_new();
+
+ fail_if(!eolian_state_directory_add(eos, TESTS_SRC_DIR"/data"));
+ fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/a.eo"));
+
+ const Eolian_Class *acl = eolian_state_class_by_name_get(eos, "A");
+ fail_if(!acl);
+
+ Eina_List *funcs = NULL;
+ Eina_List *evs = NULL;
+ size_t ofuncs = 0;
+ size_t oevs = 0;
+
+ size_t clbls = eolian_aux_class_callables_get(acl, &funcs, &evs, &ofuncs, &oevs);
+ fail_if(clbls != 5);
+ fail_if(ofuncs != 3);
+ fail_if(oevs != 1);
+ fail_if(eina_list_count(funcs) != 3);
+ fail_if(eina_list_count(evs) != 2);
+
+ eina_list_free(funcs);
+ eina_list_free(evs);
+ eolian_state_free(eos);
+}
+EFL_END_TEST
+
+EFL_START_TEST(eolian_aux_implparent)
+{
+ Eolian_State *eos = eolian_state_new();
+
+ fail_if(!eolian_state_directory_add(eos, TESTS_SRC_DIR"/data"));
+ fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/a.eo"));
+
+ const Eolian_Class *acl = eolian_state_class_by_name_get(eos, "A");
+ fail_if(!acl);
+
+ const Eolian_Class *ccl = eolian_state_class_by_name_get(eos, "C");
+ fail_if(!ccl);
+
+ const Eolian_Function *fn = eolian_class_function_by_name_get(ccl, "foo", EOLIAN_METHOD);
+ fail_if(!fn);
+
+ const Eolian_Implement *impl = NULL;
+ Eina_Iterator *itr = eolian_class_implements_get(acl);
+ EINA_ITERATOR_FOREACH(itr, impl)
+ {
+ if (eolian_implement_function_get(impl, NULL) == fn)
+ break;
+ }
+ eina_iterator_free(itr);
+
+ fail_if(!impl);
+ fail_if(eolian_implement_function_get(impl, NULL) != fn);
+
+ fail_if(eolian_implement_class_get(impl) != ccl);
+ fail_if(eolian_implement_implementing_class_get(impl) != acl);
+
+ const Eolian_Implement *pimpl = eolian_aux_implement_parent_get(impl);
+ fail_if(eolian_implement_class_get(pimpl) != ccl);
+ fail_if(eolian_implement_implementing_class_get(pimpl) != ccl);
+
+ eolian_state_free(eos);
+}
+EFL_END_TEST
+
void eolian_aux_test(TCase *tc)
{
+ tcase_add_test(tc, eolian_aux_children);
+ tcase_add_test(tc, eolian_aux_implements);
+ tcase_add_test(tc, eolian_aux_callables);
+ tcase_add_test(tc, eolian_aux_implparent);
}
diff --git a/src/tests/eolian_aux/meson.build b/src/tests/eolian_aux/meson.build
index 67f5c3d05d..e8ad59b03a 100644
--- a/src/tests/eolian_aux/meson.build
+++ b/src/tests/eolian_aux/meson.build
@@ -6,7 +6,7 @@ eolian_aux_test_src = [
eolian_aux_suite = executable('eolian_aux_suite',
eolian_aux_test_src,
- dependencies: [eolian, check],
+ dependencies: [eolian, eolian_aux, check],
c_args : [
'-DTESTS_BUILD_DIR="'+meson.current_build_dir()+'"',
'-DTESTS_SRC_DIR="'+meson.current_source_dir()+'"']