Exemplo n.º 1
0
void measure_int_speed(void)
{
#undef	TESTS
#define	TESTS 1024

	int n;
	dword t;
	float f;
	float test_timePR[TESTS];
	float test_timeRP[TESTS];
	float timer_time=1193181;		// timer freq in Hz

	test_int();
	for(n=0; n<TESTS; n++)
	{
		t=test_int();
		test_timePR[n]=(t&0x0000FFFF);
		test_timeRP[n]=(t&0xFFFF0000)>>16;
	}
	f=0;
	for(n=0; n<TESTS; n++) f=f+test_timePR[n];
	f=f/TESTS;
	intPR_speed=(f/2)/timer_time;

	f=0;
	for(n=0; n<TESTS; n++) f=f+test_timeRP[n];
	f=f/TESTS;
	intRP_speed=(f/2)/timer_time;

}
Exemplo n.º 2
0
void core_mul() {
  env *e = prepare_env();
  test_int(e, "(* 2 3)", 6);
  test_int(e, "(* 2 3 4)", 24);
  test_int(e, "(* (* 2 1) (* 1 3))", 6);
  test_int(e, "(* (* 2 1) (* 1 3) (* 2 2))", 24);
}
Exemplo n.º 3
0
void core_add() {
  env *e = prepare_env();
  test_int(e, "(+ 1 1)", 2);
  test_int(e, "(+ 1 1 1)", 3);
  test_int(e, "(+ 1 (+ 2 3))", 6);
  test_int(e, "(+ (+ 2 3) (+ 4 5)))", 14);
}
Exemplo n.º 4
0
Arquivo: gc.c Projeto: hsk/docs
/*
void test_pipes1() {
  enum {frame_START, frame_SIZE, A, B, C, frame_END};
  ENTER_FRAME_ENUM(frame);

  A = gc_alloc_int(1); // 1
  assert(vm->heap_num==1);

  PUSH_VM(vm1);

    assert(vm->heap_num==0);
    frame[B] = test_new_vm2(A);
    assert(vm->heap_num==4);
    frame[B] = test_new_vm2(frame[B]);
    assert(vm->heap_num==8);
    frame[B] = test_new_vm2(frame[B]);
    assert(vm->heap_num==12);
  printf("id change check.........\n");
  POP_VM(vm1,frame[B]);
  assert(vm->heap_num==8);
  printf("id change check.........\n");
  gc_collect();
  assert(vm->heap_num==7);
  LEAVE_FRAME(frame);
}

void test_pipes2() {
  enum {frame_START, frame_SIZE, A, B, C, frame_END};
  ENTER_FRAME_ENUM(frame);

  A = gc_alloc_int(1); // 1

  assert(vm->heap_num==1);
  PUSH_VM(vm1);
    assert(vm->heap_num==0);
    frame[B] = test_new_vm2(A); // 生きているのが2つ死んでいるのが2つ
    assert(vm->heap_num==4);
    gc_collect_pipe(frame[B]);// bだけコピーして後は消す
    assert(vm->heap_num==2);
    frame[B] = test_new_vm2(frame[B]);// bを渡すと 2つのデータが入ってるのを渡す
    assert(vm->heap_num==6); // 生きてる4、死んでる2
    gc_collect_pipe(frame[B]);// bだけコピーして後は消す
    assert(vm->heap_num==4);// 生きてる4
    frame[B] = test_new_vm2(frame[B]);// 4+4=
    assert(vm->heap_num==8);// 4 + 4 = 8 生きてる6死んでる2と
    gc_collect_pipe(frame[B]);// bだけコピーして後は消す
    assert(vm->heap_num==6);// 生きてる6

  printf("id change check.........\n");
  POP_VM(vm1, frame[B]); // 世界が終わる
  // ヒープ上には、元のデータ1と世界のデータ1と6つの生きているで8個
  assert(vm->heap_num==8);
  printf("id change check.........\n");
  gc_collect();// gcで世界のデータが消える。
  assert(vm->heap_num==7);
  LEAVE_FRAME(frame);
}
*/
void test_multi_vm() {
    ENTER_FRAME(frame,8);
    Object* A = pool(gc_alloc_int(1));

    assert(vm->heap_num==1);
    VM* tmp_vm = pool(vm);
    VM* VM1 = pool(vm_new());// 世界を作る
    VM* VM2 = pool(vm_new());// 世界を作る
    assert(vm->heap_num==3);
    vm = VM1;// 世界を移動
    assert(vm->heap_num==0);
    vm->record = test_int(A->intv);// 計算する
    assert(vm->heap_num==1);

    Object* C;
    vm = VM2;// 世界を移動
    assert(vm->heap_num==0);
    C = pool(test_int(A->intv));// 計算する
    assert(vm->heap_num==1);
    vm_end(C, tmp_vm);

    vm = tmp_vm;// 元に戻る
    assert(vm->heap_num==4);

    Object* B = pool(vm_get_record(VM1));// コピーとる
    assert(vm->heap_num==5);
    printf("id change check.........\n");
    gc_collect();
    assert(vm->heap_num==5);
    LEAVE_FRAME(frame);
}
Exemplo n.º 5
0
void core_div() {
  env *e = prepare_env();
  test_int(e, "(/ 3 1)", 3);
  test_int(e, "(/ 10 2)", 5);
  test_int(e, "(/ (/ 20 2) (/ 9 3))", 3);
  
  atom *exp = eval(e, parse("(/ 2 0)"));
  check(exp->typ == A_ERROR, "divide by 0 returns error");
}
Exemplo n.º 6
0
void core_defun() {
  env *e = prepare_env();
  atom *exp = eval(e, parse("(defun hello (x) (+ 2 2))"));
  test_int(e, "(hello 8)", 4);
  exp = eval(e, parse("(defun cool () 10)"));
  test_int(e, "(cool)", 10);
  exp = eval(e, parse("(defun cool (x y z) (+ x y z))"));
  test_int(e, "(cool 1 2 3)", 6);
}
void circular_buffer_wrap_around_test()
{
	int ii;
	CircularBuffer *buffer = circular_buffer_create(12);

	for (ii = 1; ii <= 13; ii++) circular_buffer_enqueue(buffer, ii);

	test_int(circular_buffer_dequeue(buffer), 13, "Enqueue wraps around");
	for (ii = 2; ii <= 12; ii++) {
		test_int(circular_buffer_dequeue(buffer), ii, "Dequeue continues after wrap-around");
	}

	circular_buffer_destroy(buffer);
}
Exemplo n.º 8
0
 void Test_Variant::run()
 {
     test_int();
     test_float();
     test_double();
     test_string();
 }
Exemplo n.º 9
0
int main() {

   test_int() ;
   test_double() ;

   return 0 ;
}
Exemplo n.º 10
0
Arquivo: gc.c Projeto: hsk/docs
void test_multi() {
    ENTER_FRAME(frame,3);

    Object* A = pool(gc_alloc_int(1));
    Object* B;
    assert(vm->heap_num==1);
    PUSH_VM(vm1);// vmオブジェクトが作られる
    assert(vm->heap_num==0);
    assert(vm1->heap_num==2);
    POP_VM(vm1, B);
    assert(vm->heap_num==2);
    gc_collect();// 世界が消える
    assert(vm->heap_num==1);


    PUSH_VM(vm2);
    assert(vm2->heap_num==2); // 世界が増える
    assert(vm->heap_num==0);
    B = pool(test_int(A->intv));
    assert(vm->heap_num==1);
    assert(vm2->heap_num==2);
    POP_VM(vm2, B);
    assert(vm->heap_num==3);// frame2の世界と値が増えた

    gc_collect();// frame2世界が消えた
    assert(vm->heap_num==2);

    LEAVE_FRAME(frame);
}
Exemplo n.º 11
0
void test_leak() {
  for (;;) {
    test_int();
    test_double();
    test_charP();
    test_String();
  }
}
Exemplo n.º 12
0
int
main ()
{
  test_string ();
  test_null_string ();
  test_int ();
  return 0;
}
Exemplo n.º 13
0
	int test()
	{
		int Error(0);

		Error += test_int();
		Error += test_float();

		return Error;
	}
Exemplo n.º 14
0
void circular_buffer_enqueue_test()
{
	CircularBuffer *buffer = circular_buffer_create(12);

	circular_buffer_enqueue(buffer, 1);
	test_int(circular_buffer_dequeue(buffer), 1, "Enqueue and dequeue value");

	circular_buffer_destroy(buffer);
}
Exemplo n.º 15
0
int
main(int argc, char * argv[])
{
    test_int();
    test_string();


    return EXIT_SUCCESS;
}
Exemplo n.º 16
0
// Types can be defined in constexpr functions.
constexpr int f() {
  enum E { e1, e2, e3 };

  struct S {
    constexpr S(E e) : e(e) {}
    constexpr int get() { return e; }
    E e;
  };

  return S(e2).get();
}
Exemplo n.º 17
0
int main (void) {
  START("CoolQueue");
  test_int();
  test_double();
  test_charP();
  test_String();
#if LEAK
  test_leak();
#endif
  SUMMARY();
  return 0;
}
Exemplo n.º 18
0
int main()
{
    test_cpy();
    test_int();
    test_long();
    test_real();
    test_idx();
    test_trim();
    test_split();
    test_match();

    return 0;
}
Exemplo n.º 19
0
Arquivo: add.c Projeto: wgtdkp/wgtcc
int main() {
  test_char();
  test_uchar();
  test_short();
  test_ushort();
  test_int();
  test_uint();
  test_long();
  test_ulong();
  test_float();
  test_double();
  return 0;
}
Exemplo n.º 20
0
void main(void)
{
    test_int(-2); // true
    test_int(-1); // true
    test_int(0);  // false
    test_int(1);  // true
    test_int(2);  // true
    test_int(3);  // true
}
Exemplo n.º 21
0
int main(int argc, char *argv[]) {
	test_long();
	test_int();
	test_short();
	test_char();
	test_unsigned_long();
	test_unsigned_int();
	test_unsigned_short();
	test_unsigned_char();
#if 0
	test_unsigned_long_long();
	test_long_long();
#endif
	return 0;
}
Exemplo n.º 22
0
Arquivo: gc.c Projeto: hsk/docs
void test_record() {
    ENTER_FRAME(frame,2);

    // レコード
    enum {RECORD_SIZE=3,RECORD_BITMAP=BIT(1)|BIT(2)};
    Object* A = pool(gc_alloc_record(RECORD_SIZE));
    A->longs[RECORD_SIZE] = RECORD_BITMAP;// レコードのビットマップ(cpuビット数分でアラインする。ビットマップもcpu bit数)
    A->longs[0] = 10; // undata
    A->field[1] = gc_alloc_int(20);
    A->field[2] = test_int(30);

    assert(vm->heap_num==3);
    gc_collect();
    assert(vm->heap_num==3);
    LEAVE_FRAME(frame);
}
Exemplo n.º 23
0
int
main (void)
{

  err = 0;

  test_float ();
  test_double ();
  test_long_double ();
  test_int ();
  test_long_int ();

  if (err != 0)
    abort ();

  return 0;
}
Exemplo n.º 24
0
Arquivo: test5.c Projeto: hsk/docs
void test_record() {
  enum {A, DUMMY, SIZE};
  Object* frame[SIZE];
  static void* start_ptr = &&end; goto *start_ptr; start:;
  // レコード
  enum {RECORD_SIZE=3,RECORD_BITMAP=BIT(1)|BIT(2)};
  frame[A] = gc_alloc_record(RECORD_SIZE);
  frame[A]->longs[0] = 10; // undata
  frame[A]->field[1] = gc_alloc_int(20);
  frame[A]->field[2] = test_int(30);
  frame[A]->longs[RECORD_SIZE] = RECORD_BITMAP;// レコードのビットマップ(cpuビット数分でアラインする。ビットマップもcpu bit数)

  assert(heap_num==3);
  gc_collect();
  assert(heap_num==3);
  return;
end:;
  static StackMap f = {SIZE, (void*)test_record,&&end, NULL};
  gc_add_stack_map(&f); start_ptr=&&start; goto *start_ptr;
}
Exemplo n.º 25
0
void run()
{
    test_zero();
    test_zero_white();
    test_hundred();
    test_minus_hundred();
    test_large();
    test_max();
    fail_minus();
    fail_minus_white();
    fail_minus_alpha();
    fail_too_large();
    fail_as_float();
    fail_as_string();

    test_short();
    test_int();
    test_long();
    test_intmax();
    test_unsigned();
    fail_unsigned_negative();
}
Exemplo n.º 26
0
static gboolean test_row(GtkTreeModel *model, GtkTreeIter *iter, gint sel,
			 gint col_num, gint search_val, const gchar *search_text)
{
	gchar *text = NULL;
	gboolean found = FALSE;
	gint val;

	switch (col_num) {
	case TRACE_VIEW_STORE_COL_INDEX:
	case TRACE_VIEW_STORE_COL_CPU:
	case TRACE_VIEW_STORE_COL_PID:
		/* integers */

		gtk_tree_model_get(model, iter,
				   col_num, &val,
				   -1);
		if (test_int(val, search_val, sel))
			found = TRUE;
		break;

	case TRACE_VIEW_STORE_COL_TS:
	case TRACE_VIEW_STORE_COL_COMM:
	case TRACE_VIEW_STORE_COL_LAT:
	case TRACE_VIEW_STORE_COL_EVENT:
	case TRACE_VIEW_STORE_COL_INFO:
		/* strings */

		gtk_tree_model_get(model, iter,
				   col_num, &text,
				   -1);

		if (test_text(text, search_text, sel))
			found = TRUE;
		break;
	}

	return found;
}
Exemplo n.º 27
0
int
main (int argc, char *argv[])
{
  unsigned int prec, err, yprec, n, k, zeros;
  int rnd;
  mpfr_t x, y, z, t;
  int inexact;

  tests_start_mpfr ();

  special ();

  test_int ();

  mpfr_init (x);
  mpfr_init (y);
  mpfr_init (z);
  mpfr_init (t);

  mpfr_fac_ui (y, 0, GMP_RNDN);

  if (mpfr_cmp_ui (y, 1))
    {
      printf ("mpfr_fac_ui(0) does not give 1\n");
      exit (1);
    }

  for (prec = 2; prec <= 100; prec++)
    {
      mpfr_set_prec (x, prec);
      mpfr_set_prec (z, prec);
      mpfr_set_prec (t, prec);
      yprec = prec + 10;
      mpfr_set_prec (y, yprec);

      for (n = 0; n < 50; n++)
        for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
          {
            inexact = mpfr_fac_ui (y, n, (mp_rnd_t) rnd);
            err = (rnd == GMP_RNDN) ? yprec + 1 : yprec;
            if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec))
              {
                mpfr_set (t, y, (mp_rnd_t) rnd);
                inexact = mpfr_fac_ui (z, n, (mp_rnd_t) rnd);
                /* fact(n) ends with floor(n/2)+floor(n/4)+... zeros */
                for (k=n/2, zeros=0; k; k >>= 1)
                  zeros += k;
                if (MPFR_EXP(y) <= (mp_exp_t) (prec + zeros))
                  /* result should be exact */
                  {
                    if (inexact)
                      {
                        printf ("Wrong inexact flag: expected exact\n");
                        exit (1);
                      }
                  }
                else /* result is inexact */
                  {
                    if (!inexact)
                      {
                        printf ("Wrong inexact flag: expected inexact\n");
                        printf ("n=%u prec=%u\n", n, prec);
                        mpfr_print_binary(z); puts ("");
                        exit (1);
                      }
                  }
                if (mpfr_cmp (t, z))
                  {
                    printf ("results differ for x=");
                    mpfr_out_str (stdout, 2, prec, x, GMP_RNDN);
                    printf (" prec=%u rnd_mode=%s\n", prec,
                            mpfr_print_rnd_mode ((mp_rnd_t) rnd));
                    printf ("   got ");
                    mpfr_out_str (stdout, 2, prec, z, GMP_RNDN);
                    puts ("");
                    printf ("   expected ");
                    mpfr_out_str (stdout, 2, prec, t, GMP_RNDN);
                    puts ("");
                    printf ("   approximation was ");
                    mpfr_print_binary (y);
                    puts ("");
                    exit (1);
                  }
              }
          }
    }
Exemplo n.º 28
0
int main() {
  int32_t a;
  uint32_t b;
  void *c;

  a = 0; test_int(a);
  a = -1; test_int(a);
  a = 1; test_int(a);
  a = -2; test_int(a);
  a = 2; test_int(a);
  a = MAX_TAG_INT-2; test_int(a);
  a = MAX_TAG_INT-1; test_int(a);
  a = MAX_TAG_INT; test_int(a);
  a = MIN_TAG_INT+2; test_int(a);
  a = MIN_TAG_INT+1; test_int(a);
  a = MIN_TAG_INT; test_int(a);

  b = 0; test_uint(b);
  b = 1; test_uint(b);
  b = 2; test_uint(b);
  b = MAX_TAG_UINT-2; test_uint(b);
  b = MAX_TAG_UINT-1; test_uint(b);
  b = MAX_TAG_UINT; test_uint(b);

  c = NULL; test_ptr(c);
  c = (void *) &a; test_ptr(c);
  c = (void *) &b; test_ptr(c);
  c = (void *) &c; test_ptr(c);

  return 0;
}
Exemplo n.º 29
0
void core_sub() {
  env *e = prepare_env();
  test_int(e, "(- 1 1)", 0);
  test_int(e, "(- 4 (- 2 1))", 3);
  test_int(e, "(- (- 1 4) (- 4 2))", -5);
}
Exemplo n.º 30
0
static int
test_ints(void)
{
	plan(153);
	header();

	test_int(-0x01, "\xff", 1);
	test_int(-0x1e, "\xe2", 1);
	test_int(-0x1f, "\xe1", 1);
	test_int(-0x20, "\xe0", 1);
	test_int(-0x21, "\xd0\xdf", 2);

	test_int(-0x7f, "\xd0\x81", 2);
	test_int(-0x80, "\xd0\x80", 2);

	test_int(-0x81, "\xd1\xff\x7f", 3);
	test_int(-0x7fff, "\xd1\x80\x01", 3);
	test_int(-0x8000, "\xd1\x80\x00", 3);

	test_int(-0x8001, "\xd2\xff\xff\x7f\xff", 5);
	test_int(-0x7fffffff, "\xd2\x80\x00\x00\x01", 5);
	test_int(-0x80000000LL, "\xd2\x80\x00\x00\x00", 5);

	test_int(-0x80000001LL,
	     "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", 9);
	test_int(-0x80000001LL,
	     "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", 9);
	test_int(-0x7fffffffffffffffLL,
	     "\xd3\x80\x00\x00\x00\x00\x00\x00\x01", 9);
	test_int((int64_t)-0x8000000000000000LL,
	     "\xd3\x80\x00\x00\x00\x00\x00\x00\x00", 9);

	footer();
	return check_plan();
}