Ejemplo n.º 1
0
/*
 * Test
 * - create values of type tau
 * - n: max number of fresh values to try (assumed positive)
 */
static void test_type(type_t tau, uint32_t n) {
  value_t v;
  uint32_t i;

  printf("==== Test fresh values of type ");
  print_type(stdout, &types, tau);
  printf(" ====\n");
  printf("cardinality: %"PRIu32"\n\n", type_card(&types, tau));

  i = 0;
  do {
    v = make_fresh_value(&maker, tau);
    if (v == null_value) break;
    i ++;
    printf("val[%"PRIu32"] = ", i);
    vtbl_print_object(stdout, &vtbl, v);
    printf("\n");
    if (vtbl_queue_is_nonempty(&vtbl)) {
      vtbl_print_queued_functions(stdout, &vtbl, true);
      printf("\n");
    }
  } while (i <n);

  printf("\n---> got %"PRIu32" fresh values\n\n", i);
}
Ejemplo n.º 2
0
static void test_enum_type(type_t tau) {
  uint32_t i, n;
  value_t x;

  assert(is_finite_type(&types, tau) && type_card_is_exact(&types, tau));

  n = type_card(&types, tau);
  printf("==== Enumerating elements of type ");
  print_type(stdout, &types, tau);
  printf(" ====\n");
  printf("cardinality: %"PRIu32"\n", n);
  for (i=0; i<n; i++) {
    x = vtbl_gen_object(&vtbl, tau, i);
    printf("elem[%"PRIu32"] = ", i);
    vtbl_print_object(stdout, &vtbl, x);
    printf("\n");
    if (vtbl_queue_is_nonempty(&vtbl)) {
      vtbl_print_queued_functions(stdout, &vtbl, true);
      printf("\n");
    }
  }
  printf("\n");
}