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

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

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
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 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import 'memory_source_file_helper.dart'; 6 import 'memory_source_file_helper.dart';
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 8
9 import 'package:compiler/compiler.dart' 9 import 'package:compiler/compiler.dart'
10 show Diagnostic; 10 show Diagnostic;
11 import 'package:compiler/src/old_to_new_api.dart';
11 12
12 main() { 13 main() {
13 Uri script = currentDirectory.resolveUri(Platform.script); 14 Uri script = currentDirectory.resolveUri(Platform.script);
14 Uri libraryRoot = script.resolve('../../../sdk/'); 15 Uri libraryRoot = script.resolve('../../../sdk/');
15 Uri packageRoot = script.resolve('./packages/'); 16 Uri packageRoot = script.resolve('./packages/');
16 17
17 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); 18 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
18 int warningCount = 0; 19 int warningCount = 0;
19 int errorCount = 0; 20 int errorCount = 0;
20 void diagnosticHandler(Uri uri, int begin, int end, 21 void diagnosticHandler(Uri uri, int begin, int end,
21 String message, Diagnostic kind) { 22 String message, Diagnostic kind) {
22 if (kind == Diagnostic.VERBOSE_INFO) { 23 if (kind == Diagnostic.VERBOSE_INFO) {
23 return; 24 return;
24 } 25 }
25 if (kind == Diagnostic.ERROR) { 26 if (kind == Diagnostic.ERROR) {
26 errorCount++; 27 errorCount++;
27 } else if (kind == Diagnostic.WARNING) { 28 } else if (kind == Diagnostic.WARNING) {
28 warningCount++; 29 warningCount++;
29 } else { 30 } else {
30 throw 'unexpected diagnostic $kind: $message'; 31 throw 'unexpected diagnostic $kind: $message';
31 } 32 }
32 } 33 }
33 34
34 Compiler compiler = new Compiler(provider.readStringFromUri, 35 Compiler compiler = new Compiler(
35 (name, extension) => null, 36 new LegacyCompilerInput(provider.readStringFromUri),
36 diagnosticHandler, 37 new LegacyCompilerOutput(),
37 libraryRoot, 38 new LegacyCompilerDiagnostics(diagnosticHandler),
38 packageRoot, 39 libraryRoot,
39 ['--analyze-only'], 40 packageRoot,
40 {}); 41 ['--analyze-only'],
42 {});
41 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { 43 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) {
42 Expect.isTrue(compiler.compilationFailed); 44 Expect.isTrue(compiler.compilationFailed);
43 Expect.equals(5, errorCount); 45 Expect.equals(5, errorCount);
44 Expect.equals(1, warningCount); 46 Expect.equals(1, warningCount);
45 })); 47 }));
46 } 48 }
47 49
48 const Map MEMORY_SOURCE_FILES = const { 50 const Map MEMORY_SOURCE_FILES = const {
49 'main.dart': """ 51 'main.dart': """
50 main() { 52 main() {
51 for (var x, y in []) { 53 for (var x, y in []) {
52 } 54 }
53 55
54 for (var x = 10 in []) { 56 for (var x = 10 in []) {
55 } 57 }
56 58
57 for (x.y in []) { // Also causes a warning "x unresolved". 59 for (x.y in []) { // Also causes a warning "x unresolved".
58 } 60 }
59 61
60 for ((){}() in []) { 62 for ((){}() in []) {
61 } 63 }
62 64
63 for (1 in []) { 65 for (1 in []) {
64 } 66 }
65 } 67 }
66 """ 68 """
67 }; 69 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698