Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: test/unittests/value-serializer-unittest.cc

Issue 2646553002: Fix unused lambda captures. (Closed)
Patch Set: Add a workaround for MSVC++. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/unittests/heap/slot-set-unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/value-serializer.h" 5 #include "src/value-serializer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "include/v8.h" 10 #include "include/v8.h"
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 [this](Local<Value> value) { 1171 [this](Local<Value> value) {
1172 ASSERT_TRUE(value->IsArray()); 1172 ASSERT_TRUE(value->IsArray());
1173 ASSERT_EQ(1000u, Array::Cast(*value)->Length()); 1173 ASSERT_EQ(1000u, Array::Cast(*value)->Length());
1174 EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)")); 1174 EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)"));
1175 }); 1175 });
1176 } 1176 }
1177 1177
1178 TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) { 1178 TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) {
1179 // Empty (sparse) array. 1179 // Empty (sparse) array.
1180 DecodeTestForVersion0({0x40, 0x00, 0x00, 0x00}, 1180 DecodeTestForVersion0({0x40, 0x00, 0x00, 0x00},
1181 [this](Local<Value> value) { 1181 [](Local<Value> value) {
1182 ASSERT_TRUE(value->IsArray()); 1182 ASSERT_TRUE(value->IsArray());
1183 ASSERT_EQ(0u, Array::Cast(*value)->Length()); 1183 ASSERT_EQ(0u, Array::Cast(*value)->Length());
1184 }); 1184 });
1185 // Sparse array with a mixture of elements and properties. 1185 // Sparse array with a mixture of elements and properties.
1186 DecodeTestForVersion0( 1186 DecodeTestForVersion0(
1187 {0x55, 0x00, 0x53, 0x01, 'a', 0x55, 0x02, 0x55, 0x05, 0x53, 1187 {0x55, 0x00, 0x53, 0x01, 'a', 0x55, 0x02, 0x55, 0x05, 0x53,
1188 0x03, 'f', 'o', 'o', 0x53, 0x03, 'b', 'a', 'r', 0x53, 1188 0x03, 'f', 'o', 'o', 0x53, 0x03, 'b', 'a', 'r', 0x53,
1189 0x03, 'b', 'a', 'z', 0x49, 0x0b, 0x40, 0x04, 0x03, 0x00}, 1189 0x03, 'b', 'a', 'z', 0x49, 0x0b, 0x40, 0x04, 0x03, 0x00},
1190 [this](Local<Value> value) { 1190 [this](Local<Value> value) {
1191 ASSERT_TRUE(value->IsArray()); 1191 ASSERT_TRUE(value->IsArray());
(...skipping 11 matching lines...) Expand all
1203 ASSERT_TRUE(value->IsArray()); 1203 ASSERT_TRUE(value->IsArray());
1204 EXPECT_EQ(2u, Array::Cast(*value)->Length()); 1204 EXPECT_EQ(2u, Array::Cast(*value)->Length());
1205 EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result)")); 1205 EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result)"));
1206 EXPECT_TRUE(EvaluateScriptForResultBool("result[1] instanceof Array")); 1206 EXPECT_TRUE(EvaluateScriptForResultBool("result[1] instanceof Array"));
1207 EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result[1])")); 1207 EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result[1])"));
1208 EXPECT_TRUE(EvaluateScriptForResultBool("result[1][1] === true")); 1208 EXPECT_TRUE(EvaluateScriptForResultBool("result[1][1] === true"));
1209 }); 1209 });
1210 } 1210 }
1211 1211
1212 TEST_F(ValueSerializerTest, RoundTripDate) { 1212 TEST_F(ValueSerializerTest, RoundTripDate) {
1213 RoundTripTest("new Date(1e6)", [this](Local<Value> value) { 1213 RoundTripTest("new Date(1e6)", [](Local<Value> value) {
1214 ASSERT_TRUE(value->IsDate()); 1214 ASSERT_TRUE(value->IsDate());
1215 EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); 1215 EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf());
1216 EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); 1216 EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype");
1217 }); 1217 });
1218 RoundTripTest("new Date(Date.UTC(1867, 6, 1))", [this](Local<Value> value) { 1218 RoundTripTest("new Date(Date.UTC(1867, 6, 1))", [](Local<Value> value) {
1219 ASSERT_TRUE(value->IsDate()); 1219 ASSERT_TRUE(value->IsDate());
1220 EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'"); 1220 EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'");
1221 }); 1221 });
1222 RoundTripTest("new Date(NaN)", [this](Local<Value> value) { 1222 RoundTripTest("new Date(NaN)", [](Local<Value> value) {
1223 ASSERT_TRUE(value->IsDate()); 1223 ASSERT_TRUE(value->IsDate());
1224 EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); 1224 EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf()));
1225 }); 1225 });
1226 RoundTripTest( 1226 RoundTripTest(
1227 "({ a: new Date(), get b() { return this.a; } })", 1227 "({ a: new Date(), get b() { return this.a; } })",
1228 [this](Local<Value> value) { 1228 [this](Local<Value> value) {
1229 EXPECT_TRUE(EvaluateScriptForResultBool("result.a instanceof Date")); 1229 EXPECT_TRUE(EvaluateScriptForResultBool("result.a instanceof Date"));
1230 EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b")); 1230 EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b"));
1231 }); 1231 });
1232 } 1232 }
1233 1233
1234 TEST_F(ValueSerializerTest, DecodeDate) { 1234 TEST_F(ValueSerializerTest, DecodeDate) {
1235 #if defined(V8_TARGET_LITTLE_ENDIAN) 1235 #if defined(V8_TARGET_LITTLE_ENDIAN)
1236 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x80, 0x84, 1236 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x80, 0x84,
1237 0x2e, 0x41, 0x00}, 1237 0x2e, 0x41, 0x00},
1238 [this](Local<Value> value) { 1238 [](Local<Value> value) {
1239 ASSERT_TRUE(value->IsDate()); 1239 ASSERT_TRUE(value->IsDate());
1240 EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); 1240 EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf());
1241 EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); 1241 EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype");
1242 }); 1242 });
1243 DecodeTest( 1243 DecodeTest(
1244 {0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x20, 0x45, 0x27, 0x89, 0x87, 1244 {0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x20, 0x45, 0x27, 0x89, 0x87,
1245 0xc2, 0x00}, 1245 0xc2, 0x00},
1246 [this](Local<Value> value) { 1246 [](Local<Value> value) {
1247 ASSERT_TRUE(value->IsDate()); 1247 ASSERT_TRUE(value->IsDate());
1248 EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'"); 1248 EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'");
1249 }); 1249 });
1250 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1250 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1251 0xf8, 0x7f, 0x00}, 1251 0xf8, 0x7f, 0x00},
1252 [this](Local<Value> value) { 1252 [](Local<Value> value) {
1253 ASSERT_TRUE(value->IsDate()); 1253 ASSERT_TRUE(value->IsDate());
1254 EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); 1254 EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf()));
1255 }); 1255 });
1256 #else 1256 #else
1257 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x41, 0x2e, 0x84, 0x80, 0x00, 0x00, 1257 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x41, 0x2e, 0x84, 0x80, 0x00, 0x00,
1258 0x00, 0x00, 0x00}, 1258 0x00, 0x00, 0x00},
1259 [this](Local<Value> value) { 1259 [this](Local<Value> value) {
1260 ASSERT_TRUE(value->IsDate()); 1260 ASSERT_TRUE(value->IsDate());
1261 EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); 1261 EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf());
1262 EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); 1262 EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype");
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 InvalidDecodeTest(raw); 2566 InvalidDecodeTest(raw);
2567 } 2567 }
2568 2568
2569 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) { 2569 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) {
2570 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00}); 2570 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00});
2571 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f}); 2571 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f});
2572 } 2572 }
2573 2573
2574 } // namespace 2574 } // namespace
2575 } // namespace v8 2575 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/heap/slot-set-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698