summaryrefslogtreecommitdiff
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
parent0b3468000bf1b0e9c260892a151ca164b76d5f22 (diff)
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 @@
1class A(C) {
2 methods {
3 baz {}
4 }
5 events {
6 test2: void;
7 }
8 implements {
9 C.foo;
10 C.bar;
11 }
12}
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 @@
1class B(C) {
2}
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 @@
1class C {
2 methods {
3 foo {}
4 bar {}
5 }
6 events {
7 test: void;
8 }
9}
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 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <Eolian_Aux.h>
6
5#include "eolian_aux_suite.h" 7#include "eolian_aux_suite.h"
6 8
9EFL_START_TEST(eolian_aux_children)
10{
11 Eolian_State *eos = eolian_state_new();
12
13 fail_if(!eolian_state_directory_add(eos, TESTS_SRC_DIR"/data"));
14 fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/a.eo"));
15 fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/b.eo"));
16
17 Eina_Hash *chash = eolian_aux_state_class_children_find(eos);
18 fail_if(!chash);
19
20 const Eolian_Class *acl = eolian_state_class_by_name_get(eos, "A");
21 fail_if(!acl);
22
23 const Eolian_Class *bcl = eolian_state_class_by_name_get(eos, "B");
24 fail_if(!bcl);
25
26 const Eolian_Class *ccl = eolian_state_class_by_name_get(eos, "C");
27 fail_if(!ccl);
28
29 Eina_List *cl = eina_hash_find(chash, &ccl);
30 fail_if(!cl);
31
32 fail_if(eina_list_count(cl) != 2);
33 if (eina_list_nth(cl, 0) == bcl)
34 fail_if(eina_list_nth(cl, 1) != acl);
35 else
36 {
37 fail_if(eina_list_nth(cl, 0) != acl);
38 fail_if(eina_list_nth(cl, 1) != bcl);
39 }
40
41 eina_hash_free(chash);
42 eolian_state_free(eos);
43}
44EFL_END_TEST
45
46EFL_START_TEST(eolian_aux_implements)
47{
48 Eolian_State *eos = eolian_state_new();
49
50 fail_if(!eolian_state_directory_add(eos, TESTS_SRC_DIR"/data"));
51 fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/a.eo"));
52 fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/b.eo"));
53
54 Eina_Hash *chash = eolian_aux_state_class_children_find(eos);
55 fail_if(!chash);
56
57 const Eolian_Class *ccl = eolian_state_class_by_name_get(eos, "C");
58 fail_if(!ccl);
59
60 const Eolian_Function *fn = eolian_class_function_by_name_get(ccl, "foo", EOLIAN_METHOD);
61 fail_if(!fn);
62
63 Eina_List *imps = eolian_aux_function_all_implements_get(fn, chash);
64 fail_if(!imps);
65 fail_if(eina_list_count(imps) != 2);
66
67 eina_list_free(imps);
68 eina_hash_free(chash);
69 eolian_state_free(eos);
70}
71EFL_END_TEST
72
73EFL_START_TEST(eolian_aux_callables)
74{
75 Eolian_State *eos = eolian_state_new();
76
77 fail_if(!eolian_state_directory_add(eos, TESTS_SRC_DIR"/data"));
78 fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/a.eo"));
79
80 const Eolian_Class *acl = eolian_state_class_by_name_get(eos, "A");
81 fail_if(!acl);
82
83 Eina_List *funcs = NULL;
84 Eina_List *evs = NULL;
85 size_t ofuncs = 0;
86 size_t oevs = 0;
87
88 size_t clbls = eolian_aux_class_callables_get(acl, &funcs, &evs, &ofuncs, &oevs);
89 fail_if(clbls != 5);
90 fail_if(ofuncs != 3);
91 fail_if(oevs != 1);
92 fail_if(eina_list_count(funcs) != 3);
93 fail_if(eina_list_count(evs) != 2);
94
95 eina_list_free(funcs);
96 eina_list_free(evs);
97 eolian_state_free(eos);
98}
99EFL_END_TEST
100
101EFL_START_TEST(eolian_aux_implparent)
102{
103 Eolian_State *eos = eolian_state_new();
104
105 fail_if(!eolian_state_directory_add(eos, TESTS_SRC_DIR"/data"));
106 fail_if(!eolian_state_file_parse(eos, TESTS_SRC_DIR"/data/a.eo"));
107
108 const Eolian_Class *acl = eolian_state_class_by_name_get(eos, "A");
109 fail_if(!acl);
110
111 const Eolian_Class *ccl = eolian_state_class_by_name_get(eos, "C");
112 fail_if(!ccl);
113
114 const Eolian_Function *fn = eolian_class_function_by_name_get(ccl, "foo", EOLIAN_METHOD);
115 fail_if(!fn);
116
117 const Eolian_Implement *impl = NULL;
118 Eina_Iterator *itr = eolian_class_implements_get(acl);
119 EINA_ITERATOR_FOREACH(itr, impl)
120 {
121 if (eolian_implement_function_get(impl, NULL) == fn)
122 break;
123 }
124 eina_iterator_free(itr);
125
126 fail_if(!impl);
127 fail_if(eolian_implement_function_get(impl, NULL) != fn);
128
129 fail_if(eolian_implement_class_get(impl) != ccl);
130 fail_if(eolian_implement_implementing_class_get(impl) != acl);
131
132 const Eolian_Implement *pimpl = eolian_aux_implement_parent_get(impl);
133 fail_if(eolian_implement_class_get(pimpl) != ccl);
134 fail_if(eolian_implement_implementing_class_get(pimpl) != ccl);
135
136 eolian_state_free(eos);
137}
138EFL_END_TEST
139
7void eolian_aux_test(TCase *tc) 140void eolian_aux_test(TCase *tc)
8{ 141{
142 tcase_add_test(tc, eolian_aux_children);
143 tcase_add_test(tc, eolian_aux_implements);
144 tcase_add_test(tc, eolian_aux_callables);
145 tcase_add_test(tc, eolian_aux_implparent);
9} 146}
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 = [
6 6
7eolian_aux_suite = executable('eolian_aux_suite', 7eolian_aux_suite = executable('eolian_aux_suite',
8 eolian_aux_test_src, 8 eolian_aux_test_src,
9 dependencies: [eolian, check], 9 dependencies: [eolian, eolian_aux, check],
10 c_args : [ 10 c_args : [
11 '-DTESTS_BUILD_DIR="'+meson.current_build_dir()+'"', 11 '-DTESTS_BUILD_DIR="'+meson.current_build_dir()+'"',
12 '-DTESTS_SRC_DIR="'+meson.current_source_dir()+'"'] 12 '-DTESTS_SRC_DIR="'+meson.current_source_dir()+'"']