Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/JsValue.cpp

Issue 29416579: Issue 5034 - Part 1: Pass a JsValue directly to SetProperty() and return from GetProperty() (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Remove JsValue test Created April 19, 2017, 2:46 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/JsEngine.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/JsValue.cpp
===================================================================
--- a/test/JsValue.cpp
+++ b/test/JsValue.cpp
@@ -148,21 +148,21 @@
ASSERT_FALSE(value->IsNumber());
ASSERT_TRUE(value->IsObject());
ASSERT_FALSE(value->IsArray());
ASSERT_FALSE(value->IsFunction());
ASSERT_EQ("foo", value->AsString());
ASSERT_EQ(123, value->AsInt());
ASSERT_TRUE(value->AsBool());
ASSERT_ANY_THROW(value->AsList());
- ASSERT_EQ(2, value->GetProperty("x")->AsInt());
+ ASSERT_EQ(2, value->GetProperty("x").AsInt());
value->SetProperty("x", 12);
- ASSERT_EQ(12, value->GetProperty("x")->AsInt());
- value->SetProperty("x", jsEngine->NewValue(15));
- ASSERT_EQ(15, value->GetProperty("x")->AsInt());
+ ASSERT_EQ(12, value->GetProperty("x").AsInt());
+ value->SetProperty("x", *jsEngine->NewValue(15));
+ ASSERT_EQ(15, value->GetProperty("x").AsInt());
ASSERT_EQ("Foo", value->GetClass());
ASSERT_EQ(3u, value->GetOwnPropertyNames().size());
ASSERT_ANY_THROW(value->Call());
}
TEST_F(JsValueTest, ArrayValue)
{
AdblockPlus::JsValuePtr value = jsEngine->Evaluate("[5,8,12]");
@@ -173,17 +173,17 @@
ASSERT_FALSE(value->IsNumber());
ASSERT_TRUE(value->IsObject());
ASSERT_TRUE(value->IsArray());
ASSERT_FALSE(value->IsFunction());
ASSERT_EQ("5,8,12", value->AsString());
ASSERT_TRUE(value->AsBool());
ASSERT_EQ(3u, value->AsList().size());
ASSERT_EQ(8, value->AsList()[1]->AsInt());
- ASSERT_EQ(3, value->GetProperty("length")->AsInt());
+ ASSERT_EQ(3, value->GetProperty("length").AsInt());
ASSERT_EQ("Array", value->GetClass());
ASSERT_ANY_THROW(value->Call());
}
TEST_F(JsValueTest, FunctionValue)
{
AdblockPlus::JsValuePtr value = jsEngine->Evaluate("(function(foo, bar) {return this.x + '/' + foo + '/' + bar;})");
ASSERT_FALSE(value->IsUndefined());
@@ -191,17 +191,17 @@
ASSERT_FALSE(value->IsString());
ASSERT_FALSE(value->IsBool());
ASSERT_FALSE(value->IsNumber());
ASSERT_TRUE(value->IsObject());
ASSERT_FALSE(value->IsArray());
ASSERT_TRUE(value->IsFunction());
ASSERT_TRUE(value->AsBool());
ASSERT_ANY_THROW(value->AsList());
- ASSERT_EQ(2, value->GetProperty("length")->AsInt());
+ ASSERT_EQ(2, value->GetProperty("length").AsInt());
AdblockPlus::JsValuePtr thisPtr = jsEngine->Evaluate("({x:2})");
AdblockPlus::JsConstValueList params;
params.push_back(jsEngine->NewValue(5));
params.push_back(jsEngine->NewValue("xyz"));
ASSERT_EQ("2/5/xyz", value->Call(params, thisPtr).AsString());
}
« no previous file with comments | « test/JsEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld