| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/kernel.dart'; | 5 import 'package:kernel/kernel.dart'; |
| 6 import 'package:kernel/class_hierarchy.dart'; | 6 import 'package:kernel/class_hierarchy.dart'; |
| 7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
| 8 import 'class_hierarchy_basic.dart'; | 8 import 'class_hierarchy_basic.dart'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:math'; | 10 import 'dart:math'; |
| 11 import 'self_check_util.dart'; | 11 import 'self_check_util.dart'; |
| 12 | 12 |
| 13 main(List<String> args) { | 13 main(List<String> args) { |
| 14 runSelfCheck(args, (String filename) { | 14 runSelfCheck(args, (String filename) { |
| 15 testClassHierarchyOnProgram(loadProgramFromBinary(filename)); | 15 testClassHierarchyOnProgram(loadProgramFromBinary(filename)); |
| 16 }); | 16 }); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void testClassHierarchyOnProgram(Program program, {bool verbose: false}) { | 19 void testClassHierarchyOnProgram(Program program, {bool verbose: false}) { |
| 20 BasicClassHierarchy basic = new BasicClassHierarchy(program); | 20 BasicClassHierarchy basic = new BasicClassHierarchy(program); |
| 21 ClassHierarchy classHierarchy = new ClassHierarchy(program); | 21 ClassHierarchyImpl classHierarchy = new ClassHierarchyImpl(program); |
| 22 int total = classHierarchy.classes.length; | 22 int total = classHierarchy.classes.length; |
| 23 int progress = 0; | 23 int progress = 0; |
| 24 for (var class1 in classHierarchy.classes) { | 24 for (var class1 in classHierarchy.classes) { |
| 25 for (var class2 in classHierarchy.classes) { | 25 for (var class2 in classHierarchy.classes) { |
| 26 bool isSubclass = classHierarchy.isSubclassOf(class1, class2); | 26 bool isSubclass = classHierarchy.isSubclassOf(class1, class2); |
| 27 bool isSubmixture = classHierarchy.isSubmixtureOf(class1, class2); | 27 bool isSubmixture = classHierarchy.isSubmixtureOf(class1, class2); |
| 28 bool isSubtype = classHierarchy.isSubtypeOf(class1, class2); | 28 bool isSubtype = classHierarchy.isSubtypeOf(class1, class2); |
| 29 var asInstance = classHierarchy.getClassAsInstanceOf(class1, class2); | 29 var asInstance = classHierarchy.getClassAsInstanceOf(class1, class2); |
| 30 if (isSubclass != basic.isSubclassOf(class1, class2)) { | 30 if (isSubclass != basic.isSubclassOf(class1, class2)) { |
| 31 fail('isSubclassOf(${class1.name}, ${class2.name}) returned ' | 31 fail('isSubclassOf(${class1.name}, ${class2.name}) returned ' |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 var random = new Random(12345); | 151 var random = new Random(12345); |
| 152 | 152 |
| 153 List/*<T>*/ pickRandom/*<T>*/(List/*<T>*/ items, int n) { | 153 List/*<T>*/ pickRandom/*<T>*/(List/*<T>*/ items, int n) { |
| 154 var result = /*<T>*/ []; | 154 var result = /*<T>*/ []; |
| 155 for (int i = 0; i < n; ++i) { | 155 for (int i = 0; i < n; ++i) { |
| 156 result.add(items[random.nextInt(items.length)]); | 156 result.add(items[random.nextInt(items.length)]); |
| 157 } | 157 } |
| 158 return result; | 158 return result; |
| 159 } | 159 } |
| OLD | NEW |