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

Side by Side Diff: compiler/javatests/com/google/dart/compiler/PrettyErrorFormatterTest.java

Issue 11418190: Issue 6969. Fix for reporting machine format for EOS error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 package com.google.dart.compiler; 4 package com.google.dart.compiler;
5 5
6 import com.google.common.base.Joiner; 6 import com.google.common.base.Joiner;
7 import com.google.dart.compiler.CompilerConfiguration.ErrorFormat; 7 import com.google.dart.compiler.CompilerConfiguration.ErrorFormat;
8 import com.google.dart.compiler.parser.DartScanner.Location; 8 import com.google.dart.compiler.parser.DartScanner.Location;
9 import com.google.dart.compiler.resolver.ResolverErrorCode; 9 import com.google.dart.compiler.resolver.ResolverErrorCode;
10 import com.google.dart.compiler.resolver.TypeErrorCode; 10 import com.google.dart.compiler.resolver.TypeErrorCode;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 * Error on first line, so no previous line printed. 97 * Error on first line, so no previous line printed.
98 */ 98 */
99 public void test_noColor_notMachine_firstLine() throws Exception { 99 public void test_noColor_notMachine_firstLine() throws Exception {
100 Location location = new Location(2, 5); 100 Location location = new Location(2, 5);
101 DartCompilationError error = 101 DartCompilationError error =
102 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo"); 102 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo");
103 // 103 //
104 String errorString = getErrorString(error, false, false); 104 String errorString = getErrorString(error, false, false);
105 assertEquals( 105 assertEquals(
106 Joiner.on("\n").join( 106 Joiner.on("\n").join(
107 "my/path/Test.dart:1: no such type \"Foo\" (sourced from Test_app)", 107 "my/path/Test.dart:1:3: no such type \"Foo\" (sourced from Test_app) ",
108 " 1: lineAAA", 108 " 1: lineAAA",
109 " ~~~", 109 " ~~~",
110 ""), 110 ""),
111 errorString); 111 errorString);
112 } 112 }
113 113
114 /** 114 /**
115 * {@link Location} with single <code>Position</code>, underline single charac ter. 115 * {@link Location} with single <code>Position</code>, underline single charac ter.
116 */ 116 */
117 public void test_noColor_notMachine_singlePosition() throws Exception { 117 public void test_noColor_notMachine_singlePosition() throws Exception {
118 Location location = new Location(10); 118 Location location = new Location(10);
119 DartCompilationError error = 119 DartCompilationError error =
120 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo"); 120 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo");
121 // 121 //
122 String errorString = getErrorString(error, false, false); 122 String errorString = getErrorString(error, false, false);
123 assertEquals( 123 assertEquals(
124 Joiner.on("\n").join( 124 Joiner.on("\n").join(
125 "my/path/Test.dart:2: no such type \"Foo\" (sourced from Test_app)", 125 "my/path/Test.dart:2:3: no such type \"Foo\" (sourced from Test_app) ",
126 " 1: lineAAA", 126 " 1: lineAAA",
127 " 2: lineBBB", 127 " 2: lineBBB",
128 " ~~~~~", 128 " ~~~~~",
129 ""), 129 ""),
130 errorString); 130 errorString);
131 } 131 }
132 132
133 /** 133 /**
134 * {@link Location} with single <code>Position</code>, underline single charac ter. 134 * {@link Location} with single <code>Position</code>, underline single charac ter.
135 */ 135 */
136 public void test_withColor_notMachine_singlePosition() throws Exception { 136 public void test_withColor_notMachine_singlePosition() throws Exception {
137 Location location = new Location(10); 137 Location location = new Location(10);
138 DartCompilationError error = 138 DartCompilationError error =
139 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo"); 139 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo");
140 String errorString = getErrorString(error, true, false); 140 String errorString = getErrorString(error, true, false);
141 assertEquals( 141 assertEquals(
142 Joiner.on("\n").join( 142 Joiner.on("\n").join(
143 WARNING_BOLD_COLOR 143 WARNING_BOLD_COLOR
144 + "my/path/Test.dart:2: no such type \"Foo\" (sourced from Test_ app)" 144 + "my/path/Test.dart:2:3: no such type \"Foo\" (sourced from Tes t_app)"
145 + NO_COLOR, 145 + NO_COLOR,
146 " 1: lineAAA", 146 " 1: lineAAA",
147 " 2: li" + WARNING_COLOR + "neBBB" + NO_COLOR, 147 " 2: li" + WARNING_COLOR + "neBBB" + NO_COLOR,
148 ""), 148 ""),
149 errorString); 149 errorString);
150 150
151 error = new DartCompilationError(SOURCE, location, ResolverErrorCode.NO_SUCH _TYPE, "Foo"); 151 error = new DartCompilationError(SOURCE, location, ResolverErrorCode.NO_SUCH _TYPE, "Foo");
152 errorString = getErrorString(error, true, false); 152 errorString = getErrorString(error, true, false);
153 assertEquals( 153 assertEquals(
154 Joiner.on("\n").join( 154 Joiner.on("\n").join(
155 ERROR_BOLD_COLOR 155 ERROR_BOLD_COLOR
156 + "my/path/Test.dart:2: no such type \"Foo\" (sourced from Test_ app)" 156 + "my/path/Test.dart:2:3: no such type \"Foo\" (sourced from Tes t_app)"
157 + NO_COLOR, 157 + NO_COLOR,
158 " 1: lineAAA", 158 " 1: lineAAA",
159 " 2: li" + ERROR_COLOR + "neBBB" + NO_COLOR, 159 " 2: li" + ERROR_COLOR + "neBBB" + NO_COLOR,
160 ""), 160 ""),
161 errorString); 161 errorString);
162 } 162 }
163 163
164 /** 164 /**
165 * Underline range of characters. 165 * Underline range of characters.
166 */ 166 */
167 public void test_noColor_notMachine() throws Exception { 167 public void test_noColor_notMachine() throws Exception {
168 Location location = new Location(10, 10 + 3); 168 Location location = new Location(10, 10 + 3);
169 DartCompilationError error = 169 DartCompilationError error =
170 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo"); 170 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo");
171 // 171 //
172 String errorString = getErrorString(error, false, false); 172 String errorString = getErrorString(error, false, false);
173 assertEquals( 173 assertEquals(
174 Joiner.on("\n").join( 174 Joiner.on("\n").join(
175 "my/path/Test.dart:2: no such type \"Foo\" (sourced from Test_app)", 175 "my/path/Test.dart:2:3: no such type \"Foo\" (sourced from Test_app) ",
176 " 1: lineAAA", 176 " 1: lineAAA",
177 " 2: lineBBB", 177 " 2: lineBBB",
178 " ~~~", 178 " ~~~",
179 ""), 179 ""),
180 errorString); 180 errorString);
181 } 181 }
182 182
183 /** 183 /**
184 * Use color to highlight range of characters. 184 * Use color to highlight range of characters.
185 */ 185 */
186 public void test_withColor_notMachine() throws Exception { 186 public void test_withColor_notMachine() throws Exception {
187 Location location = new Location(10, 10 + 3); 187 Location location = new Location(10, 10 + 3);
188 DartCompilationError error = 188 DartCompilationError error =
189 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo"); 189 new DartCompilationError(SOURCE, location, TypeErrorCode.NO_SUCH_TYPE, " Foo");
190 String errorString = getErrorString(error, true, false); 190 String errorString = getErrorString(error, true, false);
191 assertEquals( 191 assertEquals(
192 Joiner.on("\n").join( 192 Joiner.on("\n").join(
193 WARNING_BOLD_COLOR 193 WARNING_BOLD_COLOR
194 + "my/path/Test.dart:2: no such type \"Foo\" (sourced from Test_ app)" 194 + "my/path/Test.dart:2:3: no such type \"Foo\" (sourced from Tes t_app)"
195 + NO_COLOR, 195 + NO_COLOR,
196 " 1: lineAAA", 196 " 1: lineAAA",
197 " 2: li" + WARNING_COLOR + "neB" + NO_COLOR + "BB", 197 " 2: li" + WARNING_COLOR + "neB" + NO_COLOR + "BB",
198 ""), 198 ""),
199 errorString); 199 errorString);
200 200
201 error = new DartCompilationError(SOURCE, location, ResolverErrorCode.NO_SUCH _TYPE, "Foo"); 201 error = new DartCompilationError(SOURCE, location, ResolverErrorCode.NO_SUCH _TYPE, "Foo");
202 errorString = getErrorString(error, true, false); 202 errorString = getErrorString(error, true, false);
203 assertEquals( 203 assertEquals(
204 Joiner.on("\n").join( 204 Joiner.on("\n").join(
205 ERROR_BOLD_COLOR 205 ERROR_BOLD_COLOR
206 + "my/path/Test.dart:2: no such type \"Foo\" (sourced from Test_ app)" 206 + "my/path/Test.dart:2:3: no such type \"Foo\" (sourced from Tes t_app)"
207 + NO_COLOR, 207 + NO_COLOR,
208 " 1: lineAAA", 208 " 1: lineAAA",
209 " 2: li" + ERROR_COLOR + "neB" + NO_COLOR + "BB", 209 " 2: li" + ERROR_COLOR + "neB" + NO_COLOR + "BB",
210 ""), 210 ""),
211 errorString); 211 errorString);
212 } 212 }
213 213
214 /** 214 /**
215 * Include all information about error context. 215 * Include all information about error context.
216 */ 216 */
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 270 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
271 PrintStream printStream = new PrintStream(outputStream); 271 PrintStream printStream = new PrintStream(outputStream);
272 ErrorFormatter errorFormatter = 272 ErrorFormatter errorFormatter =
273 new PrettyErrorFormatter(printStream, useColor, printMachineProblems 273 new PrettyErrorFormatter(printStream, useColor, printMachineProblems
274 ? ErrorFormat.MACHINE 274 ? ErrorFormat.MACHINE
275 : ErrorFormat.NORMAL); 275 : ErrorFormat.NORMAL);
276 errorFormatter.format(error); 276 errorFormatter.format(error);
277 return outputStream.toString(); 277 return outputStream.toString();
278 } 278 }
279 } 279 }
OLDNEW
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/Resolver.java ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698