| 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 // Test that the helper [Compiler.inUserCode] works as intended. | 5 // Test that the helper [Compiler.inUserCode] works as intended. |
| 6 | 6 |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
| 9 | 9 |
| 10 import 'memory_compiler.dart'; | 10 import 'memory_compiler.dart'; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 options: ['--analyze-only', '--analyze-all'], | 47 options: ['--analyze-only', '--analyze-all'], |
| 48 packageRoot: Uri.parse('memory:pkg/')); | 48 packageRoot: Uri.parse('memory:pkg/')); |
| 49 Uri mainUri = null; | 49 Uri mainUri = null; |
| 50 if (entryPoints.length == 1) { | 50 if (entryPoints.length == 1) { |
| 51 mainUri = entryPoints[0]; | 51 mainUri = entryPoints[0]; |
| 52 } else { | 52 } else { |
| 53 compiler.librariesToAnalyzeWhenRun = entryPoints; | 53 compiler.librariesToAnalyzeWhenRun = entryPoints; |
| 54 } | 54 } |
| 55 asyncTest(() => compiler.run(mainUri).then((_) { | 55 asyncTest(() => compiler.run(mainUri).then((_) { |
| 56 expectedResults.forEach((String uri, bool expectedResult) { | 56 expectedResults.forEach((String uri, bool expectedResult) { |
| 57 var element = compiler.libraries[uri]; | 57 var element = compiler.libraryLoader.lookupLibrary(Uri.parse(uri)); |
| 58 Expect.isNotNull(element, "Unknown library '$uri'."); | 58 Expect.isNotNull(element, "Unknown library '$uri'."); |
| 59 Expect.equals(expectedResult, compiler.inUserCode(element), | 59 Expect.equals(expectedResult, compiler.inUserCode(element), |
| 60 expectedResult ? "Library '$uri' expected to be in user code" | 60 expectedResult ? "Library '$uri' expected to be in user code" |
| 61 : "Library '$uri' not expected to be in user code"); | 61 : "Library '$uri' not expected to be in user code"); |
| 62 }); | 62 }); |
| 63 })); | 63 })); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void main() { | 66 void main() { |
| 67 test([Uri.parse('memory:main.dart')], | 67 test([Uri.parse('memory:main.dart')], |
| (...skipping 20 matching lines...) Expand all Loading... |
| 88 'package:sup/boz.dart': true, | 88 'package:sup/boz.dart': true, |
| 89 'dart:core': false}); | 89 'dart:core': false}); |
| 90 test([Uri.parse('dart:async'), Uri.parse('package:sub/bar.dart')], | 90 test([Uri.parse('dart:async'), Uri.parse('package:sub/bar.dart')], |
| 91 {'package:sub/bar.dart': true, | 91 {'package:sub/bar.dart': true, |
| 92 'package:sub/baz.dart': true, | 92 'package:sub/baz.dart': true, |
| 93 'package:sup/boz.dart': false, | 93 'package:sup/boz.dart': false, |
| 94 'dart:core': true, | 94 'dart:core': true, |
| 95 'dart:async': true}); | 95 'dart:async': true}); |
| 96 } | 96 } |
| 97 | 97 |
| OLD | NEW |