OLD | NEW |
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 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 }); | 1330 }); |
1331 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1331 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
1332 0xf8, 0x7f, 0x00}, | 1332 0xf8, 0x7f, 0x00}, |
1333 [](Local<Value> value) { | 1333 [](Local<Value> value) { |
1334 ASSERT_TRUE(value->IsDate()); | 1334 ASSERT_TRUE(value->IsDate()); |
1335 EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); | 1335 EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); |
1336 }); | 1336 }); |
1337 #else | 1337 #else |
1338 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x41, 0x2e, 0x84, 0x80, 0x00, 0x00, | 1338 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x41, 0x2e, 0x84, 0x80, 0x00, 0x00, |
1339 0x00, 0x00, 0x00}, | 1339 0x00, 0x00, 0x00}, |
1340 [this](Local<Value> value) { | 1340 [](Local<Value> value) { |
1341 ASSERT_TRUE(value->IsDate()); | 1341 ASSERT_TRUE(value->IsDate()); |
1342 EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); | 1342 EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); |
1343 EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); | 1343 EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); |
1344 }); | 1344 }); |
1345 DecodeTest( | 1345 DecodeTest( |
1346 {0xff, 0x09, 0x3f, 0x00, 0x44, 0xc2, 0x87, 0x89, 0x27, 0x45, 0x20, 0x00, | 1346 {0xff, 0x09, 0x3f, 0x00, 0x44, 0xc2, 0x87, 0x89, 0x27, 0x45, 0x20, 0x00, |
1347 0x00, 0x00}, | 1347 0x00, 0x00}, |
1348 [this](Local<Value> value) { | 1348 [](Local<Value> value) { |
1349 ASSERT_TRUE(value->IsDate()); | 1349 ASSERT_TRUE(value->IsDate()); |
1350 EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'"); | 1350 EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'"); |
1351 }); | 1351 }); |
1352 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, | 1352 DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, |
1353 0x00, 0x00, 0x00}, | 1353 0x00, 0x00, 0x00}, |
1354 [this](Local<Value> value) { | 1354 [](Local<Value> value) { |
1355 ASSERT_TRUE(value->IsDate()); | 1355 ASSERT_TRUE(value->IsDate()); |
1356 EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); | 1356 EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); |
1357 }); | 1357 }); |
1358 #endif | 1358 #endif |
1359 DecodeTest( | 1359 DecodeTest( |
1360 {0xff, 0x09, 0x3f, 0x00, 0x6f, 0x3f, 0x01, 0x53, 0x01, 0x61, 0x3f, | 1360 {0xff, 0x09, 0x3f, 0x00, 0x6f, 0x3f, 0x01, 0x53, 0x01, 0x61, 0x3f, |
1361 0x01, 0x44, 0x00, 0x20, 0x39, 0x50, 0x37, 0x6a, 0x75, 0x42, 0x3f, | 1361 0x01, 0x44, 0x00, 0x20, 0x39, 0x50, 0x37, 0x6a, 0x75, 0x42, 0x3f, |
1362 0x02, 0x53, 0x01, 0x62, 0x3f, 0x02, 0x5e, 0x01, 0x7b, 0x02}, | 1362 0x02, 0x53, 0x01, 0x62, 0x3f, 0x02, 0x5e, 0x01, 0x7b, 0x02}, |
1363 [this](Local<Value> value) { | 1363 [this](Local<Value> value) { |
1364 EXPECT_TRUE(EvaluateScriptForResultBool("result.a instanceof Date")); | 1364 EXPECT_TRUE(EvaluateScriptForResultBool("result.a instanceof Date")); |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2744 InvalidDecodeTest(raw); | 2744 InvalidDecodeTest(raw); |
2745 } | 2745 } |
2746 | 2746 |
2747 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) { | 2747 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) { |
2748 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00}); | 2748 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00}); |
2749 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f}); | 2749 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f}); |
2750 } | 2750 } |
2751 | 2751 |
2752 } // namespace | 2752 } // namespace |
2753 } // namespace v8 | 2753 } // namespace v8 |
OLD | NEW |