| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_message.h" | 10 #include "vm/dart_api_message.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 Dart_CObject* root = api_reader.ReadMessage(); | 226 Dart_CObject* root = api_reader.ReadMessage(); |
| 227 EXPECT_NOTNULL(root); | 227 EXPECT_NOTNULL(root); |
| 228 CheckEncodeDecodeMessage(root); | 228 CheckEncodeDecodeMessage(root); |
| 229 return root; | 229 return root; |
| 230 } | 230 } |
| 231 | 231 |
| 232 | 232 |
| 233 void CheckMint(int64_t value) { | 233 void CheckMint(int64_t value) { |
| 234 StackZone zone(Isolate::Current()); | 234 StackZone zone(Isolate::Current()); |
| 235 | 235 |
| 236 const Mint& mint = Mint::Handle(Mint::New(value)); | 236 Mint& mint = Mint::Handle(); |
| 237 mint ^= Integer::New(value); |
| 237 ApiNativeScope scope; | 238 ApiNativeScope scope; |
| 238 Dart_CObject* mint_cobject = SerializeAndDeserializeMint(mint); | 239 Dart_CObject* mint_cobject = SerializeAndDeserializeMint(mint); |
| 239 // On 64-bit platforms mints always require 64-bits as the smi range | 240 // On 64-bit platforms mints always require 64-bits as the smi range |
| 240 // here covers most of the 64-bit range. On 32-bit platforms the smi | 241 // here covers most of the 64-bit range. On 32-bit platforms the smi |
| 241 // range covers most of the 32-bit range and values outside that | 242 // range covers most of the 32-bit range and values outside that |
| 242 // range are also represented as mints. | 243 // range are also represented as mints. |
| 243 #if defined(ARCH_IS_64_BIT) | 244 #if defined(ARCH_IS_64_BIT) |
| 244 EXPECT_EQ(Dart_CObject::kInt64, mint_cobject->type); | 245 EXPECT_EQ(Dart_CObject::kInt64, mint_cobject->type); |
| 245 EXPECT_EQ(value, mint_cobject->value.as_int64); | 246 EXPECT_EQ(value, mint_cobject->value.as_int64); |
| 246 #else | 247 #else |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 365 |
| 365 | 366 |
| 366 TEST_CASE(SerializeBigint) { | 367 TEST_CASE(SerializeBigint) { |
| 367 StackZone zone(Isolate::Current()); | 368 StackZone zone(Isolate::Current()); |
| 368 | 369 |
| 369 // Write snapshot with object content. | 370 // Write snapshot with object content. |
| 370 uint8_t* buffer; | 371 uint8_t* buffer; |
| 371 MessageWriter writer(&buffer, &zone_allocator); | 372 MessageWriter writer(&buffer, &zone_allocator); |
| 372 const char* cstr = "0x270FFFFFFFFFFFFFD8F0"; | 373 const char* cstr = "0x270FFFFFFFFFFFFFD8F0"; |
| 373 const String& str = String::Handle(String::New(cstr)); | 374 const String& str = String::Handle(String::New(cstr)); |
| 374 const Bigint& bigint = Bigint::Handle(Bigint::NewCanonical(str)); | 375 Bigint& bigint = Bigint::Handle(); |
| 376 bigint ^= Integer::NewCanonical(str); |
| 375 writer.WriteMessage(bigint); | 377 writer.WriteMessage(bigint); |
| 376 intptr_t buffer_len = writer.BytesWritten(); | 378 intptr_t buffer_len = writer.BytesWritten(); |
| 377 | 379 |
| 378 // Read object back from the snapshot. | 380 // Read object back from the snapshot. |
| 379 SnapshotReader reader(buffer, buffer_len, | 381 SnapshotReader reader(buffer, buffer_len, |
| 380 Snapshot::kMessage, Isolate::Current()); | 382 Snapshot::kMessage, Isolate::Current()); |
| 381 Bigint& obj = Bigint::Handle(); | 383 Bigint& obj = Bigint::Handle(); |
| 382 obj ^= reader.ReadObject(); | 384 obj ^= reader.ReadObject(); |
| 383 | 385 |
| 384 EXPECT_STREQ(BigintOperations::ToHexCString(bigint, &allocator), | 386 EXPECT_STREQ(BigintOperations::ToHexCString(bigint, &allocator), |
| (...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2486 result = Dart_RunLoop(); | 2488 result = Dart_RunLoop(); |
| 2487 EXPECT(Dart_IsError(result)); | 2489 EXPECT(Dart_IsError(result)); |
| 2488 EXPECT(Dart_ErrorHasException(result)); | 2490 EXPECT(Dart_ErrorHasException(result)); |
| 2489 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2491 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", |
| 2490 Dart_GetError(result)); | 2492 Dart_GetError(result)); |
| 2491 | 2493 |
| 2492 Dart_ExitScope(); | 2494 Dart_ExitScope(); |
| 2493 } | 2495 } |
| 2494 | 2496 |
| 2495 } // namespace dart | 2497 } // namespace dart |
| OLD | NEW |