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

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

Issue 13866010: Correctly compile unresolved for-in loops. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added unit test Created 7 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:expect/expect.dart';
6 import 'memory_source_file_helper.dart';
7
8 import '../../../sdk/lib/_internal/compiler/compiler.dart'
9 show Diagnostic;
10
11 main() {
kasperl 2013/04/10 08:34:54 This is a great way of writing this test.
12 Uri cwd = getCurrentDirectory();
13 Uri script = cwd.resolve(nativeToUriPath(new Options().script));
14 Uri libraryRoot = script.resolve('../../../sdk/');
15 Uri packageRoot = script.resolve('./packages/');
16
17 MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES;
18 var provider = new MemorySourceFileProvider();
19 int warningCount = 0;
20 int errorCount = 0;
21 void diagnosticHandler(Uri uri, int begin, int end,
22 String message, Diagnostic kind) {
23 if (kind == Diagnostic.VERBOSE_INFO) return;
kasperl 2013/04/10 08:34:54 Tiny nit: I might actually go for writing this wit
ahe 2013/04/10 15:02:19 Done.
24 if (kind == Diagnostic.ERROR) {
25 errorCount++;
26 } else if (kind == Diagnostic.WARNING) {
27 warningCount++;
28 } else {
29 throw 'unexpected diagnostic $kind: $message';
30 }
31 }
32
33 Compiler compiler = new Compiler(provider.readStringFromUri,
34 (name, extension) => null,
35 diagnosticHandler,
36 libraryRoot,
37 packageRoot,
38 ['--analyze-only']);
39 compiler.run(new Uri('memory:main.dart'));
40 Expect.isTrue(compiler.compilationFailed);
41 Expect.equals(5, errorCount);
42 Expect.equals(1, warningCount);
43 }
44
45 const Map MEMORY_SOURCE_FILES = const {
46 'main.dart': """
47 main() {
48 for (var x, y in []) {
49 }
50
51 for (var x = 10 in []) {
52 }
53
54 for (x.y in []) { // Also causes a warning "x unresolved".
55 }
56
57 for ((){}() in []) {
58 }
59
60 for (1 in []) {
61 }
62 }
63 """
64 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698