@@ -58569,3 +58569,242 @@ const struct type* type_get_specifer_part(const struct type* p_type)
5856958569}
5857058570
5857158571
58572+
58573+ /*
58574+ * This file is part of cake compiler
58575+ * https://github.com/thradams/cake
58576+ */
58577+
58578+ #pragma safety enable
58579+
58580+
58581+ #ifdef _WIN32
58582+ #undef assert
58583+ #define assert _ASSERTE
58584+ #endif
58585+
58586+ #ifdef TEST
58587+
58588+
58589+ /*do not edit this file*/
58590+
58591+
58592+ #ifdef TEST
58593+ #define TESTCODE
58594+ #endif
58595+ int g_unit_test_error_count = 0;
58596+ int g_unit_test_success_count = 0;
58597+ #ifdef TESTCODE
58598+
58599+ /*forward declarations*/
58600+
58601+ /* tests from token.c*/
58602+ void token_list_remove_get_test(void);
58603+ void token_list_remove_get_test2(void);
58604+
58605+ /* tests from tokenizer.c*/
58606+ void test_lexeme_cmp(void);
58607+ void token_list_pop_front_test(void);
58608+ void token_list_pop_back_test(void);
58609+ int token_list_append_list_test(void);
58610+ void test_collect(void);
58611+ void test_va_opt_0(void);
58612+ void test_va_opt_1(void);
58613+ void test_va_opt_2(void);
58614+ void test_va_opt_3(void);
58615+ void test_va_opt_4(void);
58616+ void test_va_opt_5(void);
58617+ void test_va_opt_6(void);
58618+ void test_va_opt_7(void);
58619+ void concatenation_problem(void);
58620+ void test_va_opt_G2(void);
58621+ void test_va_opt(void);
58622+ void test_empty_va_args(void);
58623+ void test_va_args_single(void);
58624+ void test_va_args_extra_args(void);
58625+ void test_empty_va_args_empty(void);
58626+ void test_defined(void);
58627+ void testline(void);
58628+ void ifelse(void);
58629+ void T1(void);
58630+ int EXAMPLE5(void);
58631+ void recursivetest1(void);
58632+ void rectest(void);
58633+ void emptycall(void);
58634+ void semiempty(void);
58635+ void calling_one_arg_with_empty_arg(void);
58636+ void test_argument_with_parentesis(void);
58637+ void two_empty_arguments(void);
58638+ void simple_object_macro(void);
58639+ void test2(void);
58640+ void test3(void);
58641+ void tetris(void);
58642+ void recursive_macro_expansion(void);
58643+ void empty_and_no_args(void);
58644+ void empty_and_args(void);
58645+ void test4(void);
58646+ void test_string(void);
58647+ void test6(void);
58648+ void testerror(void);
58649+ int test_expression(void);
58650+ void test_concatenation_o(void);
58651+ void test_concatenation(void);
58652+ void bad_test(void);
58653+ void test_spaces(void);
58654+ void test_stringfy(void);
58655+ void test_stringfy_scape(void);
58656+ void test_stringfy_scape3(void);
58657+ int test_tokens(void);
58658+ int test_predefined_macros(void);
58659+ int test_utf8(void);
58660+ void test_counter(void);
58661+ void bug_test(void);
58662+ int test_line_continuation(void);
58663+ int stringify_test(void);
58664+ void recursive_macro_expr(void);
58665+ void quasi_recursive_macro(void);
58666+ void newline_macro_func(void);
58667+
58668+ /* tests from target.c*/
58669+ void target_self_test(void);
58670+
58671+ /*end of forward declarations*/
58672+
58673+ int test_main(void)
58674+ {
58675+ g_unit_test_error_count = 0;
58676+ g_unit_test_success_count = 0;
58677+ token_list_remove_get_test();
58678+ token_list_remove_get_test2();
58679+ test_lexeme_cmp();
58680+ token_list_pop_front_test();
58681+ token_list_pop_back_test();
58682+ token_list_append_list_test();
58683+ test_collect();
58684+ test_va_opt_0();
58685+ test_va_opt_1();
58686+ test_va_opt_2();
58687+ test_va_opt_3();
58688+ test_va_opt_4();
58689+ test_va_opt_5();
58690+ test_va_opt_6();
58691+ test_va_opt_7();
58692+ concatenation_problem();
58693+ test_va_opt_G2();
58694+ test_va_opt();
58695+ test_empty_va_args();
58696+ test_va_args_single();
58697+ test_va_args_extra_args();
58698+ test_empty_va_args_empty();
58699+ test_defined();
58700+ testline();
58701+ ifelse();
58702+ T1();
58703+ EXAMPLE5();
58704+ recursivetest1();
58705+ rectest();
58706+ emptycall();
58707+ semiempty();
58708+ calling_one_arg_with_empty_arg();
58709+ test_argument_with_parentesis();
58710+ two_empty_arguments();
58711+ simple_object_macro();
58712+ test2();
58713+ test3();
58714+ tetris();
58715+ recursive_macro_expansion();
58716+ empty_and_no_args();
58717+ empty_and_args();
58718+ test4();
58719+ test_string();
58720+ test6();
58721+ testerror();
58722+ test_expression();
58723+ test_concatenation_o();
58724+ test_concatenation();
58725+ bad_test();
58726+ test_spaces();
58727+ test_stringfy();
58728+ test_stringfy_scape();
58729+ test_stringfy_scape3();
58730+ test_tokens();
58731+ test_predefined_macros();
58732+ test_utf8();
58733+ test_counter();
58734+ bug_test();
58735+ test_line_continuation();
58736+ stringify_test();
58737+ recursive_macro_expr();
58738+ quasi_recursive_macro();
58739+ newline_macro_func();
58740+ target_self_test();
58741+ return g_unit_test_error_count;
58742+
58743+ }
58744+ #undef TESTCODE
58745+ #endif /*TEST*/
58746+
58747+ #endif
58748+
58749+ int main(int argc, char** argv)
58750+ {
58751+ enable_vt_mode();
58752+
58753+ #if 0
58754+ //Help debug emscript on desktop
58755+ //MOCKFILES needs to be defined
58756+ const char* source =
58757+ "#include <stdio.h>\n";
58758+
58759+ char* _Owner _Opt r =
58760+ CompileText("", source);
58761+ return;
58762+ #endif
58763+
58764+ printf("Cake " CAKE_VERSION " (%s)\n", get_platform(CAKE_COMPILE_TIME_SELECTED_TARGET)->name);
58765+
58766+ if (argc < 2)
58767+ {
58768+ print_help();
58769+ return 1;
58770+ }
58771+
58772+
58773+ if (argc > 1 && strcmp(argv[1], "-selftest") == 0)
58774+ {
58775+ printf("*** SELF TEST ***.\n");
58776+
58777+ #ifdef TEST
58778+
58779+ clock_t begin_clock = clock();
58780+
58781+ test_main();
58782+
58783+ struct report report = { 0 };
58784+ report.test_mode = true;
58785+ report.test_failed = g_unit_test_error_count;
58786+ report.test_succeeded = g_unit_test_success_count;
58787+
58788+ clock_t end_clock = clock();
58789+ double cpu_time_used = ((double)(end_clock - begin_clock)) / CLOCKS_PER_SEC;
58790+ report.no_files = g_unit_test_error_count + g_unit_test_success_count;
58791+ report.cpu_time_used_sec = cpu_time_used;
58792+
58793+ print_report(&report);
58794+
58795+ return g_unit_test_error_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
58796+ #else
58797+ printf("Error: self-tests not included. To run the self-tests, compile with -DTEST and try again.\n");
58798+ return EXIT_FAILURE;
58799+ #endif
58800+ }
58801+
58802+
58803+ struct report report = { 0 };
58804+ int result = compile(argc, (const char**)argv, &report);
58805+
58806+ return result;
58807+ }
58808+
58809+
58810+
0 commit comments