static void S_run_tests(CFCTest *test) { CFCParser *parser = CFCParser_new(); CFCParcel *neato_parcel = CFCTest_parse_parcel(test, parser, "parcel Neato;"); CFCType *return_type = CFCTest_parse_type(test, parser, "Obj*"); CFCParamList *param_list = CFCTest_parse_param_list(test, parser, "(int32_t some_num)"); { CFCFunction *func = CFCFunction_new(NULL, "return_an_obj", return_type, param_list, NULL, 0); OK(test, func != NULL, "new"); CFCBase_decref((CFCBase*)func); } { CFCFunction *func = NULL; char *error; CFCUTIL_TRY { func = CFCFunction_new(NULL, "Uh_Oh", return_type, param_list, NULL, 0); } CFCUTIL_CATCH(error); OK(test, error && strstr(error, "Uh_Oh"), "invalid name kills constructor"); FREEMEM(error); CFCBase_decref((CFCBase*)func); } { CFCClass *neato_obj = CFCClass_create(neato_parcel, NULL, "Neato::Obj", NULL, NULL, NULL, NULL, false, false, false); CFCParser_set_class(parser, neato_obj); static const char *func_strings[2] = { "inert int running_count(int biscuit);", "public inert Hash* init_fave_hash(int32_t num_buckets," " bool o_rly);" }; for (int i = 0; i < 2; ++i) { CFCFunction *func = CFCTest_parse_function(test, parser, func_strings[i]); CFCBase_decref((CFCBase*)func); } CFCBase_decref((CFCBase*)neato_obj); } CFCBase_decref((CFCBase*)return_type); CFCBase_decref((CFCBase*)param_list); CFCBase_decref((CFCBase*)neato_parcel); CFCBase_decref((CFCBase*)parser); CFCParcel_reap_singletons(); }
static void S_run_tests(CFCTest *test) { CFCParser *parser = CFCParser_new(); CFCParcel *neato_parcel = CFCTest_parse_parcel(test, parser, "parcel Neato;"); { CFCType *return_type = CFCTest_parse_type(test, parser, "Obj*"); CFCParamList *param_list = CFCTest_parse_param_list(test, parser, "(int32_t some_num)"); CFCFunction *func = CFCFunction_new(neato_parcel, NULL, "Neato::Foo", "Foo", "return_an_obj", return_type, param_list, NULL, 0); OK(test, func != NULL, "new"); CFCBase_decref((CFCBase*)return_type); CFCBase_decref((CFCBase*)param_list); CFCBase_decref((CFCBase*)func); } { CFCParser_set_class_name(parser, "Neato::Obj"); CFCParser_set_class_cnick(parser, "Obj"); static const char *func_strings[2] = { "inert int running_count(int biscuit);", "public inert Hash* init_fave_hash(int32_t num_buckets," " bool o_rly);" }; for (int i = 0; i < 2; ++i) { CFCFunction *func = CFCTest_parse_function(test, parser, func_strings[i]); CFCBase_decref((CFCBase*)func); } } CFCBase_decref((CFCBase*)neato_parcel); CFCBase_decref((CFCBase*)parser); CFCParcel_reap_singletons(); }