本文整理汇总了C++中Fixnum::coerce方法的典型用法代码示例。如果您正苦于以下问题:C++ Fixnum::coerce方法的具体用法?C++ Fixnum::coerce怎么用?C++ Fixnum::coerce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fixnum
的用法示例。
在下文中一共展示了Fixnum::coerce方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_coerce_bignum
void test_coerce_bignum() {
Fixnum* one = Fixnum::from(1);
Bignum* e = Bignum::create(state, one);
Array* ary = one->coerce(state, e);
Fixnum* a = try_as<Fixnum>(ary->get(state, 0));
Fixnum* b = try_as<Fixnum>(ary->get(state, 1));
TS_ASSERT_EQUALS(2, ary->size());
TS_ASSERT(a);
TS_ASSERT(b);
TS_ASSERT_EQUALS(one, a);
TS_ASSERT_EQUALS(one, b);
Bignum* f = Bignum::from(state, 9223372036854775807LL);
ary = one->coerce(state, f);
Bignum* c = try_as<Bignum>(ary->get(state, 0));
Bignum* d = try_as<Bignum>(ary->get(state, 1));
TS_ASSERT_EQUALS(2, ary->size());
TS_ASSERT(c);
TS_ASSERT(d);
TS_ASSERT_EQUALS(cTrue, c->equal(state, f));
TS_ASSERT_EQUALS(cTrue, d->equal(state, e));
}
示例2: test_coerce_fixnum
void test_coerce_fixnum() {
Fixnum* one = Fixnum::from(1);
Fixnum* two = Fixnum::from(2);
Array* ary = one->coerce(state, two);
Fixnum* a = try_as<Fixnum>(ary->get(state, 0));
Fixnum* b = try_as<Fixnum>(ary->get(state, 1));
TS_ASSERT_EQUALS(2, ary->size());
TS_ASSERT(a);
TS_ASSERT(b);
TS_ASSERT_EQUALS(two, a);
TS_ASSERT_EQUALS(one, b);
}