| 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; | |
| 89 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 88 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
| 90 if (uri != null) { | 89 if (uri != null) { |
| 91 // print('$uri:$begin:$end: $kind: $message'); | 90 // print('$uri:$begin:$end: $kind: $message'); |
| 92 Expect.equals('main', uri.scheme); | 91 Expect.equals('main', uri.scheme); |
| 93 if (kind == Diagnostic.WARNING) { | 92 if (kind == Diagnostic.WARNING) { |
| 94 warningCount++; | 93 warningCount++; |
| 95 } else if (kind == Diagnostic.ERROR) { | 94 } else if (kind == Diagnostic.ERROR) { |
| 96 errorCount++; | 95 errorCount++; |
| 97 } else if (kind == Diagnostic.INFO || kind == Diagnostic.VERBOSE_INFO){ | |
| 98 infoCount++; | |
| 99 } else { | 96 } else { |
| 100 throw kind; | 97 throw kind; |
| 101 } | 98 } |
| 102 } | 99 } |
| 103 } | 100 } |
| 104 | 101 |
| 105 Future<String> result = | 102 Future<String> result = |
| 106 compile(new Uri.fromComponents(scheme: 'main'), | 103 compile(new Uri.fromComponents(scheme: 'main'), |
| 107 new Uri.fromComponents(scheme: 'lib', path: '/'), | 104 new Uri.fromComponents(scheme: 'lib', path: '/'), |
| 108 new Uri.fromComponents(scheme: 'package', path: '/'), | 105 new Uri.fromComponents(scheme: 'package', path: '/'), |
| 109 provider, handler); | 106 provider, handler); |
| 110 result.then((String code) { | 107 result.then((String code) { |
| 111 Expect.isNull(code); | 108 Expect.isNull(code); |
| 112 Expect.isTrue(10 < count); | 109 Expect.isTrue(10 < count); |
| 113 Expect.equals(0, warningCount); | 110 // Two warnings for each time RECURSIVE_MAIN is read, except the |
| 111 // first time. |
| 112 Expect.equals(2 * (count - 1), warningCount); |
| 114 Expect.equals(1, errorCount); | 113 Expect.equals(1, errorCount); |
| 115 // Two infos for each time RECURSIVE_MAIN is read, except the | |
| 116 // first time. | |
| 117 Expect.equals(2 * (count - 1), infoCount); | |
| 118 }, onError: (AsyncError e) { | 114 }, onError: (AsyncError e) { |
| 119 throw 'Compilation failed'; | 115 throw 'Compilation failed'; |
| 120 }); | 116 }); |
| 121 } | 117 } |
| OLD | NEW |