| 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:front_end/front_end.dart'; | 5 import 'package:front_end/front_end.dart'; |
| 6 import 'package:front_end/src/testing/compiler_common.dart'; | 6 import 'package:front_end/src/testing/compiler_common.dart'; |
| 7 import 'package:kernel/ast.dart'; | 7 import 'package:kernel/ast.dart'; |
| 8 import 'package:kernel/kernel.dart'; | 8 import 'package:kernel/kernel.dart'; |
| 9 | 9 |
| 10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 var errors = []; | 104 var errors = []; |
| 105 var options = new CompilerOptions()..onError = (e) => errors.add(e); | 105 var options = new CompilerOptions()..onError = (e) => errors.add(e); |
| 106 await summarize(['b.dart'], allSources, options: options); | 106 await summarize(['b.dart'], allSources, options: options); |
| 107 expect(errors.first.toString(), contains('Invalid access')); | 107 expect(errors.first.toString(), contains('Invalid access')); |
| 108 errors.clear(); | 108 errors.clear(); |
| 109 | 109 |
| 110 await summarize(['a.dart', 'b.dart'], allSources, options: options); | 110 await summarize(['a.dart', 'b.dart'], allSources, options: options); |
| 111 expect(errors, isEmpty); | 111 expect(errors, isEmpty); |
| 112 }); | 112 }); |
| 113 | 113 |
| 114 test('summarization with multi-roots can work hermetically', () async { |
| 115 var errors = []; |
| 116 var options = new CompilerOptions() |
| 117 ..onError = ((e) => errors.add(e)) |
| 118 ..multiRoots = [toTestUri('rootA/'), toTestUri('rootB/')]; |
| 119 |
| 120 var multiRootSources = <String, String>{ |
| 121 'rootA/a.dart': allSources['a.dart'], |
| 122 'rootB/b.dart': allSources['b.dart'], |
| 123 }; |
| 124 |
| 125 await summarize(['multi-root:/b.dart'], multiRootSources, options: options); |
| 126 expect(errors.first.toString(), contains('Invalid access')); |
| 127 errors.clear(); |
| 128 |
| 129 await summarize( |
| 130 ['multi-root:/a.dart', 'multi-root:/b.dart'], multiRootSources, |
| 131 options: options); |
| 132 expect(errors, isEmpty); |
| 133 }); |
| 134 |
| 114 // TODO(sigmund): test trimDependencies when it is part of the public API. | 135 // TODO(sigmund): test trimDependencies when it is part of the public API. |
| 115 } | 136 } |
| 116 | 137 |
| 117 var allSources = { | 138 var allSources = { |
| 118 'a.dart': 'class A { foo() { print("hi"); } }', | 139 'a.dart': 'class A { foo() { print("hi"); } }', |
| 119 'b.dart': 'import "a.dart"; class B extends A {}', | 140 'b.dart': 'import "a.dart"; class B extends A {}', |
| 120 'c.dart': 'class C { bar() => 1; }', | 141 'c.dart': 'class C { bar() => 1; }', |
| 121 'd.dart': ''' | 142 'd.dart': ''' |
| 122 import "a.dart"; | 143 import "a.dart"; |
| 123 import "b.dart"; | 144 import "b.dart"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 143 var aClass = aLib.classes.firstWhere((c) => c.name == 'A'); | 164 var aClass = aLib.classes.firstWhere((c) => c.name == 'A'); |
| 144 var bClass = bLib.classes.firstWhere((c) => c.name == 'B'); | 165 var bClass = bLib.classes.firstWhere((c) => c.name == 'B'); |
| 145 expect(bClass.superclass, same(aClass)); | 166 expect(bClass.superclass, same(aClass)); |
| 146 | 167 |
| 147 var dClass = dLib.classes.firstWhere((c) => c.name == 'D'); | 168 var dClass = dLib.classes.firstWhere((c) => c.name == 'D'); |
| 148 expect(dClass.superclass.superclass, same(bClass)); | 169 expect(dClass.superclass.superclass, same(bClass)); |
| 149 | 170 |
| 150 var dInterface = dClass.implementedTypes.first.classNode; | 171 var dInterface = dClass.implementedTypes.first.classNode; |
| 151 expect(dInterface, same(aClass)); | 172 expect(dInterface, same(aClass)); |
| 152 } | 173 } |
| OLD | NEW |