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: Created April 19, 2017, 6:18 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
Index: test/JsEngine.cpp
===================================================================
--- a/test/JsEngine.cpp
+++ b/test/JsEngine.cpp
@@ -23,19 +23,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)
@@ -162,13 +162,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");
}
« include/AdblockPlus/JsValue.h ('K') | « test/GlobalJsObject.cpp ('k') | test/JsValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld