Example #1
0
int main(int argc, char **argv) {
  gen = gen_new(1);

  hello();

  printf("\n");
  compile_test();

  printf("\n");
  test();

  return 0;
}
Example #2
0
static int on_config_mruby_handler_file(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
    struct mruby_configurator_t *self = (void *)cmd->configurator;
    FILE *fp = NULL;
    h2o_iovec_t buf = {};
    int ret = -1;

    /* open and read file */
    if ((fp = fopen(node->data.scalar, "rt")) == NULL) {
        h2o_configurator_errprintf(cmd, node, "failed to open file: %s:%s", node->data.scalar, strerror(errno));
        goto Exit;
    }
    while (!feof(fp)) {
        buf.base = h2o_mem_realloc(buf.base, buf.len + 65536);
        buf.len += fread(buf.base + buf.len, 1, 65536, fp);
        if (ferror(fp)) {
            h2o_configurator_errprintf(cmd, node, "I/O error occurred while reading file:%s:%s", node->data.scalar,
                                       strerror(errno));
            goto Exit;
        }
    }

    /* set source */
    self->vars->source = buf;
    buf.base = NULL;
    self->vars->path = node->data.scalar; /* the value is retained until the end of the configuration phase */
    self->vars->lineno = 0;

    /* check if there is any error in source */
    char errbuf[1024];
    if (!compile_test(self->vars, errbuf)) {
        h2o_configurator_errprintf(cmd, node, "failed to compile file:%s:%s", node->data.scalar, errbuf);
        goto Exit;
    }

    /* register */
    h2o_mruby_register(ctx->pathconf, self->vars);

    ret = 0;

Exit:
    if (fp != NULL)
        fclose(fp);
    if (buf.base != NULL)
        free(buf.base);
    return ret;
}
Example #3
0
static int on_config_mruby_handler(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
    struct mruby_configurator_t *self = (void *)cmd->configurator;

    /* set source */
    self->vars->source = h2o_strdup(NULL, node->data.scalar, SIZE_MAX);
    self->vars->path = node->filename;
    self->vars->lineno = (int)node->line;

    /* check if there is any error in source */
    char errbuf[1024];
    if (!compile_test(self->vars, errbuf)) {
        h2o_configurator_errprintf(cmd, node, "ruby compile error:%s", errbuf);
        return -1;
    }

    /* register */
    h2o_mruby_register(ctx->pathconf, self->vars);

    return 0;
}
int main() {
  if(!test_no_deduction_points_and_normals_xyz("data/read_test/simple.xyz")) {
    return EXIT_FAILURE;
  }
  std::cerr << "test_no_deduction_points_and_normals_xyz OK." << std::endl;

  if(!test_no_deduction_points_and_normals_off("data/read_test/simple.off")) {
    return EXIT_FAILURE;
  }
  std::cerr << "test_no_deduction_points_and_normals_off OK." << std::endl;

  if(!test_no_deduction_points_xyz("data/read_test/simple.xyz")) {
    return EXIT_FAILURE;
  }
  std::cerr << "test_no_deduction_points_xyz OK." << std::endl;

  if(!test_no_deduction_points_off("data/read_test/simple.off")) {
    return EXIT_FAILURE;
  }
  std::cerr << "test_no_deduction_points_off OK." << std::endl;

  compile_test();
  return EXIT_SUCCESS;
}
static int
do_test (void)
{
  int result = 0;

  count_float = count_double = count_ldouble = 0;
  count_cfloat = count_cdouble = count_cldouble = 0;
  compile_test ();
  if (count_float != 0 || count_cfloat != 0)
    {
      puts ("float function called for double test");
      result = 1;
    }
  if (count_ldouble != 0 || count_cldouble != 0)
    {
      puts ("long double function called for double test");
      result = 1;
    }
  if (count_double < NCALLS + NCALLS_INT)
    {
      printf ("double functions not called often enough (%d)\n",
	      count_double);
      result = 1;
    }
  else if (count_double > NCALLS + NCALLS_INT)
    {
      printf ("double functions called too often (%d)\n",
	      count_double);
      result = 1;
    }
  if (count_cdouble < NCCALLS)
    {
      printf ("double complex functions not called often enough (%d)\n",
	      count_cdouble);
      result = 1;
    }
  else if (count_cdouble > NCCALLS)
    {
      printf ("double complex functions called too often (%d)\n",
	      count_cdouble);
      result = 1;
    }

  count_float = count_double = count_ldouble = 0;
  count_cfloat = count_cdouble = count_cldouble = 0;
  compile_testf ();
  if (count_double != 0 || count_cdouble != 0)
    {
      puts ("double function called for float test");
      result = 1;
    }
  if (count_ldouble != 0 || count_cldouble != 0)
    {
      puts ("long double function called for float test");
      result = 1;
    }
  if (count_float < NCALLS)
    {
      printf ("float functions not called often enough (%d)\n", count_float);
      result = 1;
    }
  else if (count_float > NCALLS)
    {
      printf ("float functions called too often (%d)\n",
	      count_double);
      result = 1;
    }
  if (count_cfloat < NCCALLS)
    {
      printf ("float complex functions not called often enough (%d)\n",
	      count_cfloat);
      result = 1;
    }
  else if (count_cfloat > NCCALLS)
    {
      printf ("float complex functions called too often (%d)\n",
	      count_cfloat);
      result = 1;
    }

#ifndef NO_LONG_DOUBLE
  count_float = count_double = count_ldouble = 0;
  count_cfloat = count_cdouble = count_cldouble = 0;
  compile_testl ();
  if (count_float != 0 || count_cfloat != 0)
    {
      puts ("float function called for long double test");
      result = 1;
    }
  if (count_double != 0 || count_cdouble != 0)
    {
      puts ("double function called for long double test");
      result = 1;
    }
  if (count_ldouble < NCALLS)
    {
      printf ("long double functions not called often enough (%d)\n",
	      count_ldouble);
      result = 1;
    }
  else if (count_ldouble > NCALLS)
    {
      printf ("long double functions called too often (%d)\n",
	      count_double);
      result = 1;
    }
  if (count_cldouble < NCCALLS)
    {
      printf ("long double complex functions not called often enough (%d)\n",
	      count_cldouble);
      result = 1;
    }
  else if (count_cldouble > NCCALLS)
    {
      printf ("long double complex functions called too often (%d)\n",
	      count_cldouble);
      result = 1;
    }
#endif

  return result;
}