| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 "vm/flow_graph_range_analysis.h" | 5 #include "vm/flow_graph_range_analysis.h" |
| 6 #include "vm/unit_test.h" | 6 #include "vm/unit_test.h" |
| 7 | 7 |
| 8 namespace dart { | 8 namespace dart { |
| 9 | 9 |
| 10 | 10 |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 | 614 |
| 615 EXPECT(RangeBoundary::IntersectionMax( | 615 EXPECT(RangeBoundary::IntersectionMax( |
| 616 p_infinity, | 616 p_infinity, |
| 617 RangeBoundary::FromConstant(1)).ConstantValue() == 1); | 617 RangeBoundary::FromConstant(1)).ConstantValue() == 1); |
| 618 } | 618 } |
| 619 | 619 |
| 620 | 620 |
| 621 TEST_CASE(RangeJoinMinMax) { | 621 TEST_CASE(RangeJoinMinMax) { |
| 622 // Test IntersectionMin and IntersectionMax methods which for constants are | 622 // Test IntersectionMin and IntersectionMax methods which for constants are |
| 623 // simply defined as Min/Max respectively. | 623 // simply defined as Min/Max respectively. |
| 624 const RangeBoundary::RangeSize size = RangeBoundary::kRangeBoundarySmi; |
| 624 | 625 |
| 625 // Constants. | 626 // Constants. |
| 626 EXPECT(RangeBoundary::JoinMax( | 627 EXPECT(RangeBoundary::JoinMax( |
| 627 RangeBoundary::FromConstant(0), | 628 RangeBoundary::FromConstant(0), |
| 628 RangeBoundary::FromConstant(1)).ConstantValue() == 1); | 629 RangeBoundary::FromConstant(1), |
| 630 size).ConstantValue() == 1); |
| 629 EXPECT(RangeBoundary::JoinMax( | 631 EXPECT(RangeBoundary::JoinMax( |
| 630 RangeBoundary::FromConstant(0), | 632 RangeBoundary::FromConstant(0), |
| 631 RangeBoundary::FromConstant(-1)).ConstantValue() == 0); | 633 RangeBoundary::FromConstant(-1), |
| 634 size).ConstantValue() == 0); |
| 632 EXPECT(RangeBoundary::JoinMax( | 635 EXPECT(RangeBoundary::JoinMax( |
| 633 RangeBoundary::FromConstant(1), | 636 RangeBoundary::FromConstant(1), |
| 634 RangeBoundary::FromConstant(0)).ConstantValue() == 1); | 637 RangeBoundary::FromConstant(0), |
| 638 size).ConstantValue() == 1); |
| 635 EXPECT(RangeBoundary::JoinMax( | 639 EXPECT(RangeBoundary::JoinMax( |
| 636 RangeBoundary::FromConstant(-1), | 640 RangeBoundary::FromConstant(-1), |
| 637 RangeBoundary::FromConstant(0)).ConstantValue() == 0); | 641 RangeBoundary::FromConstant(0), |
| 642 size).ConstantValue() == 0); |
| 638 EXPECT(RangeBoundary::JoinMin( | 643 EXPECT(RangeBoundary::JoinMin( |
| 639 RangeBoundary::FromConstant(0), | 644 RangeBoundary::FromConstant(0), |
| 640 RangeBoundary::FromConstant(1)).ConstantValue() == 0); | 645 RangeBoundary::FromConstant(1), |
| 646 size).ConstantValue() == 0); |
| 641 EXPECT(RangeBoundary::JoinMin( | 647 EXPECT(RangeBoundary::JoinMin( |
| 642 RangeBoundary::FromConstant(0), | 648 RangeBoundary::FromConstant(0), |
| 643 RangeBoundary::FromConstant(-1)).ConstantValue() == -1); | 649 RangeBoundary::FromConstant(-1), |
| 650 size).ConstantValue() == -1); |
| 644 EXPECT(RangeBoundary::JoinMin( | 651 EXPECT(RangeBoundary::JoinMin( |
| 645 RangeBoundary::FromConstant(1), | 652 RangeBoundary::FromConstant(1), |
| 646 RangeBoundary::FromConstant(0)).ConstantValue() == 0); | 653 RangeBoundary::FromConstant(0), |
| 654 size).ConstantValue() == 0); |
| 647 EXPECT(RangeBoundary::JoinMin( | 655 EXPECT(RangeBoundary::JoinMin( |
| 648 RangeBoundary::FromConstant(-1), | 656 RangeBoundary::FromConstant(-1), |
| 649 RangeBoundary::FromConstant(0)).ConstantValue() == -1); | 657 RangeBoundary::FromConstant(0), |
| 658 size).ConstantValue() == -1); |
| 650 | 659 |
| 651 RangeBoundary n_infinity = RangeBoundary::NegativeInfinity(); | 660 RangeBoundary n_infinity = RangeBoundary::NegativeInfinity(); |
| 652 RangeBoundary p_infinity = RangeBoundary::PositiveInfinity(); | 661 RangeBoundary p_infinity = RangeBoundary::PositiveInfinity(); |
| 653 | 662 |
| 654 // Constants vs. infinity. | 663 // Constants vs. infinity. |
| 655 EXPECT(RangeBoundary::JoinMin( | 664 EXPECT(RangeBoundary::JoinMin( |
| 656 n_infinity, | 665 n_infinity, |
| 657 RangeBoundary::FromConstant(-1)).IsSmiMinimumOrBelow()); | 666 RangeBoundary::FromConstant(-1), |
| 667 size).IsMinimumOrBelow(size)); |
| 658 | 668 |
| 659 EXPECT(RangeBoundary::JoinMin( | 669 EXPECT(RangeBoundary::JoinMin( |
| 660 RangeBoundary::FromConstant(-1), | 670 RangeBoundary::FromConstant(-1), |
| 661 n_infinity).IsSmiMinimumOrBelow()); | 671 n_infinity, |
| 672 size).IsMinimumOrBelow(size)); |
| 662 | 673 |
| 663 EXPECT(RangeBoundary::JoinMin( | 674 EXPECT(RangeBoundary::JoinMin( |
| 664 RangeBoundary::FromConstant(1), | 675 RangeBoundary::FromConstant(1), |
| 665 n_infinity).IsSmiMinimumOrBelow()); | 676 n_infinity, |
| 677 size).IsMinimumOrBelow(size)); |
| 666 | 678 |
| 667 EXPECT(RangeBoundary::JoinMin( | 679 EXPECT(RangeBoundary::JoinMin( |
| 668 n_infinity, | 680 n_infinity, |
| 669 RangeBoundary::FromConstant(1)).IsSmiMinimumOrBelow()); | 681 RangeBoundary::FromConstant(1), |
| 682 size).IsMinimumOrBelow(size)); |
| 670 | 683 |
| 671 EXPECT(RangeBoundary::JoinMax( | 684 EXPECT(RangeBoundary::JoinMax( |
| 672 p_infinity, | 685 p_infinity, |
| 673 RangeBoundary::FromConstant(-1)).IsSmiMaximumOrAbove()); | 686 RangeBoundary::FromConstant(-1), |
| 687 size).IsMaximumOrAbove(size)); |
| 674 | 688 |
| 675 EXPECT(RangeBoundary::JoinMax( | 689 EXPECT(RangeBoundary::JoinMax( |
| 676 RangeBoundary::FromConstant(-1), | 690 RangeBoundary::FromConstant(-1), |
| 677 p_infinity).IsSmiMaximumOrAbove()); | 691 p_infinity, |
| 692 size).IsMaximumOrAbove(size)); |
| 678 | 693 |
| 679 EXPECT(RangeBoundary::JoinMax( | 694 EXPECT(RangeBoundary::JoinMax( |
| 680 RangeBoundary::FromConstant(1), | 695 RangeBoundary::FromConstant(1), |
| 681 p_infinity).IsSmiMaximumOrAbove()); | 696 p_infinity, |
| 697 size).IsMaximumOrAbove(size)); |
| 682 | 698 |
| 683 EXPECT(RangeBoundary::JoinMax( | 699 EXPECT(RangeBoundary::JoinMax( |
| 684 p_infinity, | 700 p_infinity, |
| 685 RangeBoundary::FromConstant(1)).IsSmiMaximumOrAbove()); | 701 RangeBoundary::FromConstant(1), |
| 702 size).IsMaximumOrAbove(size)); |
| 686 } | 703 } |
| 687 | 704 |
| 688 } // namespace dart | 705 } // namespace dart |
| OLD | NEW |