Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: dart/tests/utils/recursive_import_test.dart

Issue 11092003: Implement part-of directive. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update co19 status for dart2dart Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Test of "recursive" imports using the dart2js compiler API.
6
7 #import('../../lib/compiler/compiler.dart');
8 #import('dart:uri');
9
10 const CORE_LIB = """
11 library core;
12 class Object{}
13 class bool {}
14 class num {}
15 class int {}
16 class double{}
17 class String{}
18 class Function{}
19 class List {}
20 class Closure {}
21 class Dynamic_ {}
22 class Null {}
23 getRuntimeTypeInfo(o) {}
24 setRuntimeTypeInfo(o, i) {}
25 eqNull(a) {}
26 eqNullB(a) {}
27 """;
28
29 const String RECURSIVE_MAIN = """
30 library fisk;
31 import 'recurse/fisk.dart';
32 main() {}
33 """;
34
35
36 main() {
37 int count = 0;
38 Future<String> provider(Uri uri) {
39 Completer<String> completer = new Completer<String>();
40 String source;
41 if (uri.path.length > 100) {
42 // Simulate an OS error.
43 throw 'Path length exceeded';
44 } else if (uri.scheme == "main") {
45 count++;
46 source = RECURSIVE_MAIN;
47 } else if (uri.scheme == "lib") {
48 if (uri.path.endsWith("/core.dart")) {
49 source = CORE_LIB;
50 } else if (uri.path.endsWith('_patch.dart')) {
51 source = '';
52 } else {
53 source = "library lib${uri.path.replaceAll('/', '.')};";
54 }
55 } else {
56 throw "unexpected URI $uri";
57 }
58 completer.complete(source);
59 return completer.future;
60 }
61
62 int warningCount = 0;
63 int errorCount = 0;
64 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) {
65 if (uri != null) {
66 // print('$uri:$begin:$end: $kind: $message');
67 Expect.equals('main', uri.scheme);
68 if (kind == Diagnostic.WARNING) {
69 warningCount++;
70 } else if (kind == Diagnostic.ERROR) {
71 errorCount++;
72 } else {
73 throw kind;
74 }
75 }
76 }
77
78 String code = compile(new Uri.fromComponents(scheme: 'main'),
79 new Uri.fromComponents(scheme: 'lib'),
80 new Uri.fromComponents(scheme: 'package'),
81 provider, handler).value;
82 Expect.isNull(code);
83 Expect.isTrue(10 < count);
84 // Two warnings for each time RECURSIVE_MAIN is read, except the
85 // first time.
86 Expect.equals(2 * (count - 1), warningCount);
87 Expect.equals(1, errorCount);
88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698