Beispiel #1
0
  void test_delete_inplace() {
    Tuple *tuple = new_tuple();

    tuple->put(state, 1, Qnil);
    Integer *count = tuple->delete_inplace(state, Fixnum::from(0), Fixnum::from(3), Qnil);

    TS_ASSERT_EQUALS(1, count->to_native());
    TS_ASSERT_EQUALS(Fixnum::from(1), as<Fixnum>(tuple->at(state, 0)));
    TS_ASSERT_EQUALS(Fixnum::from(9), as<Fixnum>(tuple->at(state, 1)));
    TS_ASSERT_EQUALS(Qnil, tuple->at(state, 2));
  }
Beispiel #2
0
  void test_delete_inplace_bounds() {
    Tuple *tuple = new_tuple();

    Integer *count;
    TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(0), Fixnum::from(4), Qnil),
			    const RubyException &e,
			    TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
    TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(1), Fixnum::from(3), Qnil),
			    const RubyException &e,
			    TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
    TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(-1), Fixnum::from(3), Qnil),
			    const RubyException &e,
			    TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
    TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(0), Fixnum::from(-1), Qnil),
			    const RubyException &e,
			    TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
    TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(3), Fixnum::from(1), Qnil),
			    const RubyException &e,
			    TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
  }
Beispiel #3
0
  void Module::Info::mark(Object* obj, ObjectMark& mark) {
    auto_mark(obj, mark);

    Array* subclasses = as<Module>(obj)->hierarchy_subclasses_;
    if(subclasses->nil_p()) return;

    native_int offset = subclasses->offset();
    native_int size = subclasses->size();
    Tuple* tup = subclasses->tuple();

    for(native_int i = offset; i < size + offset; ++i) {
      if(WeakRef* ref = try_as<WeakRef>(tup->field[i])) {
        if(!ref->alive_p()) {
          tup->field[i] = cNil;
        }
      }
    }
    subclasses->set_size(size - tup->delete_inplace(offset, size, cNil));
  }