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

Unified Diff: test/JsEngine.cpp

Issue 10213003: Make JsEngine::Evaluate() return a wrapper for v8::Value to accessdifferent variable types easily (Closed)
Patch Set: Extended JsValue API to support all FilterEngine functions Created April 13, 2013, 8:42 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/WebRequest.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
@@ -45,28 +45,30 @@ public:
TEST(JsEngineTest, EvaluateAndCall)
{
ThrowingFileReader fileReader;
ThrowingErrorCallback errorCallback;
AdblockPlus::JsEngine jsEngine(&fileReader, 0, &errorCallback);
const std::string source = "function hello() { return 'Hello'; }";
jsEngine.Evaluate(source);
- const std::string result = jsEngine.Evaluate("hello()");
- ASSERT_EQ("Hello", result);
+ AdblockPlus::JsValuePtr result = jsEngine.Evaluate("hello()");
+ ASSERT_EQ(true, result->IsString());
+ ASSERT_EQ("Hello", result->AsString());
}
TEST(JsEngineTest, LoadAndCall)
{
StubFileReader fileReader;
ThrowingErrorCallback errorCallback;
AdblockPlus::JsEngine jsEngine(&fileReader, 0, &errorCallback);
jsEngine.Load("hello.js");
- const std::string result = jsEngine.Evaluate("hello()");
- ASSERT_EQ("Hello", result);
+ AdblockPlus::JsValuePtr result = jsEngine.Evaluate("hello()");
+ ASSERT_EQ(true, result->IsString());
+ ASSERT_EQ("Hello", result->AsString());
}
TEST(JsEngineTest, LoadBadStreamFails)
{
BadFileReader fileReader;
ThrowingErrorCallback errorCallback;
AdblockPlus::JsEngine jsEngine(&fileReader, 0, &errorCallback);
ASSERT_ANY_THROW(jsEngine.Load("hello.js"));
« no previous file with comments | « test/GlobalJsObject.cpp ('k') | test/WebRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld