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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: dart/tests/compiler/dart2js/bad_loop_test.dart
diff --git a/dart/tests/compiler/dart2js/bad_loop_test.dart b/dart/tests/compiler/dart2js/bad_loop_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c3b7e2a5fc92e5f8035724b9d1f5822df3b088e4
--- /dev/null
+++ b/dart/tests/compiler/dart2js/bad_loop_test.dart
@@ -0,0 +1,64 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+import 'memory_source_file_helper.dart';
+
+import '../../../sdk/lib/_internal/compiler/compiler.dart'
+ show Diagnostic;
+
+main() {
kasperl 2013/04/10 08:34:54 This is a great way of writing this test.
+ Uri cwd = getCurrentDirectory();
+ Uri script = cwd.resolve(nativeToUriPath(new Options().script));
+ Uri libraryRoot = script.resolve('../../../sdk/');
+ Uri packageRoot = script.resolve('./packages/');
+
+ MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES;
+ var provider = new MemorySourceFileProvider();
+ int warningCount = 0;
+ int errorCount = 0;
+ void diagnosticHandler(Uri uri, int begin, int end,
+ String message, Diagnostic kind) {
+ 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.
+ if (kind == Diagnostic.ERROR) {
+ errorCount++;
+ } else if (kind == Diagnostic.WARNING) {
+ warningCount++;
+ } else {
+ throw 'unexpected diagnostic $kind: $message';
+ }
+ }
+
+ Compiler compiler = new Compiler(provider.readStringFromUri,
+ (name, extension) => null,
+ diagnosticHandler,
+ libraryRoot,
+ packageRoot,
+ ['--analyze-only']);
+ compiler.run(new Uri('memory:main.dart'));
+ Expect.isTrue(compiler.compilationFailed);
+ Expect.equals(5, errorCount);
+ Expect.equals(1, warningCount);
+}
+
+const Map MEMORY_SOURCE_FILES = const {
+ 'main.dart': """
+main() {
+ for (var x, y in []) {
+ }
+
+ for (var x = 10 in []) {
+ }
+
+ for (x.y in []) { // Also causes a warning "x unresolved".
+ }
+
+ for ((){}() in []) {
+ }
+
+ for (1 in []) {
+ }
+}
+"""
+};

Powered by Google App Engine
This is Rietveld 408576698