| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/bigint_operations.h" | |
| 9 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 11 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| 12 #include "vm/debugger.h" | 11 #include "vm/debugger.h" |
| 13 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
| 14 #include "vm/object.h" | 13 #include "vm/object.h" |
| 15 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 16 #include "vm/simulator.h" | 15 #include "vm/simulator.h" |
| 17 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
| 18 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 338 |
| 340 Mint& mint1 = Mint::Handle(); | 339 Mint& mint1 = Mint::Handle(); |
| 341 mint1 ^= Integer::New(DART_2PART_UINT64_C(0x7FFFFFFF, 100)); | 340 mint1 ^= Integer::New(DART_2PART_UINT64_C(0x7FFFFFFF, 100)); |
| 342 Mint& mint2 = Mint::Handle(); | 341 Mint& mint2 = Mint::Handle(); |
| 343 mint2 ^= Integer::New(-DART_2PART_UINT64_C(0x7FFFFFFF, 100)); | 342 mint2 ^= Integer::New(-DART_2PART_UINT64_C(0x7FFFFFFF, 100)); |
| 344 EXPECT_EQ(-1, a.CompareWith(mint1)); | 343 EXPECT_EQ(-1, a.CompareWith(mint1)); |
| 345 EXPECT_EQ(1, a.CompareWith(mint2)); | 344 EXPECT_EQ(1, a.CompareWith(mint2)); |
| 346 EXPECT_EQ(-1, c.CompareWith(mint1)); | 345 EXPECT_EQ(-1, c.CompareWith(mint1)); |
| 347 EXPECT_EQ(1, c.CompareWith(mint2)); | 346 EXPECT_EQ(1, c.CompareWith(mint2)); |
| 348 | 347 |
| 349 Bigint& big1 = Bigint::Handle(BigintOperations::NewFromCString( | 348 Bigint& big1 = Bigint::Handle(Bigint::NewFromCString( |
| 350 "10000000000000000000")); | 349 "10000000000000000000")); |
| 351 Bigint& big2 = Bigint::Handle(BigintOperations::NewFromCString( | 350 Bigint& big2 = Bigint::Handle(Bigint::NewFromCString( |
| 352 "-10000000000000000000")); | 351 "-10000000000000000000")); |
| 353 EXPECT_EQ(-1, a.CompareWith(big1)); | 352 EXPECT_EQ(-1, a.CompareWith(big1)); |
| 354 EXPECT_EQ(1, a.CompareWith(big2)); | 353 EXPECT_EQ(1, a.CompareWith(big2)); |
| 355 EXPECT_EQ(-1, c.CompareWith(big1)); | 354 EXPECT_EQ(-1, c.CompareWith(big1)); |
| 356 EXPECT_EQ(1, c.CompareWith(big2)); | 355 EXPECT_EQ(1, c.CompareWith(big2)); |
| 357 } | 356 } |
| 358 | 357 |
| 359 | 358 |
| 360 TEST_CASE(StringCompareTo) { | 359 TEST_CASE(StringCompareTo) { |
| 361 const String& abcd = String::Handle(String::New("abcd")); | 360 const String& abcd = String::Handle(String::New("abcd")); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 501 |
| 503 Mint& c = Mint::Handle(); | 502 Mint& c = Mint::Handle(); |
| 504 c ^= Integer::New(-DART_2PART_UINT64_C(3, 0)); | 503 c ^= Integer::New(-DART_2PART_UINT64_C(3, 0)); |
| 505 Smi& smi1 = Smi::Handle(Smi::New(4)); | 504 Smi& smi1 = Smi::Handle(Smi::New(4)); |
| 506 Smi& smi2 = Smi::Handle(Smi::New(-4)); | 505 Smi& smi2 = Smi::Handle(Smi::New(-4)); |
| 507 EXPECT_EQ(1, a.CompareWith(smi1)); | 506 EXPECT_EQ(1, a.CompareWith(smi1)); |
| 508 EXPECT_EQ(1, a.CompareWith(smi2)); | 507 EXPECT_EQ(1, a.CompareWith(smi2)); |
| 509 EXPECT_EQ(-1, c.CompareWith(smi1)); | 508 EXPECT_EQ(-1, c.CompareWith(smi1)); |
| 510 EXPECT_EQ(-1, c.CompareWith(smi2)); | 509 EXPECT_EQ(-1, c.CompareWith(smi2)); |
| 511 | 510 |
| 512 Bigint& big1 = Bigint::Handle(BigintOperations::NewFromCString( | 511 Bigint& big1 = Bigint::Handle(Bigint::NewFromCString( |
| 513 "10000000000000000000")); | 512 "10000000000000000000")); |
| 514 Bigint& big2 = Bigint::Handle(BigintOperations::NewFromCString( | 513 Bigint& big2 = Bigint::Handle(Bigint::NewFromCString( |
| 515 "-10000000000000000000")); | 514 "-10000000000000000000")); |
| 516 EXPECT_EQ(-1, a.CompareWith(big1)); | 515 EXPECT_EQ(-1, a.CompareWith(big1)); |
| 517 EXPECT_EQ(1, a.CompareWith(big2)); | 516 EXPECT_EQ(1, a.CompareWith(big2)); |
| 518 EXPECT_EQ(-1, c.CompareWith(big1)); | 517 EXPECT_EQ(-1, c.CompareWith(big1)); |
| 519 EXPECT_EQ(1, c.CompareWith(big2)); | 518 EXPECT_EQ(1, c.CompareWith(big2)); |
| 520 | 519 |
| 521 int64_t mint_value = DART_2PART_UINT64_C(0x7FFFFFFF, 64); | 520 int64_t mint_value = DART_2PART_UINT64_C(0x7FFFFFFF, 64); |
| 522 const String& mint_string = String::Handle(String::New("0x7FFFFFFF00000064")); | 521 const String& mint_string = String::Handle(String::New("0x7FFFFFFF00000064")); |
| 523 Mint& mint1 = Mint::Handle(); | 522 Mint& mint1 = Mint::Handle(); |
| 524 mint1 ^= Integer::NewCanonical(mint_string); | 523 mint1 ^= Integer::NewCanonical(mint_string); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 TEST_CASE(Bigint) { | 617 TEST_CASE(Bigint) { |
| 619 Bigint& b = Bigint::Handle(); | 618 Bigint& b = Bigint::Handle(); |
| 620 EXPECT(b.IsNull()); | 619 EXPECT(b.IsNull()); |
| 621 const char* cstr = "18446744073709551615000"; | 620 const char* cstr = "18446744073709551615000"; |
| 622 const String& test = String::Handle(String::New(cstr)); | 621 const String& test = String::Handle(String::New(cstr)); |
| 623 b ^= Integer::NewCanonical(test); | 622 b ^= Integer::NewCanonical(test); |
| 624 const char* str = b.ToCString(); | 623 const char* str = b.ToCString(); |
| 625 EXPECT_STREQ(cstr, str); | 624 EXPECT_STREQ(cstr, str); |
| 626 | 625 |
| 627 int64_t t64 = DART_2PART_UINT64_C(1, 0); | 626 int64_t t64 = DART_2PART_UINT64_C(1, 0); |
| 628 Bigint& big = Bigint::Handle(); | 627 Bigint& big = Bigint::Handle(Bigint::NewFromInt64(t64)); |
| 629 big = BigintOperations::NewFromInt64(t64); | |
| 630 EXPECT_EQ(t64, big.AsInt64Value()); | 628 EXPECT_EQ(t64, big.AsInt64Value()); |
| 631 big = BigintOperations::NewFromCString("10000000000000000000"); | 629 big = Bigint::NewFromCString("10000000000000000000"); |
| 632 EXPECT_EQ(1e19, big.AsDoubleValue()); | 630 EXPECT_EQ(1e19, big.AsDoubleValue()); |
| 633 | 631 |
| 634 Bigint& big1 = Bigint::Handle(BigintOperations::NewFromCString( | 632 Bigint& big1 = Bigint::Handle(Bigint::NewFromCString( |
| 635 "100000000000000000000")); | 633 "100000000000000000000")); |
| 636 Bigint& big2 = Bigint::Handle(BigintOperations::NewFromCString( | 634 Bigint& big2 = Bigint::Handle(Bigint::NewFromCString( |
| 637 "100000000000000000010")); | 635 "100000000000000000010")); |
| 638 Bigint& big3 = Bigint::Handle(BigintOperations::NewFromCString( | 636 Bigint& big3 = Bigint::Handle(Bigint::NewFromCString( |
| 639 "-10000000000000000000")); | 637 "-10000000000000000000")); |
| 640 | 638 |
| 641 EXPECT_EQ(0, big1.CompareWith(big1)); | 639 EXPECT_EQ(0, big1.CompareWith(big1)); |
| 642 EXPECT_EQ(-1, big1.CompareWith(big2)); | 640 EXPECT_EQ(-1, big1.CompareWith(big2)); |
| 643 EXPECT_EQ(1, big2.CompareWith(big1)); | 641 EXPECT_EQ(1, big2.CompareWith(big1)); |
| 644 EXPECT_EQ(1, big1.CompareWith(big3)); | 642 EXPECT_EQ(1, big1.CompareWith(big3)); |
| 645 EXPECT_EQ(-1, big3.CompareWith(big1)); | 643 EXPECT_EQ(-1, big3.CompareWith(big1)); |
| 646 | 644 |
| 647 Smi& smi1 = Smi::Handle(Smi::New(5)); | 645 Smi& smi1 = Smi::Handle(Smi::New(5)); |
| 648 Smi& smi2 = Smi::Handle(Smi::New(-2)); | 646 Smi& smi2 = Smi::Handle(Smi::New(-2)); |
| (...skipping 3888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4537 EXPECT_VALID(h_result); | 4535 EXPECT_VALID(h_result); |
| 4538 Integer& result = Integer::Handle(); | 4536 Integer& result = Integer::Handle(); |
| 4539 result ^= Api::UnwrapHandle(h_result); | 4537 result ^= Api::UnwrapHandle(h_result); |
| 4540 String& foo = String::Handle(String::New("foo")); | 4538 String& foo = String::Handle(String::New("foo")); |
| 4541 Integer& expected = Integer::Handle(); | 4539 Integer& expected = Integer::Handle(); |
| 4542 expected ^= foo.HashCode(); | 4540 expected ^= foo.HashCode(); |
| 4543 EXPECT(result.IsIdenticalTo(expected)); | 4541 EXPECT(result.IsIdenticalTo(expected)); |
| 4544 } | 4542 } |
| 4545 | 4543 |
| 4546 } // namespace dart | 4544 } // namespace dart |
| OLD | NEW |