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

Unified Diff: test/JsValue.cpp

Issue 29812649: Issue 6526 - *ToV8String() return MaybeLocal<> and check Call() return value (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added tests. Renamed CHECKED_TO_LOCAL. Created July 11, 2018, 2:10 a.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
« src/Utils.h ('K') | « src/Utils.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
@@ -12,23 +12,32 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BaseJsTest.h"
+#include "../src/Utils.h"
+
namespace
{
class JsValueTest : public BaseJsTest
{
};
}
+TEST_F(JsValueTest, Checked)
+{
+ auto value = v8::MaybeLocal<bool>();
+ ASSERT_ANY_THROW(CHECKED_TO_LOCAL(GetJsEngine().GetIsolate(),
+ std::move(value)));
+}
+
TEST_F(JsValueTest, UndefinedValue)
{
auto value = GetJsEngine().Evaluate("undefined");
ASSERT_TRUE(value.IsUndefined());
ASSERT_FALSE(value.IsNull());
ASSERT_FALSE(value.IsString());
ASSERT_FALSE(value.IsBool());
ASSERT_FALSE(value.IsNumber());
@@ -156,16 +165,17 @@
ASSERT_EQ(2, value.GetProperty("x").AsInt());
value.SetProperty("x", 12);
ASSERT_EQ(12, value.GetProperty("x").AsInt());
value.SetProperty("x", GetJsEngine().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());
+ ASSERT_TRUE(value.GetProperty("bar").IsUndefined());
}
TEST_F(JsValueTest, ArrayValue)
{
auto value = GetJsEngine().Evaluate("[5,8,12]");
ASSERT_FALSE(value.IsUndefined());
ASSERT_FALSE(value.IsNull());
ASSERT_FALSE(value.IsString());
« src/Utils.h ('K') | « src/Utils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld