Eolian/Tests: add test for complex type.

It includes too fixes for the complex type. If I had listened to Tasn,
I would have detected them a long time ago.
But he didn't insist enough. He just said:
"Write your tests, ?#@*&%! french!"
This commit is contained in:
Daniel Zaoui 2014-04-25 09:26:39 +03:00
parent 6efce2289b
commit 6797e12bc3
4 changed files with 869 additions and 756 deletions

File diff suppressed because it is too large Load Diff

View File

@ -500,7 +500,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
}
rettype_comment = ws* eo_comment %end_accessor_rettype_comment;
rettype = 'return' ws+ alpha+ >save_fpc return_char+ %end_accessor_return end_statement rettype_comment?;
rettype = 'return' ws+ return_char >save_fpc return_char+ %end_accessor_return end_statement rettype_comment?;
legacy = 'legacy' ws+ ident %end_accessor_legacy end_statement;
@ -724,7 +724,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
meth_legacy = 'legacy' ws+ ident %end_method_legacy end_statement;
meth_rettype_comment = ws* eo_comment %end_method_rettype_comment;
meth_rettype = 'return' ws+ alpha+ >save_fpc return_char+ %end_method_rettype end_statement meth_rettype_comment?;
meth_rettype = 'return' ws+ return_char >save_fpc return_char+ %end_method_rettype end_statement meth_rettype_comment?;
meth_obj_const = 'const' %end_method_obj_const end_statement;
@ -1209,10 +1209,10 @@ _types_extract(const char *buf, int len)
/* @own */
case '@':
{
if (!strncmp(buf, "own", 3))
if (!strncmp(buf, "own ", 4))
{
is_own = EINA_TRUE;
buf += 3; len -= 3;
buf += 4; len -= 4;
}
break;
}
@ -1255,7 +1255,7 @@ _types_extract(const char *buf, int len)
ERR("%s: Too much >", save_buf);
goto error;
}
if (d == tmp_type)
if (depth > 0 && d == tmp_type)
{
ERR("%s: empty type inside <>", save_buf);
goto error;

View File

@ -0,0 +1,22 @@
class Complex_Type {
properties {
a {
set {
return @own Eina_List * <Eina_Array*< @own Eo * *>>;
}
get {
}
values {
@own Eina_List *<int> value;
}
}
}
methods {
foo {
params {
@own char *buf;
}
return @own Eina_List *<Eina_Stringshare *>; /*@ comment for method return */
}
}
}

View File

@ -52,6 +52,68 @@ START_TEST(eolian_ctor_dtor)
}
END_TEST
START_TEST(eolian_complex_type)
{
Eolian_Function fid = NULL;
Eolian_Function_Parameter param = NULL;
const Eina_List *params_list = NULL;
const char *class_name = "Complex_Type";
Eolian_Type types_list = NULL;
const char *type_name = NULL;
Eina_Bool own = EINA_FALSE;
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/complex_type.eo"));
/* Properties return type */
fail_if(!(fid = eolian_class_function_find_by_name(class_name, "a", EOLIAN_PROPERTY)));
fail_if(!(types_list = eolian_function_return_types_list_get(fid, EOLIAN_PROP_SET)));
fail_if(!(types_list = eolian_type_information_get(types_list, &type_name, &own)));
fail_if(strcmp(type_name, "Eina_List *"));
fail_if(own != EINA_TRUE);
fail_if(!(types_list = eolian_type_information_get(types_list, &type_name, &own)));
fail_if(strcmp(type_name, "Eina_Array *"));
fail_if(own != EINA_FALSE);
fail_if(eolian_type_information_get(types_list, &type_name, &own));
fail_if(strcmp(type_name, "Eo **"));
fail_if(own != EINA_TRUE);
/* Properties parameter type */
fail_if(!(params_list = eolian_parameters_list_get(fid)));
fail_if(eina_list_count(params_list) != 1);
fail_if(!(param = eina_list_nth(params_list, 0)));
fail_if(strcmp(eolian_parameter_name_get(param), "value"));
fail_if(!(types_list = eolian_parameter_types_list_get(param)));
fail_if(!(types_list = eolian_type_information_get(types_list, &type_name, &own)));
fail_if(strcmp(type_name, "Eina_List *"));
fail_if(own != EINA_TRUE);
fail_if(eolian_type_information_get(types_list, &type_name, &own));
fail_if(strcmp(type_name, "int"));
fail_if(own != EINA_FALSE);
/* Methods return type */
fail_if(!(fid = eolian_class_function_find_by_name(class_name, "foo", EOLIAN_METHOD)));
fail_if(!(types_list = eolian_function_return_types_list_get(fid, EOLIAN_METHOD)));
fail_if(!(types_list = eolian_type_information_get(types_list, &type_name, &own)));
fail_if(strcmp(type_name, "Eina_List *"));
fail_if(own != EINA_TRUE);
fail_if(eolian_type_information_get(types_list, &type_name, &own));
fail_if(strcmp(type_name, "Eina_Stringshare *"));
fail_if(own != EINA_FALSE);
/* Methods parameter type */
fail_if(!(params_list = eolian_parameters_list_get(fid)));
fail_if(eina_list_count(params_list) != 1);
fail_if(!(param = eina_list_nth(params_list, 0)));
fail_if(strcmp(eolian_parameter_name_get(param), "buf"));
fail_if(!(types_list = eolian_parameter_types_list_get(param)));
fail_if(eolian_type_information_get(types_list, &type_name, &own));
fail_if(strcmp(type_name, "char *"));
fail_if(own != EINA_TRUE);
eolian_shutdown();
}
END_TEST
START_TEST(eolian_scope)
{
Eolian_Function fid = NULL;
@ -187,6 +249,7 @@ 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);
tcase_add_test(tc, eolian_complex_type);
}
static const Eolian_Test_Case etc[] = {