| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 of "recursive" imports using the dart2js compiler API. | 5 // Test of "recursive" imports using the dart2js compiler API. |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import '../../sdk/lib/_internal/compiler/compiler.dart'; | 8 import '../../sdk/lib/_internal/compiler/compiler.dart'; |
| 9 import 'dart:uri'; | 9 import 'dart:uri'; |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 } else { | 79 } else { |
| 80 throw "unexpected URI $uri"; | 80 throw "unexpected URI $uri"; |
| 81 } | 81 } |
| 82 completer.complete(source); | 82 completer.complete(source); |
| 83 return completer.future; | 83 return completer.future; |
| 84 } | 84 } |
| 85 | 85 |
| 86 int warningCount = 0; | 86 int warningCount = 0; |
| 87 int errorCount = 0; | 87 int errorCount = 0; |
| 88 int infoCount = 0; |
| 88 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 89 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
| 89 if (uri != null) { | 90 if (uri != null) { |
| 90 // print('$uri:$begin:$end: $kind: $message'); | 91 // print('$uri:$begin:$end: $kind: $message'); |
| 91 Expect.equals('main', uri.scheme); | 92 Expect.equals('main', uri.scheme); |
| 92 if (kind == Diagnostic.WARNING) { | 93 if (kind == Diagnostic.WARNING) { |
| 93 warningCount++; | 94 warningCount++; |
| 94 } else if (kind == Diagnostic.ERROR) { | 95 } else if (kind == Diagnostic.ERROR) { |
| 95 errorCount++; | 96 errorCount++; |
| 97 } else if (kind == Diagnostic.INFO || kind == Diagnostic.VERBOSE_INFO){ |
| 98 infoCount++; |
| 96 } else { | 99 } else { |
| 97 throw kind; | 100 throw kind; |
| 98 } | 101 } |
| 99 } | 102 } |
| 100 } | 103 } |
| 101 | 104 |
| 102 Future<String> result = | 105 Future<String> result = |
| 103 compile(new Uri.fromComponents(scheme: 'main'), | 106 compile(new Uri.fromComponents(scheme: 'main'), |
| 104 new Uri.fromComponents(scheme: 'lib', path: '/'), | 107 new Uri.fromComponents(scheme: 'lib', path: '/'), |
| 105 new Uri.fromComponents(scheme: 'package', path: '/'), | 108 new Uri.fromComponents(scheme: 'package', path: '/'), |
| 106 provider, handler); | 109 provider, handler); |
| 107 result.then((String code) { | 110 result.then((String code) { |
| 108 Expect.isNull(code); | 111 Expect.isNull(code); |
| 109 Expect.isTrue(10 < count); | 112 Expect.isTrue(10 < count); |
| 110 // Two warnings for each time RECURSIVE_MAIN is read, except the | 113 Expect.equals(0, warningCount); |
| 114 Expect.equals(1, errorCount); |
| 115 // Two infos for each time RECURSIVE_MAIN is read, except the |
| 111 // first time. | 116 // first time. |
| 112 Expect.equals(2 * (count - 1), warningCount); | 117 Expect.equals(2 * (count - 1), infoCount); |
| 113 Expect.equals(1, errorCount); | |
| 114 }, onError: (AsyncError e) { | 118 }, onError: (AsyncError e) { |
| 115 throw 'Compilation failed'; | 119 throw 'Compilation failed'; |
| 116 }); | 120 }); |
| 117 } | 121 } |
| OLD | NEW |