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

Side by Side Diff: test/JsValue.cpp

Issue 29410664: Issue 5013 - Use const JsValue and pass reference where applicable (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created April 12, 2017, 3:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 ASSERT_TRUE(value->IsObject()); 149 ASSERT_TRUE(value->IsObject());
150 ASSERT_FALSE(value->IsArray()); 150 ASSERT_FALSE(value->IsArray());
151 ASSERT_FALSE(value->IsFunction()); 151 ASSERT_FALSE(value->IsFunction());
152 ASSERT_EQ("foo", value->AsString()); 152 ASSERT_EQ("foo", value->AsString());
153 ASSERT_EQ(123, value->AsInt()); 153 ASSERT_EQ(123, value->AsInt());
154 ASSERT_TRUE(value->AsBool()); 154 ASSERT_TRUE(value->AsBool());
155 ASSERT_ANY_THROW(value->AsList()); 155 ASSERT_ANY_THROW(value->AsList());
156 ASSERT_EQ(2, value->GetProperty("x")->AsInt()); 156 ASSERT_EQ(2, value->GetProperty("x")->AsInt());
157 value->SetProperty("x", 12); 157 value->SetProperty("x", 12);
158 ASSERT_EQ(12, value->GetProperty("x")->AsInt()); 158 ASSERT_EQ(12, value->GetProperty("x")->AsInt());
159 value->SetProperty("x", jsEngine->NewValue(15)); 159 value->SetProperty("x", *jsEngine->NewValue(15));
160 ASSERT_EQ(15, value->GetProperty("x")->AsInt()); 160 ASSERT_EQ(15, value->GetProperty("x")->AsInt());
161 ASSERT_EQ("Foo", value->GetClass()); 161 ASSERT_EQ("Foo", value->GetClass());
162 ASSERT_EQ(3u, value->GetOwnPropertyNames().size()); 162 ASSERT_EQ(3u, value->GetOwnPropertyNames().size());
163 ASSERT_ANY_THROW(value->Call()); 163 ASSERT_ANY_THROW(value->Call());
164 } 164 }
165 165
166 TEST_F(JsValueTest, ArrayValue) 166 TEST_F(JsValueTest, ArrayValue)
167 { 167 {
168 AdblockPlus::JsValuePtr value = jsEngine->Evaluate("[5,8,12]"); 168 AdblockPlus::JsValuePtr value = jsEngine->Evaluate("[5,8,12]");
169 ASSERT_FALSE(value->IsUndefined()); 169 ASSERT_FALSE(value->IsUndefined());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 const std::string source("\ 216 const std::string source("\
217 function Foo() {\ 217 function Foo() {\
218 this.toString = function() {throw 'test1';};\ 218 this.toString = function() {throw 'test1';};\
219 this.valueOf = function() {throw 'test2';};\ 219 this.valueOf = function() {throw 'test2';};\
220 };\ 220 };\
221 new Foo()"); 221 new Foo()");
222 AdblockPlus::JsValuePtr value = jsEngine->Evaluate(source); 222 AdblockPlus::JsValuePtr value = jsEngine->Evaluate(source);
223 ASSERT_EQ("", value->AsString()); 223 ASSERT_EQ("", value->AsString());
224 ASSERT_EQ(0, value->AsInt()); 224 ASSERT_EQ(0, value->AsInt());
225 } 225 }
OLDNEW
« src/FilterEngine.cpp ('K') | « test/JsEngine.cpp ('k') | test/UpdateCheck.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld