示例#1
0
  void test_add_overflows_to_bignum() {
    Fixnum* max = Fixnum::from(FIXNUM_MAX);
    Integer* max_plus1 = max->add(state, Fixnum::from(1));

    TS_ASSERT(kind_of<Bignum>(max_plus1));
    TS_ASSERT_EQUALS(FIXNUM_MAX+1, max_plus1->to_native());
  }
示例#2
0
  void test_add_underflows_to_bignum() {
    Fixnum*  min = Fixnum::from(FIXNUM_MIN);
    Integer* min_minus1 = min->add(state, Fixnum::from(-1));

    TS_ASSERT(kind_of<Bignum>(min_minus1));
    TS_ASSERT_EQUALS(FIXNUM_MIN-1, min_minus1->to_native());
  }
示例#3
0
  void test_add() {
    Fixnum* one = Fixnum::from(1);
    Fixnum* two = as<Fixnum>(one->add(state, one));

    TS_ASSERT_EQUALS(Fixnum::from(2), two);
    TS_ASSERT_EQUALS(2, two->to_native());
  }
示例#4
0
  void test_add_a_bignum() {
    Fixnum* one  = Fixnum::from(13);
    Bignum* obj = Bignum::from(state, (native_int)FIXNUM_MAX - 10);
    Integer* res = one->add(state, obj);

    TS_ASSERT(kind_of<Bignum>(res));
    TS_ASSERT_EQUALS(res->to_native(), FIXNUM_MAX + 3);
  }
示例#5
0
 void test_add_a_float() {
   Fixnum* one = Fixnum::from(13);
   Float* res = one->add(state, Float::create(state, 1.4));
   check_float(res, Float::create(state, 14.4));
 }