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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
7 import 'package:compiler/src/apiimpl.dart'; | 7 import 'package:compiler/src/apiimpl.dart'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 import 'package:compiler/src/elements/elements.dart' show ClassElement; | 9 import 'package:compiler/src/elements/elements.dart' show ClassElement; |
10 import 'package:compiler/src/resolution/class_members.dart' | 10 import 'package:compiler/src/resolution/class_members.dart' |
11 show ClassMemberMixin; | 11 show ClassMemberMixin; |
12 import 'memory_compiler.dart'; | 12 import 'memory_compiler.dart'; |
13 | 13 |
14 const String DART2JS_SOURCE = 'pkg/compiler/lib/src/dart2js.dart'; | 14 const String DART2JS_SOURCE = 'pkg/compiler/lib/src/dart2js.dart'; |
15 const List<String> DART2JS_OPTIONS = const <String>[ | 15 const List<String> DART2JS_OPTIONS = const <String>[ |
16 '--categories=Client,Server', | 16 '--categories=Client,Server', |
17 '--disable-type-inference' | 17 '--disable-type-inference' |
18 ]; | 18 ]; |
19 | 19 |
20 Iterable<ClassElement> computeLiveClasses(CompilerImpl compiler) { | 20 Iterable<ClassElement> computeLiveClasses(CompilerImpl compiler) { |
21 return new Set<ClassElement>() | 21 return new Set<ClassElement>() |
22 ..addAll(compiler.resolverWorld.directlyInstantiatedClasses) | 22 ..addAll(compiler.resolutionWorldBuilder.directlyInstantiatedClasses) |
23 ..addAll(compiler.codegenWorld.directlyInstantiatedClasses); | 23 ..addAll(compiler.codegenWorldBuilder.directlyInstantiatedClasses); |
24 } | 24 } |
25 | 25 |
26 void checkClassInvariants(ClassElement cls) { | 26 void checkClassInvariants(ClassElement cls) { |
27 ClassMemberMixin impl = cls; | 27 ClassMemberMixin impl = cls; |
28 Expect.isTrue(impl.areAllMembersComputed(), | 28 Expect.isTrue(impl.areAllMembersComputed(), |
29 "Not all members have been computed for $cls."); | 29 "Not all members have been computed for $cls."); |
30 } | 30 } |
31 | 31 |
32 Future checkElementInvariantsAfterCompiling(Uri uri) async { | 32 Future checkElementInvariantsAfterCompiling(Uri uri) async { |
33 CompilationResult result = | 33 CompilationResult result = |
34 await runCompiler(entryPoint: uri, options: DART2JS_OPTIONS); | 34 await runCompiler(entryPoint: uri, options: DART2JS_OPTIONS); |
35 Expect.isTrue(result.isSuccess, "Compilation of dart2js failed."); | 35 Expect.isTrue(result.isSuccess, "Compilation of dart2js failed."); |
36 | 36 |
37 computeLiveClasses(result.compiler).forEach(checkClassInvariants); | 37 computeLiveClasses(result.compiler).forEach(checkClassInvariants); |
38 } | 38 } |
39 | 39 |
40 void main() { | 40 void main() { |
41 var uri = Uri.base.resolve(DART2JS_SOURCE); | 41 var uri = Uri.base.resolve(DART2JS_SOURCE); |
42 asyncTest(() => checkElementInvariantsAfterCompiling(uri)); | 42 asyncTest(() => checkElementInvariantsAfterCompiling(uri)); |
43 } | 43 } |
OLD | NEW |