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

Unified Diff: test/JsEngine.cpp

Issue 29417624: Issue 5034 - Part 4: JsEngine::Evaluate() return a JsValue (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Rebased again Created April 20, 2017, 1:02 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/GlobalJsObject.cpp ('k') | test/JsValue.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/JsEngine.cpp
===================================================================
--- a/test/JsEngine.cpp
+++ b/test/JsEngine.cpp
@@ -24,19 +24,19 @@
class JsEngineTest : public BaseJsTest
{
};
}
TEST_F(JsEngineTest, Evaluate)
{
jsEngine->Evaluate("function hello() { return 'Hello'; }");
- AdblockPlus::JsValuePtr result = jsEngine->Evaluate("hello()");
- ASSERT_TRUE(result->IsString());
- ASSERT_EQ("Hello", result->AsString());
+ auto result = jsEngine->Evaluate("hello()");
+ ASSERT_TRUE(result.IsString());
+ ASSERT_EQ("Hello", result.AsString());
}
TEST_F(JsEngineTest, RuntimeExceptionIsThrown)
{
ASSERT_THROW(jsEngine->Evaluate("doesnotexist()"), std::runtime_error);
}
TEST_F(JsEngineTest, CompileTimeExceptionIsThrown)
@@ -66,17 +66,17 @@
namespace {
bool IsSame(AdblockPlus::JsEngine& jsEngine,
const AdblockPlus::JsValue& v1, const AdblockPlus::JsValue& v2)
{
AdblockPlus::JsValueList params;
params.push_back(v1);
params.push_back(v2);
- return jsEngine.Evaluate("f = function(a, b) { return a == b };")->Call(params).AsBool();
+ return jsEngine.Evaluate("f = function(a, b) { return a == b };").Call(params).AsBool();
}
}
TEST_F(JsEngineTest, ValueCopy)
{
{
auto value = jsEngine->NewValue("foo");
@@ -184,13 +184,13 @@
jsEngine->SetWebRequest(webRequest);
ASSERT_EQ(webRequest, jsEngine->GetWebRequest());
}
TEST(NewJsEngineTest, GlobalPropertyTest)
{
AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New());
jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar"));
- AdblockPlus::JsValuePtr foo = jsEngine->Evaluate("foo");
- ASSERT_TRUE(foo->IsString());
- ASSERT_EQ(foo->AsString(), "bar");
+ auto foo = jsEngine->Evaluate("foo");
+ ASSERT_TRUE(foo.IsString());
+ ASSERT_EQ(foo.AsString(), "bar");
}
« no previous file with comments | « test/GlobalJsObject.cpp ('k') | test/JsValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld