Commit d5bcaafd authored by Masamitsu MURASE's avatar Masamitsu MURASE

Modify return value of mrbtest.

This is an improvement for CI, such as Travis.
parent 0584874e
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <mruby/proc.h> #include <mruby/proc.h>
#include <mruby/data.h> #include <mruby/data.h>
#include <mruby/compile.h> #include <mruby/compile.h>
#include <mruby/variable.h>
void void
mrb_init_mrbtest(mrb_state *); mrb_init_mrbtest(mrb_state *);
...@@ -23,12 +24,24 @@ void print_hint(void) ...@@ -23,12 +24,24 @@ void print_hint(void)
printf("Thanks :)\n\n"); printf("Thanks :)\n\n");
} }
static int
check_error(mrb_state *mrb)
{
/* Error check */
/* $ko_test and $kill_test should be 0 */
mrb_value ko_test = mrb_gv_get(mrb, mrb_intern(mrb, "$ko_test"));
mrb_value kill_test = mrb_gv_get(mrb, mrb_intern(mrb, "$kill_test"));
return FIXNUM_P(ko_test) && mrb_fixnum(ko_test) == 0 && FIXNUM_P(kill_test) && mrb_fixnum(kill_test) == 0;
}
int int
main(void) main(void)
{ {
mrb_state *mrb; mrb_state *mrb;
mrb_value return_value; mrb_value return_value;
const char *prog = "report()"; const char *prog = "report()";
int ret = EXIT_SUCCESS;
print_hint(); print_hint();
...@@ -46,11 +59,12 @@ main(void) ...@@ -46,11 +59,12 @@ main(void)
if (mrb->exc) { if (mrb->exc) {
mrb_p(mrb, return_value); mrb_p(mrb, return_value);
mrb->exc = 0; mrb->exc = 0;
ret = EXIT_FAILURE;
} }
else { else if (!check_error(mrb)) {
/* no */ ret = EXIT_FAILURE;
} }
mrb_close(mrb); mrb_close(mrb);
return EXIT_SUCCESS; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment