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

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

Issue 864643006: Allow sync *, async * and yield * in dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | « tests/compiler/dart2js/dart2js.status ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // Checks that dart2js produces the expected static type warnings and 5 // Checks that dart2js produces the expected static type warnings and
6 // compile-time errors for the provided multitests. 6 // compile-time errors for the provided multitests.
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io';
9 10
10 import 'package:expect/expect.dart';
11 import 'package:async_helper/async_helper.dart'; 11 import 'package:async_helper/async_helper.dart';
12 12 import 'package:compiler/src/util/uri_extras.dart'
13 show relativize;
13 import 'memory_compiler.dart'; 14 import 'memory_compiler.dart';
14 15
15 import '../../../tools/testing/dart/multitest.dart' 16 import '../../../tools/testing/dart/multitest.dart'
16 show ExtractTestsFromMultitest; 17 show ExtractTestsFromMultitest;
17 import '../../../tools/testing/dart/path.dart' 18 import '../../../tools/testing/dart/path.dart'
18 show Path; 19 show Path;
19 20
20 void check(List<String> testFiles, 21
22 /// Check the analysis of the multitests in [testFiles] to result in the
23 /// expected static warnings and compile-time errors.
24 ///
25 /// [testFiles] is a map of the test files to be checked together with their
26 /// associated white listing.
27 ///
28 /// For instance if [testFiles] contain the mapping
29 /// 'language/async_await_syntax_test.dart': const ['a03b', 'a04b']
30 /// the multitests in 'language/async_await_syntax_test.dart' are checked but
31 /// the subtests 'a03b' and 'a04c' are expected to fail.
32 void check(Map<String, List<String>> testFiles,
21 {List<String> arguments: const <String>[], 33 {List<String> arguments: const <String>[],
22 List<String> options: const <String>[]}) { 34 List<String> options: const <String>[]}) {
23 bool outcomeMismatch = false; 35 bool outcomeMismatch = false;
24 bool verbose = arguments.contains('-v'); 36 bool verbose = arguments.contains('-v');
25 var cachedCompiler; 37 var cachedCompiler;
26 asyncTest(() => Future.forEach(testFiles, (String testFile) { 38 asyncTest(() => Future.forEach(testFiles.keys, (String testFile) {
27 Map<String, String> testSources = {}; 39 Map<String, String> testSources = {};
28 Map<String, Set<String>> testOutcomes = {}; 40 Map<String, Set<String>> testOutcomes = {};
29 String fileName = 'tests/$testFile'; 41 String fileName = 'tests/$testFile';
30 ExtractTestsFromMultitest(new Path(fileName), testSources, testOutcomes); 42 ExtractTestsFromMultitest(new Path(fileName), testSources, testOutcomes);
31 return Future.forEach(testSources.keys, (String testName) { 43 return Future.forEach(testSources.keys, (String testName) {
32 String testFileName = '$fileName/$testName'; 44 String testFileName = '$fileName/$testName';
33 Set<String> expectedOutcome = testOutcomes[testName]; 45 Set<String> expectedOutcome = testOutcomes[testName];
46 bool expectFailure = testFiles[testFile].contains(testName);
34 DiagnosticCollector collector = new DiagnosticCollector(); 47 DiagnosticCollector collector = new DiagnosticCollector();
35 var compiler = compilerFor( 48 var compiler = compilerFor(
36 {testFileName: testSources[testName]}, 49 {testFileName: testSources[testName]},
37 diagnosticHandler: collector, 50 diagnosticHandler: collector,
38 options: ['--analyze-only']..addAll(options), 51 options: ['--analyze-only']..addAll(options),
39 showDiagnostics: verbose, 52 showDiagnostics: verbose,
40 cachedCompiler: cachedCompiler); 53 cachedCompiler: cachedCompiler);
41 return compiler.run(Uri.parse('memory:$testFileName')).then((_) { 54 return compiler.run(Uri.parse('memory:$testFileName')).then((_) {
55 bool unexpectedResult = false;
42 if (expectedOutcome.contains('compile-time error')) { 56 if (expectedOutcome.contains('compile-time error')) {
43 if (collector.errors.isEmpty) { 57 if (collector.errors.isEmpty) {
44 print('$testFileName: Missing compile-time error.'); 58 print('$testFileName: Missing compile-time error.');
45 outcomeMismatch = true; 59 unexpectedResult = true;
46 } 60 }
47 } else if (expectedOutcome.contains('static type warning')) { 61 } else if (expectedOutcome.contains('static type warning')) {
48 if (collector.warnings.isEmpty) { 62 if (collector.warnings.isEmpty) {
49 print('$testFileName: Missing static type warning.'); 63 print('$testFileName: Missing static type warning.');
50 outcomeMismatch = true; 64 unexpectedResult = true;
51 } 65 }
52 } else { 66 } else {
53 // Expect ok. 67 // Expect ok.
54 if (!collector.errors.isEmpty || 68 if (!collector.errors.isEmpty ||
55 !collector.warnings.isEmpty) { 69 !collector.warnings.isEmpty) {
56 collector.errors.forEach((message) { 70 collector.errors.forEach((message) {
57 print('$testFileName: Unexpected error: ${message.message}'); 71 print('$testFileName: Unexpected error: ${message.message}');
58 }); 72 });
59 collector.warnings.forEach((message) { 73 collector.warnings.forEach((message) {
60 print('$testFileName: Unexpected warning: ${message.message}'); 74 print('$testFileName: Unexpected warning: ${message.message}');
61 }); 75 });
62 outcomeMismatch = true; 76 unexpectedResult = true;
63 } 77 }
64 } 78 }
79 if (expectFailure) {
80 if (unexpectedResult) {
81 unexpectedResult = false;
82 } else {
83 print('$testFileName: The test is white-listed '
84 'and therefore expected to fail.');
85 unexpectedResult = true;
86 }
87 }
88 if (unexpectedResult) {
89 outcomeMismatch = true;
90 }
65 cachedCompiler = compiler; 91 cachedCompiler = compiler;
66 }); 92 });
67 }); 93 });
68 }).then((_) { 94 }).then((_) {
69 Expect.isFalse(outcomeMismatch, 'Outcome mismatch'); 95 if (outcomeMismatch) {
96 String testFileName =
97 relativize(Uri.base, Platform.script, Platform.isWindows);
98 print('''
99
100 ===
101 === ERROR: Unexpected result of analysis.
102 ===
103 === Please update the white-listing in $testFileName
104 ===
105
106 ''');
107 exit(1);
108 }
70 })); 109 }));
71 } 110 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698