On Tue, 22 Apr 2014 14:44:02 +0100 Tom Hacohen <[email protected]> said:

i was just looking for these... so i ended up making my own! :(

> Yay, finally. :)
> 
> On 22/04/14 08:21, Daniel Zaoui wrote:
> > jackdanielz pushed a commit to branch master.
> >
> > http://git.enlightenment.org/core/efl.git/commit/?id=d95a114db7ef950fe2ded3ea9b36cad1a621e294
> >
> > commit d95a114db7ef950fe2ded3ea9b36cad1a621e294
> > Author: Daniel Zaoui <[email protected]>
> > Date:   Mon Apr 21 09:36:44 2014 +0300
> >
> >      Eolian: infras for tests + first test
> > ---
> >   src/Makefile_Eolian.am                |  28 +++++
> >   src/tests/eolian/data/class_simple.eo |  31 +++++
> >   src/tests/eolian/eolian_suite.c       | 206 ++++++++++++++++++++++++++++++
> > ++++ src/tests/eolian/eolian_suite.h       |  10 ++
> >   4 files changed, 275 insertions(+)
> >
> > diff --git a/src/Makefile_Eolian.am b/src/Makefile_Eolian.am
> > index 6807557..326727c 100644
> > --- a/src/Makefile_Eolian.am
> > +++ b/src/Makefile_Eolian.am
> > @@ -55,3 +55,31 @@ am__v_RAGEL_0 = @echo "  RAGEL   " $@;
> >
> >   lib/eolian/eo_lexer.c: lib/eolian/eo_lexer.rl
> >   endif
> > +
> > +### Unit tests
> > +
> > +if EFL_ENABLE_TESTS
> > +check_PROGRAMS += \
> > +tests/eolian/eolian_suite
> > +
> > +tests_eolian_eolian_suite_SOURCES = \
> > +tests/eolian/eolian_suite.c \
> > +tests/eolian/eolian_suite.h
> > +
> > +tests_eolian_eolian_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
> > +-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian\" \
> > +-DPACKAGE_DATA_DIR=\"$(top_srcdir)/src/tests/eolian\" \
> > +@CHECK_CFLAGS@ \
> > +@EOLIAN_CFLAGS@
> > +TESTS += tests/eolian/eolian_suite
> > +
> > +tests_eolian_eolian_suite_LDADD = @CHECK_LIBS@ @USE_EOLIAN_LIBS@
> > +tests_eolian_eolian_suite_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@
> > +
> > +eoliandatafilesdir = $(datadir)/eolian/data
> > +eoliandatafiles_DATA = tests/eolian/data/class_simple.eo
> > +
> > +endif
> > +
> > +EXTRA_DIST += \
> > +tests/eolian/data/class_simple.eo
> > diff --git a/src/tests/eolian/data/class_simple.eo
> > b/src/tests/eolian/data/class_simple.eo new file mode 100644
> > index 0000000..3abbc3b
> > --- /dev/null
> > +++ b/src/tests/eolian/data/class_simple.eo
> > @@ -0,0 +1,31 @@
> > +class Simple {
> > +   /*@ Class Desc Simple */
> > +   legacy_prefix: evas_object_simple;
> > +   eo_prefix: evas_obj_simple;
> > +   data: Evas_Simple_Data;
> > +   properties {
> > +      a {
> > +         set {
> > +            /*@
> > +            comment a::set */
> > +            return Eina_Bool (EINA_TRUE);
> > +         }
> > +         get {
> > +         }
> > +         values {
> > +            int value; /*@ Value description */
> > +         }
> > +      }
> > +   }
> > +   methods {
> > +      foo {
> > +         /*@ comment foo */
> > +         params {
> > +            @in int a; /*@ a */
> > +            @inout char *b;
> > +            @out double c;
> > +         }
> > +         return char *(NULL);
> > +      }
> > +   }
> > +};
> > diff --git a/src/tests/eolian/eolian_suite.c
> > b/src/tests/eolian/eolian_suite.c new file mode 100644
> > index 0000000..7534e57
> > --- /dev/null
> > +++ b/src/tests/eolian/eolian_suite.c
> > @@ -0,0 +1,206 @@
> > +#ifdef HAVE_CONFIG_H
> > +# include <config.h>
> > +#endif
> > +
> > +#include <stdlib.h>
> > +#include <stdio.h>
> > +
> > +#include "Eolian.h"
> > +#include "eolian_suite.h"
> > +
> > +typedef struct _Eolian_Test_Case Eolian_Test_Case;
> > +
> > +struct _Eolian_Test_Case
> > +{
> > +   const char *test_case;
> > +   void      (*build)(TCase *tc);
> > +};
> > +
> > +START_TEST(eolian_simple_parsing)
> > +{
> > +   Eolian_Function fid = NULL;
> > +   const char *string = NULL, *ptype = NULL, *pname = NULL;
> > +   Eolian_Parameter_Dir dir = EOLIAN_IN_PARAM;
> > +   const char *class_name = "Simple";
> > +   const Eina_List *list = NULL;
> > +   Eolian_Function_Parameter param = NULL;
> > +
> > +   eolian_init();
> > +   /* Parsing */
> > +   fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/class_simple.eo"));
> > +   fail_if(strcmp(eolian_class_find_by_file
> > (PACKAGE_DATA_DIR"/data/class_simple.eo"), class_name)); +
> > +   /* Class */
> > +   fail_if(!eolian_class_exists(class_name));
> > +   fail_if(eolian_class_type_get(class_name) != EOLIAN_CLASS_REGULAR);
> > +   string = eolian_class_description_get(class_name);
> > +   fail_if(!string);
> > +   fail_if(strcmp(string, "Class Desc Simple"));
> > +   fail_if(eolian_class_inherits_list_get(class_name) != NULL);
> > +   fail_if(strcmp(eolian_class_legacy_prefix_get(class_name),
> > "evas_object_simple"));
> > +   fail_if(strcmp(eolian_class_eo_prefix_get(class_name),
> > "evas_obj_simple"));
> > +   fail_if(strcmp(eolian_class_data_type_get(class_name),
> > "Evas_Simple_Data")); +
> > +   /* Property */
> > +   fail_if(!(fid = eolian_class_function_find_by_name(class_name, "a",
> > EOLIAN_PROPERTY)));
> > +   fail_if(strcmp(eolian_function_name_get(fid), "a"));
> > +   string = eolian_function_description_get(fid, EOLIAN_COMMENT_SET);
> > +   fail_if(!string);
> > +   fail_if(strcmp(string, "comment a::set"));
> > +   string = eolian_function_description_get(fid, EOLIAN_COMMENT_GET);
> > +   fail_if(string);
> > +   /* Function return */
> > +   string = eolian_function_return_type_get(fid, EOLIAN_PROP_SET);
> > +   fail_if(!string);
> > +   fail_if(strcmp(string, "Eina_Bool"));
> > +   string = eolian_function_return_dflt_value_get(fid, EOLIAN_PROP_SET);
> > +   fail_if(!string);
> > +   fail_if(strcmp(string, "EINA_TRUE"));
> > +   string = eolian_function_return_type_get(fid, EOLIAN_PROP_GET);
> > +   fail_if(string);
> > +
> > +   /* Function parameters */
> > +   fail_if(eolian_property_keys_list_get(fid) != NULL);
> > +   fail_if(!(list = eolian_property_values_list_get(fid)));
> > +   fail_if(eina_list_count(list) != 1);
> > +   fail_if(!(param = eina_list_data_get(list)));
> > +   eolian_parameter_information_get(param, NULL, &ptype, &pname, &string);
> > +   fail_if(strcmp(ptype, "int"));
> > +   fail_if(strcmp(pname, "value"));
> > +   fail_if(strcmp(string, "Value description"));
> > +
> > +   /* Method */
> > +   fail_if(!(fid = eolian_class_function_find_by_name(class_name, "foo",
> > EOLIAN_METHOD)));
> > +   string = eolian_function_description_get(fid, EOLIAN_COMMENT);
> > +   fail_if(!string);
> > +   fail_if(strcmp(string, "comment foo"));
> > +   /* Function return */
> > +   string = eolian_function_return_type_get(fid, EOLIAN_METHOD);
> > +   fail_if(!string);
> > +   fail_if(strcmp(string, "char *"));
> > +   string = eolian_function_return_dflt_value_get(fid, EOLIAN_METHOD);
> > +   fail_if(!string);
> > +   fail_if(strcmp(string, "NULL"));
> > +
> > +   /* Function parameters */
> > +   fail_if(!(list = eolian_parameters_list_get(fid)));
> > +   fail_if(eina_list_count(list) != 3);
> > +   fail_if(!(param = eina_list_nth(list, 0)));
> > +   eolian_parameter_information_get(param, &dir, &ptype, &pname, &string);
> > +   fail_if(dir != EOLIAN_IN_PARAM);
> > +   fail_if(strcmp(ptype, "int"));
> > +   fail_if(strcmp(pname, "a"));
> > +   fail_if(!string || strcmp(string, "a"));
> > +   fail_if(!(param = eina_list_nth(list, 1)));
> > +   eolian_parameter_information_get(param, &dir, &ptype, &pname, &string);
> > +   fail_if(dir != EOLIAN_INOUT_PARAM);
> > +   fail_if(strcmp(ptype, "char *"));
> > +   fail_if(strcmp(pname, "b"));
> > +   fail_if(string);
> > +   fail_if(!(param = eina_list_nth(list, 2)));
> > +   eolian_parameter_information_get(param, &dir, &ptype, &pname, &string);
> > +   fail_if(dir != EOLIAN_OUT_PARAM);
> > +   fail_if(strcmp(ptype, "double"));
> > +   fail_if(strcmp(pname, "c"));
> > +   fail_if(string);
> > +
> > +   eolian_shutdown();
> > +}
> > +END_TEST
> > +
> > +static void eolian_parsing_test(TCase *tc)
> > +{
> > +   tcase_add_test(tc, eolian_simple_parsing);
> > +}
> > +
> > +static const Eolian_Test_Case etc[] = {
> > +  { "Eolian Parsing", eolian_parsing_test},
> > +  { NULL, NULL }
> > +};
> > +
> > +static void
> > +_list_tests(void)
> > +{
> > +  const Eolian_Test_Case *itr;
> > +
> > +   itr = etc;
> > +   fputs("Available Test Cases:\n", stderr);
> > +   for (; itr->test_case; itr++)
> > +     fprintf(stderr, "\t%s\n", itr->test_case);
> > +}
> > +
> > +static Eina_Bool
> > +_use_test(int argc, const char **argv, const char *test_case)
> > +{
> > +   if (argc < 1)
> > +     return 1;
> > +
> > +   for (; argc > 0; argc--, argv++)
> > +     if (strcmp(test_case, *argv) == 0)
> > +       return 1;
> > +   return 0;
> > +}
> > +
> > +static Suite *
> > +eolian_suite_build(int argc, const char **argv)
> > +{
> > +   TCase *tc;
> > +   Suite *s;
> > +   int i;
> > +
> > +   s = suite_create("Eolian");
> > +
> > +   for (i = 0; etc[i].test_case; ++i)
> > +     {
> > +   if (!_use_test(argc, argv, etc[i].test_case)) continue;
> > +   tc = tcase_create(etc[i].test_case);
> > +
> > +   etc[i].build(tc);
> > +
> > +   suite_add_tcase(s, tc);
> > +   tcase_set_timeout(tc, 0);
> > +     }
> > +
> > +   return s;
> > +}
> > +
> > +int
> > +main(int argc, char **argv)
> > +{
> > +   Suite *s;
> > +   SRunner *sr;
> > +   int i, failed_count;
> > +   eolian_init();
> > +   setenv("CK_FORK", "no", 0);
> > +
> > +   for (i = 1; i < argc; i++)
> > +     if ((strcmp(argv[i], "-h") == 0) ||
> > +    (strcmp(argv[i], "--help") == 0))
> > +       {
> > +     fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
> > +             argv[0]);
> > +     _list_tests();
> > +     return 0;
> > +       }
> > +     else if ((strcmp(argv[i], "-l") == 0) ||
> > +         (strcmp(argv[i], "--list") == 0))
> > +       {
> > +     _list_tests();
> > +     return 0;
> > +       }
> > +
> > +   putenv("EFL_RUN_IN_TREE=1");
> > +
> > +   s = eolian_suite_build(argc - 1, (const char **)argv + 1);
> > +   sr = srunner_create(s);
> > +
> > +   srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
> > +
> > +   srunner_run_all(sr, CK_ENV);
> > +   failed_count = srunner_ntests_failed(sr);
> > +   srunner_free(sr);
> > +
> > +   eolian_shutdown();
> > +
> > +   return (failed_count == 0) ? 0 : 255;
> > +}
> > diff --git a/src/tests/eolian/eolian_suite.h
> > b/src/tests/eolian/eolian_suite.h new file mode 100644
> > index 0000000..210b301
> > --- /dev/null
> > +++ b/src/tests/eolian/eolian_suite.h
> > @@ -0,0 +1,10 @@
> > +#ifndef _EOLIAN_SUITE_H
> > +#define _EOLIAN_SUITE_H
> > +
> > +#include <check.h>
> > +
> > +void eolian_test_init(TCase *tc);
> > +void eolian_test_general(TCase *tc);
> > +
> > +#endif /* _EOLIAN_SUITE_H */
> > +
> >
> 
> 
> ------------------------------------------------------------------------------
> Start Your Social Network Today - Download eXo Platform
> Build your Enterprise Intranet with eXo Platform Software
> Java Based Open Source Intranet - Social, Extensible, Cloud Ready
> Get Started Now And Turn Your Intranet Into A Collaboration Platform
> http://p.sf.net/sfu/ExoPlatform
> _______________________________________________
> enlightenment-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> 


-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    [email protected]


------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to