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 "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import '../../sdk/lib/_internal/compiler/compiler.dart'; | 9 import '../../sdk/lib/_internal/compiler/compiler.dart'; |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 main() {} | 62 main() {} |
63 """; | 63 """; |
64 | 64 |
65 | 65 |
66 main() { | 66 main() { |
67 int count = 0; | 67 int count = 0; |
68 Future<String> provider(Uri uri) { | 68 Future<String> provider(Uri uri) { |
69 String source; | 69 String source; |
70 if (uri.path.length > 100) { | 70 if (uri.path.length > 100) { |
71 // Simulate an OS error. | 71 // Simulate an OS error. |
72 throw 'Path length exceeded'; | 72 return new Future.error('Path length exceeded'); |
73 } else if (uri.scheme == "main") { | 73 } else if (uri.scheme == "main") { |
74 count++; | 74 count++; |
75 source = RECURSIVE_MAIN; | 75 source = RECURSIVE_MAIN; |
76 } else if (uri.scheme == "lib") { | 76 } else if (uri.scheme == "lib") { |
77 if (uri.path.endsWith("/core.dart")) { | 77 if (uri.path.endsWith("/core.dart")) { |
78 source = CORE_LIB; | 78 source = CORE_LIB; |
79 } else if (uri.path.endsWith('_patch.dart')) { | 79 } else if (uri.path.endsWith('_patch.dart')) { |
80 source = ''; | 80 source = ''; |
81 } else if (uri.path.endsWith('isolate_helper.dart')) { | 81 } else if (uri.path.endsWith('isolate_helper.dart')) { |
82 source = 'class _WorkerStub {}'; | 82 source = 'class _WorkerStub {}'; |
83 } else if (uri.path.endsWith('interceptors.dart')) { | 83 } else if (uri.path.endsWith('interceptors.dart')) { |
84 source = INTERCEPTORS_LIB; | 84 source = INTERCEPTORS_LIB; |
85 } else { | 85 } else { |
86 source = "library lib${uri.path.replaceAll('/', '.')};"; | 86 source = "library lib${uri.path.replaceAll('/', '.')};"; |
87 } | 87 } |
88 } else { | 88 } else { |
89 throw "unexpected URI $uri"; | 89 return new Future.error("unexpected URI $uri"); |
90 } | 90 } |
91 return new Future.value(source); | 91 return new Future.value(source); |
92 } | 92 } |
93 | 93 |
94 int warningCount = 0; | 94 int warningCount = 0; |
95 int errorCount = 0; | 95 int errorCount = 0; |
96 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 96 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
97 if (uri != null) { | 97 if (uri != null) { |
98 // print('$uri:$begin:$end: $kind: $message'); | 98 // print('$uri:$begin:$end: $kind: $message'); |
99 Expect.equals('main', uri.scheme); | 99 Expect.equals('main', uri.scheme); |
(...skipping 16 matching lines...) Expand all Loading... |
116 Expect.isNull(code); | 116 Expect.isNull(code); |
117 Expect.isTrue(10 < count); | 117 Expect.isTrue(10 < count); |
118 // Two warnings for each time RECURSIVE_MAIN is read, except the | 118 // Two warnings for each time RECURSIVE_MAIN is read, except the |
119 // first time. | 119 // first time. |
120 Expect.equals(2 * (count - 1), warningCount); | 120 Expect.equals(2 * (count - 1), warningCount); |
121 Expect.equals(1, errorCount); | 121 Expect.equals(1, errorCount); |
122 }, onError: (e) { | 122 }, onError: (e) { |
123 throw 'Compilation failed'; | 123 throw 'Compilation failed'; |
124 }); | 124 }); |
125 } | 125 } |
OLD | NEW |