OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:kernel/ast.dart'; | 5 import 'package:kernel/ast.dart'; |
6 import 'package:kernel/class_hierarchy.dart'; | 6 import 'package:kernel/class_hierarchy.dart'; |
7 import 'package:kernel/core_types.dart'; | 7 import 'package:kernel/core_types.dart'; |
8 import 'package:kernel/src/incremental_class_hierarchy.dart'; | 8 import 'package:kernel/src/incremental_class_hierarchy.dart'; |
9 import 'package:kernel/testing/mock_sdk_program.dart'; | 9 import 'package:kernel/testing/mock_sdk_program.dart'; |
10 import 'package:kernel/text/ast_to_text.dart'; | 10 import 'package:kernel/text/ast_to_text.dart'; |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 expect(hierarchy.getInterfaceMember(b, aMethodName), aMethod); | 789 expect(hierarchy.getInterfaceMember(b, aMethodName), aMethod); |
790 expect(hierarchy.getInterfaceMember(b, bMethodName), bMethod); | 790 expect(hierarchy.getInterfaceMember(b, bMethodName), bMethod); |
791 expect(hierarchy.getInterfaceMember(b, aSetterName, setter: true), aSetter); | 791 expect(hierarchy.getInterfaceMember(b, aSetterName, setter: true), aSetter); |
792 expect(hierarchy.getInterfaceMember(b, bSetterName, setter: true), bSetter); | 792 expect(hierarchy.getInterfaceMember(b, bSetterName, setter: true), bSetter); |
793 expect(hierarchy.getInterfaceMember(c, aMethodName), aMethod); | 793 expect(hierarchy.getInterfaceMember(c, aMethodName), aMethod); |
794 expect(hierarchy.getInterfaceMember(c, bMethodName), bMethod); | 794 expect(hierarchy.getInterfaceMember(c, bMethodName), bMethod); |
795 expect(hierarchy.getInterfaceMember(c, aSetterName, setter: true), aSetter); | 795 expect(hierarchy.getInterfaceMember(c, aSetterName, setter: true), aSetter); |
796 expect(hierarchy.getInterfaceMember(c, bSetterName, setter: true), bSetter); | 796 expect(hierarchy.getInterfaceMember(c, bSetterName, setter: true), bSetter); |
797 } | 797 } |
798 | 798 |
| 799 void test_getOrderedClasses() { |
| 800 var a = addClass(new Class(name: 'A', supertype: objectSuper)); |
| 801 var b = addClass(new Class(name: 'B', supertype: a.asThisSupertype)); |
| 802 var c = addClass(new Class(name: 'C', supertype: b.asThisSupertype)); |
| 803 |
| 804 void assertOrderOfClasses(List<Class> unordered, List<Class> expected) { |
| 805 var ordered = hierarchy.getOrderedClasses(unordered); |
| 806 expect(ordered, expected); |
| 807 } |
| 808 |
| 809 assertOrderOfClasses([a, b, c], [a, b, c]); |
| 810 assertOrderOfClasses([b, a, c], [a, b, c]); |
| 811 assertOrderOfClasses([a, c, b], [a, b, c]); |
| 812 assertOrderOfClasses([b, c, a], [a, b, c]); |
| 813 assertOrderOfClasses([c, a, b], [a, b, c]); |
| 814 assertOrderOfClasses([c, b, a], [a, b, c]); |
| 815 assertOrderOfClasses([c, b], [b, c]); |
| 816 } |
| 817 |
799 void test_getRankedSuperclasses() { | 818 void test_getRankedSuperclasses() { |
800 var a = addImplementsClass('A', []); | 819 var a = addImplementsClass('A', []); |
801 var b = addImplementsClass('B', [a]); | 820 var b = addImplementsClass('B', [a]); |
802 var c = addImplementsClass('C', [a]); | 821 var c = addImplementsClass('C', [a]); |
803 var d = addImplementsClass('D', [c]); | 822 var d = addImplementsClass('D', [c]); |
804 var e = addImplementsClass('E', [b, d]); | 823 var e = addImplementsClass('E', [b, d]); |
805 | 824 |
806 _assertTestLibraryText(''' | 825 _assertTestLibraryText(''' |
807 class A {} | 826 class A {} |
808 class B implements self::A {} | 827 class B implements self::A {} |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 actualText = actualText.replaceAll(' extends core::Object', ''); | 901 actualText = actualText.replaceAll(' extends core::Object', ''); |
883 | 902 |
884 // if (actualText != expectedText) { | 903 // if (actualText != expectedText) { |
885 // print('-------- Actual --------'); | 904 // print('-------- Actual --------'); |
886 // print(actualText + '------------------------'); | 905 // print(actualText + '------------------------'); |
887 // } | 906 // } |
888 | 907 |
889 expect(actualText, expectedText); | 908 expect(actualText, expectedText); |
890 } | 909 } |
891 } | 910 } |
OLD | NEW |