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

Unified Diff: tests/compiler/dart2js/type_promotion_test.dart

Issue 52263003: Implement least upper bound. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/resolver_test.dart ('k') | tests/compiler/dart2js/type_test_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/type_promotion_test.dart
diff --git a/tests/compiler/dart2js/type_promotion_test.dart b/tests/compiler/dart2js/type_promotion_test.dart
index a25c2211a6f3a9f44d1ff5dbccb305bebefb422e..8739394ef6a0923f49c62e25ad7ac6bd3431fce2 100644
--- a/tests/compiler/dart2js/type_promotion_test.dart
+++ b/tests/compiler/dart2js/type_promotion_test.dart
@@ -3,18 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
// Test that dart2js produces the expected static type warnings for type
-// promotion langauge tests. This ensures that the analyzer and dart2js agrees
+// promotion language tests. This ensures that the analyzer and dart2js agrees
// on these tests.
-import 'dart:async';
-import 'dart:io';
-import 'package:expect/expect.dart';
-import 'memory_compiler.dart';
-import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
-import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
-import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.dart';
-import '../../../sdk/lib/_internal/compiler/implementation/util/uri_extras.dart';
-import 'dart:convert';
+import 'warnings_checker.dart';
/// Map from test files to a map of their expected status. If the status map is
/// `null` no warnings must be missing or unexpected, otherwise the status map
@@ -33,64 +25,5 @@ const Map<String, dynamic> TESTS = const {
};
void main() {
- bool isWindows = Platform.isWindows;
- Uri script = currentDirectory.resolveUri(Platform.script);
- bool warningsMismatch = false;
- Future.forEach(TESTS.keys, (String test) {
- Uri uri = script.resolve('../../$test');
- String source = UTF8.decode(readAll(uriPathToNative(uri.path)));
- SourceFile file = new StringSourceFile(
- relativize(currentDirectory, uri, isWindows), source);
- Map<int,String> expectedWarnings = {};
- int lineNo = 0;
- for (String line in source.split('\n')) {
- if (line.contains('///') && line.contains('static type warning')) {
- expectedWarnings[lineNo] = line;
- }
- lineNo++;
- }
- Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys);
- DiagnosticCollector collector = new DiagnosticCollector();
- var compiler = compilerFor(const {},
- diagnosticHandler: collector,
- options: ['--analyze-only'],
- showDiagnostics: false);
- return compiler.run(uri).then((_) {
- Map<String, List<int>> statusMap = TESTS[test];
- // Line numbers with known unexpected warnings.
- List<int> unexpectedStatus = [];
- if (statusMap != null && statusMap.containsKey('unexpected')) {
- unexpectedStatus = statusMap['unexpected'];
- }
- // Line numbers with known missing warnings.
- List<int> missingStatus = [];
- if (statusMap != null && statusMap.containsKey('missing')) {
- missingStatus = statusMap['missing'];
- }
- for (DiagnosticMessage message in collector.warnings) {
- Expect.equals(uri, message.uri);
- int lineNo = file.getLine(message.begin);
- if (expectedWarnings.containsKey(lineNo)) {
- unseenWarnings.remove(lineNo);
- } else if (!unexpectedStatus.contains(lineNo+1)) {
- warningsMismatch = true;
- print(file.getLocationMessage(
- 'Unexpected warning: ${message.message}',
- message.begin, message.end, true, (x) => x));
- }
- }
- if (!unseenWarnings.isEmpty) {
- for (int lineNo in unseenWarnings) {
- if (!missingStatus.contains(lineNo+1)) {
- warningsMismatch = true;
- String line = expectedWarnings[lineNo];
- print('$uri [${lineNo+1}]: Missing static type warning.');
- print(line);
- }
- }
- }
- });
- }).then((_) {
- Expect.isFalse(warningsMismatch);
- });
+ checkWarnings(TESTS);
}
« no previous file with comments | « tests/compiler/dart2js/resolver_test.dart ('k') | tests/compiler/dart2js/type_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698