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

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

Issue 20742002: Clean up error handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed errors found during testing. Created 7 years, 4 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Smoke test of the dart2js compiler API. 5 // Smoke test of the dart2js compiler API.
6 library analyze_only; 6 library analyze_only;
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 }); 46 });
47 } 47 }
48 48
49 main() { 49 main() {
50 runCompiler( 50 runCompiler(
51 "", 51 "",
52 [], 52 [],
53 (String code, List errors, List warnings) { 53 (String code, List errors, List warnings) {
54 Expect.isNull(code); 54 Expect.isNull(code);
55 Expect.equals(1, errors.length); 55 Expect.equals(1, errors.length);
56 Expect.equals('Could not find main', errors[0].toString()); 56 Expect.equals('Error: Could not find "main".', errors[0].toString());
57 Expect.isTrue(warnings.isEmpty); 57 Expect.isTrue(warnings.isEmpty);
58 }); 58 });
59 59
60 runCompiler( 60 runCompiler(
61 "main() {}", 61 "main() {}",
62 [], 62 [],
63 (String code, List errors, List warnings) { 63 (String code, List errors, List warnings) {
64 Expect.isNotNull(code); 64 Expect.isNotNull(code);
65 Expect.isTrue(errors.isEmpty); 65 Expect.isTrue(errors.isEmpty);
66 Expect.isTrue(warnings.isEmpty); 66 Expect.isTrue(warnings.isEmpty);
67 }); 67 });
68 68
69 runCompiler( 69 runCompiler(
70 "", 70 "",
71 ['--analyze-only'], 71 ['--analyze-only'],
72 (String code, List errors, List warnings) { 72 (String code, List errors, List warnings) {
73 Expect.isNull(code); 73 Expect.isNull(code);
74 Expect.equals(1, errors.length); 74 Expect.equals(1, errors.length);
75 Expect.isTrue(errors[0].toString().startsWith('Could not find main')); 75 Expect.isTrue(
76 errors[0].toString().startsWith('Error: Could not find "main".'));
76 Expect.isTrue(warnings.isEmpty); 77 Expect.isTrue(warnings.isEmpty);
77 }); 78 });
78 79
79 runCompiler( 80 runCompiler(
80 "main() {}", 81 "main() {}",
81 ['--analyze-only'], 82 ['--analyze-only'],
82 (String code, List errors, List warnings) { 83 (String code, List errors, List warnings) {
83 Expect.isNull(code); 84 Expect.isNull(code);
84 Expect.isTrue(errors.isEmpty); 85 Expect.isTrue(errors.isEmpty);
85 Expect.isTrue(warnings.isEmpty); 86 Expect.isTrue(warnings.isEmpty);
86 }); 87 });
87 88
88 runCompiler( 89 runCompiler(
89 "Foo foo; // Unresolved but not analyzed.", 90 "Foo foo; // Unresolved but not analyzed.",
90 ['--analyze-only'], 91 ['--analyze-only'],
91 (String code, List errors, List warnings) { 92 (String code, List errors, List warnings) {
92 Expect.isNull(code); 93 Expect.isNull(code);
93 Expect.equals(1, errors.length); 94 Expect.equals(1, errors.length);
94 Expect.isTrue(errors[0].toString().startsWith('Could not find main')); 95 Expect.isTrue(
96 errors[0].toString().startsWith('Error: Could not find "main".'));
95 Expect.isTrue(warnings.isEmpty); 97 Expect.isTrue(warnings.isEmpty);
96 }); 98 });
97 99
98 runCompiler( 100 runCompiler(
99 """main() { 101 """main() {
100 Foo foo; // Unresolved and analyzed. 102 Foo foo; // Unresolved and analyzed.
101 }""", 103 }""",
102 ['--analyze-only'], 104 ['--analyze-only'],
103 (String code, List errors, List warnings) { 105 (String code, List errors, List warnings) {
104 Expect.isNull(code); 106 Expect.isNull(code);
105 Expect.isTrue(errors.isEmpty); 107 Expect.isTrue(errors.isEmpty);
106 Expect.equals(1, warnings.length); 108 Expect.equals(1, warnings.length);
107 Expect.equals('Warning: cannot resolve type Foo', warnings[0].toString()); 109 Expect.equals(
110 'Warning: Cannot resolve type "Foo".', warnings[0].toString());
108 }); 111 });
109 112
110 runCompiler( 113 runCompiler(
111 """main() { 114 """main() {
112 Foo foo; // Unresolved and analyzed. 115 Foo foo; // Unresolved and analyzed.
113 }""", 116 }""",
114 ['--analyze-only', '--analyze-signatures-only'], 117 ['--analyze-only', '--analyze-signatures-only'],
115 (String code, List errors, List warnings) { 118 (String code, List errors, List warnings) {
116 Expect.isNull(code); 119 Expect.isNull(code);
117 Expect.isTrue(errors.isEmpty); 120 Expect.isTrue(errors.isEmpty);
118 Expect.isTrue(warnings.isEmpty); 121 Expect.isTrue(warnings.isEmpty);
119 }); 122 });
120 123
121 runCompiler( 124 runCompiler(
122 "Foo foo; // Unresolved and analyzed.", 125 "Foo foo; // Unresolved and analyzed.",
123 ['--analyze-only', '--analyze-all'], 126 ['--analyze-only', '--analyze-all'],
124 (String code, List errors, List warnings) { 127 (String code, List errors, List warnings) {
125 Expect.isNull(code); 128 Expect.isNull(code);
126 Expect.isTrue(errors.isEmpty); 129 Expect.isTrue(errors.isEmpty);
127 Expect.equals('Warning: cannot resolve type Foo', warnings[0].toString()); 130 Expect.equals(
131 'Warning: Cannot resolve type "Foo".', warnings[0].toString());
128 }); 132 });
129 133
130 runCompiler( 134 runCompiler(
131 """Foo foo; // Unresolved and analyzed. 135 """Foo foo; // Unresolved and analyzed.
132 main() {}""", 136 main() {}""",
133 ['--analyze-only', '--analyze-all'], 137 ['--analyze-only', '--analyze-all'],
134 (String code, List errors, List warnings) { 138 (String code, List errors, List warnings) {
135 Expect.isNull(code); 139 Expect.isNull(code);
136 Expect.isTrue(errors.isEmpty); 140 Expect.isTrue(errors.isEmpty);
137 Expect.equals(1, warnings.length); 141 Expect.equals(1, warnings.length);
138 Expect.equals('Warning: cannot resolve type Foo', warnings[0].toString()); 142 Expect.equals(
143 'Warning: Cannot resolve type "Foo".', warnings[0].toString());
139 }); 144 });
140 145
141 runCompiler( 146 runCompiler(
142 "", 147 "",
143 ['--analyze-only', '--analyze-all'], 148 ['--analyze-only', '--analyze-all'],
144 (String code, List errors, List warnings) { 149 (String code, List errors, List warnings) {
145 Expect.isNull(code); 150 Expect.isNull(code);
146 Expect.isTrue(errors.isEmpty); 151 Expect.isTrue(errors.isEmpty);
147 Expect.isTrue(warnings.isEmpty); 152 Expect.isTrue(warnings.isEmpty);
148 }); 153 });
149 154
150 // --analyze-signatures-only implies --analyze-only 155 // --analyze-signatures-only implies --analyze-only
151 runCompiler( 156 runCompiler(
152 "", 157 "",
153 ['--analyze-signatures-only', '--analyze-all'], 158 ['--analyze-signatures-only', '--analyze-all'],
154 (String code, List errors, List warnings) { 159 (String code, List errors, List warnings) {
155 Expect.isNull(code); 160 Expect.isNull(code);
156 Expect.isTrue(errors.isEmpty); 161 Expect.isTrue(errors.isEmpty);
157 Expect.isTrue(warnings.isEmpty); 162 Expect.isTrue(warnings.isEmpty);
158 }); 163 });
159 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698