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

Side by Side Diff: dart/tests/compiler/dart2js/message_kind_helper.dart

Issue 233353002: Complain if there are pending classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update expectations for parser tests Created 6 years, 8 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
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library dart2js.test.message_kind_helper; 5 library dart2js.test.message_kind_helper;
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show
(...skipping 24 matching lines...) Expand all
35 MessageKind.HIDDEN_IMPORT, 35 MessageKind.HIDDEN_IMPORT,
36 MessageKind.INHERIT_GETTER_AND_METHOD, 36 MessageKind.INHERIT_GETTER_AND_METHOD,
37 MessageKind.UNIMPLEMENTED_METHOD, 37 MessageKind.UNIMPLEMENTED_METHOD,
38 MessageKind.UNIMPLEMENTED_METHOD_ONE, 38 MessageKind.UNIMPLEMENTED_METHOD_ONE,
39 MessageKind.UNTERMINATED_STRING, 39 MessageKind.UNTERMINATED_STRING,
40 MessageKind.VAR_FUNCTION_TYPE_PARAMETER, 40 MessageKind.VAR_FUNCTION_TYPE_PARAMETER,
41 MessageKind.VOID_NOT_ALLOWED, 41 MessageKind.VOID_NOT_ALLOWED,
42 MessageKind.UNMATCHED_TOKEN, 42 MessageKind.UNMATCHED_TOKEN,
43 ]); 43 ]);
44 44
45 /// Most messages can be tested without causing a fatal error. Add an exception
46 /// here if a fatal error is unavoidable and leads to pending classes.
47 /// Try to avoid adding exceptions here; a fatal error causes the compiler to
48 /// stop before analyzing all input, and it isn't safe to reuse it.
49 final Set<MessageKind> kindsWithPendingClasses = new Set<MessageKind>.from([
50 MessageKind.TYPEDEF_FORMAL_WITH_DEFAULT,
51 ]);
52
53 /// Most messages can be tested without causing a fatal error. Add an exception
54 /// here if a fatal error is unavoidable.
55 /// Try to avoid adding exceptions here; a fatal error causes the compiler to
56 /// stop before analyzing all input, and it isn't safe to reuse it.
57 final Set<MessageKind> kindsWithFatalErrors = new Set<MessageKind>.from([
58 MessageKind.FUNCTION_TYPE_FORMAL_WITH_DEFAULT,
59 MessageKind.HEX_DIGIT_EXPECTED,
60 MessageKind.REDIRECTING_FACTORY_WITH_DEFAULT,
61 MessageKind.REFERENCE_IN_INITIALIZATION,
62 MessageKind.TYPEDEF_FORMAL_WITH_DEFAULT,
63 MessageKind.UNMATCHED_TOKEN,
64 MessageKind.UNTERMINATED_STRING,
65 ]);
66
45 Future<Compiler> check(MessageKind kind, Compiler cachedCompiler) { 67 Future<Compiler> check(MessageKind kind, Compiler cachedCompiler) {
46 Expect.isNotNull(kind.howToFix); 68 Expect.isNotNull(kind.howToFix);
47 Expect.isFalse(kind.examples.isEmpty); 69 Expect.isFalse(kind.examples.isEmpty);
48 70
49 return Future.forEach(kind.examples, (example) { 71 return Future.forEach(kind.examples, (example) {
50 if (example is String) { 72 if (example is String) {
51 example = {'main.dart': example}; 73 example = {'main.dart': example};
52 } else { 74 } else {
53 Expect.isTrue(example is Map, 75 Expect.isTrue(example is Map,
54 "Example must be either a String or a Map."); 76 "Example must be either a String or a Map.");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 for (String message in unexpectedMessages) { 118 for (String message in unexpectedMessages) {
97 print("Unexpected message: $message"); 119 print("Unexpected message: $message");
98 } 120 }
99 if (!kindsWithExtraMessages.contains(kind)) { 121 if (!kindsWithExtraMessages.contains(kind)) {
100 // Try changing the error reporting logic before adding an exception 122 // Try changing the error reporting logic before adding an exception
101 // to [kindsWithExtraMessages]. 123 // to [kindsWithExtraMessages].
102 throw 'Unexpected messages found.'; 124 throw 'Unexpected messages found.';
103 } 125 }
104 } 126 }
105 cachedCompiler = compiler; 127 cachedCompiler = compiler;
128 Expect.isTrue(kindsWithFatalErrors.contains(kind) ||
129 !compiler.compilerWasCancelled);
130
131 bool pendingStuff = false;
132 for (var e in compiler.resolver.pendingClassesToBePostProcessed) {
133 pendingStuff = true;
134 compiler.reportInfo(
135 e, MessageKind.GENERIC,
136 {'text': 'Pending class to be post-processed.'});
137 }
138 for (var e in compiler.resolver.pendingClassesToBeResolved) {
139 pendingStuff = true;
140 compiler.reportInfo(
141 e, MessageKind.GENERIC,
142 {'text': 'Pending class to be resolved.'});
143 }
144 if (pendingStuff) {
145 if (!kindsWithPendingClasses.contains(kind)) {
146 throw 'Stuff was pending';
147 }
148 cachedCompiler = null;
149 } else if (compiler.compilerWasCancelled) {
150 cachedCompiler = null;
151 } else {
152 cachedCompiler = compiler;
153 }
106 }); 154 });
107 }).then((_) => cachedCompiler); 155 }).then((_) => cachedCompiler);
108 } 156 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698