void test_find() {
    tbl->put(state, 2, Fixnum::from(1));
    tbl->put(state, 3, Fixnum::from(2));

    TS_ASSERT_EQUALS(tbl->fetch(state, Fixnum::from(1)), Fixnum::from(2));
    TS_ASSERT_EQUALS(tbl->fetch(state, Fixnum::from(2)), cNil);
  }
Beispiel #2
0
  void test_ivars() {
    Object* obj = util_new_object();

    Symbol* sym1 = state->symbol("@test1");
    Symbol* sym2 = state->symbol("@test2");
    Fixnum* one = Fixnum::from(1);
    Fixnum* two = Fixnum::from(2);
    obj->set_ivar(state, sym1, one);
    obj->set_ivar(state, sym2, two);

    CompactLookupTable* ivars = (CompactLookupTable*)obj->ivars();

    TS_ASSERT_EQUALS(ivars->fetch(state, sym1), one);
    TS_ASSERT_EQUALS(ivars->fetch(state, sym2), two);
  }