Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: pkg/kernel/test/class_hierarchy_test.dart

Issue 2924713002: Replace ClassHierarchy.classes with getOrderedClasses(). (Closed)
Patch Set: Update getOrderedClasses() to return only given classes. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/kernel/lib/transformations/insert_covariance_checks.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/transformations/insert_covariance_checks.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698