diff options
author | Tom Hacohen <tom@stosb.com> | 2013-11-08 10:25:38 +0000 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2013-11-08 10:25:45 +0000 |
commit | 4127c44ff39486254c62551498fb0a7145a22433 (patch) | |
tree | 7a85c9e50b9c93f569caec32ad6b141a390a1149 | |
parent | ed25e25a7b7cf4b285ca99fe83cc62227046e839 (diff) | |
download | efl-4127c44ff39486254c62551498fb0a7145a22433.tar.gz |
Eo2: Cleaned up the function overrides test.
6 files changed, 69 insertions, 75 deletions
diff --git a/eo2test/TODO b/eo2test/TODO index 3108ff2123..d82e2871a7 100644 --- a/eo2test/TODO +++ b/eo2test/TODO @@ -33,3 +33,7 @@ - Changing eo2_event_freeze_get and calling it wtrong in signals_main.c does *not* generate a warning~!!!!! -- FIX ALL THE TESTS! + +- A bit annoying that we don't get type checks on the callbacks, fix that? That's really dangerous! + +- Have a way to say a class has no ops. diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c index e0920313cd..f228528719 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c @@ -18,47 +18,46 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, int a) eo2_do(obj, simple_a_print()); eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1)); - Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); - pd->a_print_called = EINA_FALSE; - eo2_do_super(obj, MY_CLASS, simple_a_print()); - fail_if(!pd->a_print_called); + Eina_Bool called; + eo2_do_super(obj, MY_CLASS, called = simple_a_print()); + fail_if(!called); } -Eina_Bool inherit2_print_called = EINA_FALSE; -Eina_Bool inherit2_print2_called = EINA_FALSE; - -static void +static Eina_Bool _print(Eo *obj, void *class_data EINA_UNUSED) { + Eina_Bool called; printf("Hey\n"); - inherit2_print_called = EINA_FALSE; - eo2_do_super(obj, MY_CLASS, inherit2_print()); - // FIXME fail_if(inherit2_print_called); - inherit2_print_called = EINA_TRUE; + eo2_do_super(obj, MY_CLASS, called = inherit2_print()); + fail_if(called); + + return EINA_TRUE; } -static void +static Eina_Bool _print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) { printf("Hey2\n"); - inherit2_print2_called = EINA_TRUE; + + return EINA_TRUE; } -static void +static Eina_Bool _class_print(Eo_Class *klass, void *data EINA_UNUSED) { + Eina_Bool called; printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - class_print_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print()); - fail_if(!class_print_called); + eo2_do_super(klass, MY_CLASS, called = simple_class_print()); + fail_if(!called); + + eo2_do_super(klass, MY_CLASS, called = simple_class_print2()); + fail_if(!called); - class_print2_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print2()); - fail_if(!class_print2_called); + return EINA_TRUE; } -EAPI EO2_VOID_FUNC_BODY(inherit2_print); -EAPI EO2_VOID_FUNC_BODY(inherit2_print2); +EAPI EO2_FUNC_BODY(inherit2_print, Eina_Bool, EINA_FALSE); +EAPI EO2_FUNC_BODY(inherit2_print2, Eina_Bool, EINA_FALSE); static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC(_print, inherit2_print, "Print hey"), diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.h b/src/tests/eo/function_overrides/function_overrides_inherit2.h index c891bd966d..48be203664 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.h +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.h @@ -1,13 +1,10 @@ #ifndef INHERIT2_H #define INHERIT2_H -EAPI void inherit2_print(void); -EAPI void inherit2_print2(void); +EAPI Eina_Bool inherit2_print(void); +EAPI Eina_Bool inherit2_print2(void); #define INHERIT2_CLASS inherit2_class_get() const Eo_Class *inherit2_class_get(void); -extern Eina_Bool inherit2_print_called; -extern Eina_Bool inherit2_print2_called; - #endif diff --git a/src/tests/eo/function_overrides/function_overrides_main.c b/src/tests/eo/function_overrides/function_overrides_main.c index 1caf9025ff..11f4c8f999 100644 --- a/src/tests/eo/function_overrides/function_overrides_main.c +++ b/src/tests/eo/function_overrides/function_overrides_main.c @@ -17,6 +17,7 @@ main(int argc, char *argv[]) (void) argv; eo_init(); + Eina_Bool called; Eo *obj = eo2_add(INHERIT2_CLASS, NULL); eo2_do(obj, simple_a_set(1)); @@ -34,40 +35,36 @@ main(int argc, char *argv[]) eo_unref(obj); obj = eo2_add(INHERIT2_CLASS, NULL); - inherit2_print_called = EINA_FALSE; - eo2_do(obj, inherit2_print()); - eo2_do(obj, inherit2_print(), inherit2_print()); - fail_if(!inherit2_print_called); + eo2_do(obj, called = inherit2_print()); + fail_if(!called); + eo2_do(obj, called = inherit2_print(), called = inherit2_print()); + fail_if(!called); eo_unref(obj); obj = eo2_add(SIMPLE_CLASS, NULL); - inherit2_print_called = EINA_FALSE; - eo2_do(obj, inherit2_print()); - fail_if(inherit2_print_called); + eo2_do(obj, called = inherit2_print()); + fail_if(called); #ifdef EO_DEBUG - class_print_called = EINA_FALSE; - eo2_do(obj, simple_class_print()); - fail_if(class_print_called); + eo2_do(obj, called = simple_class_print()); + fail_if(called); #endif - class_print_called = EINA_FALSE; - eo2_do(SIMPLE_CLASS, simple_class_print()); - fail_if(!class_print_called); - class_print_called = EINA_FALSE; - eo2_do(INHERIT_CLASS, simple_class_print()); - fail_if(!class_print_called); - class_print_called = EINA_FALSE; - eo2_do(INHERIT2_CLASS, simple_class_print()); - fail_if(!class_print_called); - class_print_called = EINA_FALSE; - eo2_do(INHERIT3_CLASS, simple_class_print()); - fail_if(!class_print_called); + eo2_do(SIMPLE_CLASS, called = simple_class_print()); + fail_if(!called); + + eo2_do(INHERIT_CLASS, called = simple_class_print()); + fail_if(!called); + + eo2_do(INHERIT2_CLASS, called = simple_class_print()); + fail_if(!called); + + eo2_do(INHERIT3_CLASS, called = simple_class_print()); + fail_if(!called); #ifdef EO_DEBUG - pd->a_print_called = EINA_FALSE; - eo2_do(SIMPLE_CLASS, simple_a_print()); - fail_if(pd->a_print_called); + eo2_do(SIMPLE_CLASS, called = simple_a_print()); + fail_if(called); #endif eo2_do_super(obj, SIMPLE_CLASS, eo2_constructor()); diff --git a/src/tests/eo/function_overrides/function_overrides_simple.c b/src/tests/eo/function_overrides/function_overrides_simple.c index 0819544491..3de5938aad 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.c +++ b/src/tests/eo/function_overrides/function_overrides_simple.c @@ -20,40 +20,41 @@ _a_set(Eo *obj EINA_UNUSED, void *class_data, int a) pd->a = a; } -static void +static Eina_Bool _a_print(Eo *obj EINA_UNUSED, void *class_data) { Simple_Public_Data *pd = class_data; printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a); - pd->a_print_called = EINA_TRUE; + + return EINA_TRUE; } -static void +static Eina_Bool _class_print(Eo_Class *klass, void *class_data EINA_UNUSED) { printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - class_print_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print()); - fail_if(class_print_called); + Eina_Bool called = EINA_FALSE; + eo2_do_super(klass, MY_CLASS, called = simple_class_print()); + fail_if(called); - class_print2_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print2()); - fail_if(class_print2_called); + eo2_do_super(klass, MY_CLASS, called = simple_class_print2()); + fail_if(called); - class_print_called = EINA_TRUE; + return EINA_TRUE; } -static void +static Eina_Bool _class_print2(Eo_Class *klass, void *class_data EINA_UNUSED) { printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - class_print2_called = EINA_TRUE; + + return EINA_TRUE; } EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); -EAPI EO2_VOID_FUNC_BODY(simple_a_print); -EAPI EO2_VOID_FUNC_BODY(simple_class_print); -EAPI EO2_VOID_FUNC_BODY(simple_class_print2); +EAPI EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); +EAPI EO2_FUNC_BODY(simple_class_print, Eina_Bool, EINA_FALSE); +EAPI EO2_FUNC_BODY(simple_class_print2, Eina_Bool, EINA_FALSE); static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), diff --git a/src/tests/eo/function_overrides/function_overrides_simple.h b/src/tests/eo/function_overrides/function_overrides_simple.h index 29ab6512b4..e4739685b2 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.h +++ b/src/tests/eo/function_overrides/function_overrides_simple.h @@ -4,13 +4,12 @@ typedef struct { int a; - Eina_Bool a_print_called; } Simple_Public_Data; EAPI void simple_a_set(int a); -EAPI void simple_a_print(void); -EAPI void simple_class_print(void); -EAPI void simple_class_print2(void); +EAPI Eina_Bool simple_a_print(void); +EAPI Eina_Bool simple_class_print(void); +EAPI Eina_Bool simple_class_print2(void); extern const Eo_Event_Description _SIG_A_CHANGED; #define SIG_A_CHANGED (&(_SIG_A_CHANGED)) @@ -18,7 +17,4 @@ extern const Eo_Event_Description _SIG_A_CHANGED; #define SIMPLE_CLASS simple_class_get() const Eo_Class *simple_class_get(void); -extern Eina_Bool class_print_called; -extern Eina_Bool class_print2_called; - #endif |