| 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 library instantiated_classes_test; | 5 library instantiated_classes_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import 'package:compiler/src/elements/entities.dart' show ClassEntity; | 10 import 'package:compiler/src/elements/entities.dart' |
| 11 show ClassEntity, LibraryEntity; |
| 11 import 'type_test_helper.dart'; | 12 import 'type_test_helper.dart'; |
| 12 | 13 |
| 13 void main() { | 14 void main() { |
| 14 asyncTest(() => Future.forEach([ | 15 asyncTest(() => Future.forEach([ |
| 15 () => test("class Class {}", ["Class"]), | 16 () => test("class Class {}", ["Class"]), |
| 16 () => test( | 17 () => test( |
| 17 """abstract class A {} | 18 """abstract class A {} |
| 18 class Class extends A {}""", | 19 class Class extends A {}""", |
| 19 ["Class"]), | 20 ["Class"]), |
| 20 () => test( | 21 () => test( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 [List<String> newClasses = const <String>["Class"]]) { | 84 [List<String> newClasses = const <String>["Class"]]) { |
| 84 StringBuffer mainSource = new StringBuffer(); | 85 StringBuffer mainSource = new StringBuffer(); |
| 85 mainSource.write('main() {\n'); | 86 mainSource.write('main() {\n'); |
| 86 for (String newClass in newClasses) { | 87 for (String newClass in newClasses) { |
| 87 mainSource.write(' new $newClass();\n'); | 88 mainSource.write(' new $newClass();\n'); |
| 88 } | 89 } |
| 89 mainSource.write('}'); | 90 mainSource.write('}'); |
| 90 return TypeEnvironment | 91 return TypeEnvironment |
| 91 .create(source, mainSource: mainSource.toString(), useMockCompiler: true) | 92 .create(source, mainSource: mainSource.toString(), useMockCompiler: true) |
| 92 .then((env) { | 93 .then((env) { |
| 94 LibraryEntity mainLibrary = |
| 95 env.compiler.frontendStrategy.elementEnvironment.mainLibrary; |
| 93 Iterable<ClassEntity> expectedClasses = | 96 Iterable<ClassEntity> expectedClasses = |
| 94 directlyInstantiatedClasses.map(env.getElement); | 97 directlyInstantiatedClasses.map(env.getElement); |
| 95 Iterable<ClassEntity> actualClasses = env | 98 Iterable<ClassEntity> actualClasses = env |
| 96 .compiler.resolutionWorldBuilder.directlyInstantiatedClasses | 99 .compiler.resolutionWorldBuilder.directlyInstantiatedClasses |
| 97 .where((c) => c.library == env.compiler.mainApp); | 100 .where((c) => c.library == mainLibrary); |
| 98 Expect.setEquals(expectedClasses, actualClasses); | 101 Expect.setEquals(expectedClasses, actualClasses); |
| 99 }); | 102 }); |
| 100 } | 103 } |
| OLD | NEW |