Пример #1
0
  void test_is_number() {
    ConfigParser::Entry* ent = new ConfigParser::Entry();
    ent->value = std::string("blah");

    TS_ASSERT(!ent->is_number());

    ent->value = std::string("8");

    TS_ASSERT(ent->is_number());

    ent->value = std::string("-8");

    TS_ASSERT(ent->is_number());
  }
Пример #2
0
  Object* System::vm_get_config_item(STATE, String* var) {
    ConfigParser::Entry* ent = state->user_config->find(var->c_str());
    if(!ent) return Qnil;

    if(ent->is_number()) {
      return Fixnum::from(atoi(ent->value.c_str()));
    }
    return String::create(state, ent->value.c_str());
  }
Пример #3
0
  Object* System::vm_get_config_item(STATE, String* var) {
    ConfigParser::Entry* ent = state->shared.user_variables.find(var->c_str(state));
    if(!ent) return Qnil;

    if(ent->is_number()) {
      return Bignum::from_string(state, ent->value.c_str(), 10);
    } else if(ent->is_true()) {
      return Qtrue;
    }

    return String::create(state, ent->value.c_str());
  }