本文整理汇总了C++中Tuple::duplicate方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::duplicate方法的具体用法?C++ Tuple::duplicate怎么用?C++ Tuple::duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple::duplicate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_dup_ignores_singleton_class
void test_dup_ignores_singleton_class() {
Tuple* tup = Tuple::create(state, 1);
tup->put(state, 0, Qtrue);
// Force it to exist.
tup->singleton_class(state);
Tuple* tup2 = as<Tuple>(tup->duplicate(state));
TS_ASSERT(!try_as<SingletonClass>(tup2->klass_));
TS_ASSERT_DIFFERS(tup->singleton_class(state), tup2->singleton_class(state));
}
示例2: test_duplicate
void test_duplicate() {
Tuple* tup = Tuple::create(state, 1);
tup->put(state, 0, Qtrue);
tup->set_ivar(state, state->symbol("@name"), state->symbol("foo"));
Tuple* tup2 = as<Tuple>(tup->duplicate(state));
TS_ASSERT_EQUALS(tup2->at(state, 0), Qtrue);
TS_ASSERT_DIFFERS(tup->id(state), tup2->id(state));
TS_ASSERT(tup->ivars_ != tup2->ivars_);
TS_ASSERT_EQUALS(tup2->get_ivar(state, state->symbol("@name")),
state->symbol("foo"));
tup->ivars_ = as<CompactLookupTable>(tup->ivars_)->to_lookuptable(state);
Tuple* tup3 = as<Tuple>(tup->duplicate(state));
TS_ASSERT(tup->ivars_ != tup2->ivars_);
TS_ASSERT_EQUALS(tup3->get_ivar(state, state->symbol("@name")),
state->symbol("foo"));
}