Exemplo n.º 1
0
void PrefsCommand::operator()(const std::string& arguments)
{
    std::istringstream argumentStream(arguments);
    std::string action;
    argumentStream >> action;
    if (!action.size())
    {
        ShowUsage();
        return;
    }

    if (action == "show")
    {
        std::string pref;
        argumentStream >> pref;

        AdblockPlus::JsValuePtr value = filterEngine.GetPref(pref);
        if (value->IsUndefined())
            std::cout << "No such preference" << std::endl;
        else
        {
            if (value->IsString())
                std::cout << "(string) ";
            else if (value->IsNumber())
                std::cout << "(number) ";
            else if (value->IsBool())
                std::cout << "(bool) ";
            else
                std::cout << "(unknown type) ";
            std::cout << value->AsString() << std::endl;
        }
    }
Exemplo n.º 2
0
TEST_F(JsValueTest, NullValue)
{
  AdblockPlus::JsValuePtr value = jsEngine->Evaluate("null");
  ASSERT_FALSE(value->IsUndefined());
  ASSERT_TRUE(value->IsNull());
  ASSERT_FALSE(value->IsString());
  ASSERT_FALSE(value->IsBool());
  ASSERT_FALSE(value->IsNumber());
  ASSERT_FALSE(value->IsObject());
  ASSERT_FALSE(value->IsArray());
  ASSERT_FALSE(value->IsFunction());
  ASSERT_EQ("null", value->AsString());
  ASSERT_FALSE(value->AsBool());
  ASSERT_ANY_THROW(value->AsList());
  ASSERT_ANY_THROW(value->GetProperty("foo"));
  ASSERT_ANY_THROW(value->SetProperty("foo", false));
  ASSERT_ANY_THROW(value->GetClass());
  ASSERT_ANY_THROW(value->GetOwnPropertyNames());
  ASSERT_ANY_THROW(value->Call());
}