OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 | 3 |
4 library engine.test_support; | 4 library engine.test_support; |
5 | 5 |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'package:analyzer-experimental/src/generated/java_core.dart'; | 7 import 'package:analyzer-experimental/src/generated/java_core.dart'; |
8 import 'package:analyzer-experimental/src/generated/java_engine.dart'; | 8 import 'package:analyzer-experimental/src/generated/java_engine.dart'; |
9 import 'package:analyzer-experimental/src/generated/java_junit.dart'; | 9 import 'package:analyzer-experimental/src/generated/java_junit.dart'; |
10 import 'package:analyzer-experimental/src/generated/source.dart'; | 10 import 'package:analyzer-experimental/src/generated/source.dart'; |
(...skipping 24 matching lines...) Expand all Loading... |
35 */ | 35 */ |
36 Map<Source, LineInfo> _lineInfoMap = new Map<Source, LineInfo>(); | 36 Map<Source, LineInfo> _lineInfoMap = new Map<Source, LineInfo>(); |
37 /** | 37 /** |
38 * An empty array of errors used when no errors are expected. | 38 * An empty array of errors used when no errors are expected. |
39 */ | 39 */ |
40 static List<AnalysisError> _NO_ERRORS = new List<AnalysisError>.fixedLength(0)
; | 40 static List<AnalysisError> _NO_ERRORS = new List<AnalysisError>.fixedLength(0)
; |
41 /** | 41 /** |
42 * Initialize a newly created error listener to collect errors. | 42 * Initialize a newly created error listener to collect errors. |
43 */ | 43 */ |
44 GatheringErrorListener() : super() { | 44 GatheringErrorListener() : super() { |
45 _jtd_constructor_234_impl(); | 45 _jtd_constructor_258_impl(); |
46 } | 46 } |
47 _jtd_constructor_234_impl() { | 47 _jtd_constructor_258_impl() { |
48 } | 48 } |
49 /** | 49 /** |
50 * Initialize a newly created error listener to collect errors. | 50 * Initialize a newly created error listener to collect errors. |
51 */ | 51 */ |
52 GatheringErrorListener.con1(String rawSource) { | 52 GatheringErrorListener.con1(String rawSource2) { |
53 _jtd_constructor_235_impl(rawSource); | 53 _jtd_constructor_259_impl(rawSource2); |
54 } | 54 } |
55 _jtd_constructor_235_impl(String rawSource) { | 55 _jtd_constructor_259_impl(String rawSource2) { |
56 this._rawSource = rawSource; | 56 this._rawSource = rawSource2; |
57 this._markedSource = rawSource; | 57 this._markedSource = rawSource2; |
58 } | 58 } |
59 /** | 59 /** |
60 * Assert that the number of errors that have been gathered matches the number
of errors that are | 60 * Assert that the number of errors that have been gathered matches the number
of errors that are |
61 * given and that they have the expected error codes and locations. The order
in which the errors | 61 * given and that they have the expected error codes and locations. The order
in which the errors |
62 * were gathered is ignored. | 62 * were gathered is ignored. |
63 * @param errorCodes the errors that should have been gathered | 63 * @param errorCodes the errors that should have been gathered |
64 * @throws AssertionFailedError if a different number of errors have been gath
ered than were | 64 * @throws AssertionFailedError if a different number of errors have been gath
ered than were |
65 * expected or if they do not have the same codes and locations | 65 * expected or if they do not have the same codes and locations |
66 */ | 66 */ |
67 void assertErrors(List<AnalysisError> expectedErrors) { | 67 void assertErrors(List<AnalysisError> expectedErrors) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 * are given and that there are the same number of errors and warnings as spec
ified by the | 163 * are given and that there are the same number of errors and warnings as spec
ified by the |
164 * argument. The order in which the errors were gathered is ignored. | 164 * argument. The order in which the errors were gathered is ignored. |
165 * @param expectedSeverities the severities of the errors that should have bee
n gathered | 165 * @param expectedSeverities the severities of the errors that should have bee
n gathered |
166 * @throws AssertionFailedError if a different number of errors have been gath
ered than were | 166 * @throws AssertionFailedError if a different number of errors have been gath
ered than were |
167 * expected | 167 * expected |
168 */ | 168 */ |
169 void assertErrors3(List<ErrorSeverity> expectedSeverities) { | 169 void assertErrors3(List<ErrorSeverity> expectedSeverities) { |
170 int expectedErrorCount = 0; | 170 int expectedErrorCount = 0; |
171 int expectedWarningCount = 0; | 171 int expectedWarningCount = 0; |
172 for (ErrorSeverity severity in expectedSeverities) { | 172 for (ErrorSeverity severity in expectedSeverities) { |
173 if (severity == ErrorSeverity.ERROR) { | 173 if (identical(severity, ErrorSeverity.ERROR)) { |
174 expectedErrorCount++; | 174 expectedErrorCount++; |
175 } else { | 175 } else { |
176 expectedWarningCount++; | 176 expectedWarningCount++; |
177 } | 177 } |
178 } | 178 } |
179 int actualErrorCount = 0; | 179 int actualErrorCount = 0; |
180 int actualWarningCount = 0; | 180 int actualWarningCount = 0; |
181 for (AnalysisError error in _errors) { | 181 for (AnalysisError error in _errors) { |
182 if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) { | 182 if (identical(error.errorCode.errorSeverity, ErrorSeverity.ERROR)) { |
183 actualErrorCount++; | 183 actualErrorCount++; |
184 } else { | 184 } else { |
185 actualWarningCount++; | 185 actualWarningCount++; |
186 } | 186 } |
187 } | 187 } |
188 if (expectedErrorCount != actualErrorCount || expectedWarningCount != actual
WarningCount) { | 188 if (expectedErrorCount != actualErrorCount || expectedWarningCount != actual
WarningCount) { |
189 JUnitTestCase.fail("Expected ${expectedErrorCount} errors and ${expectedWa
rningCount} warnings, found ${actualErrorCount} errors and ${actualWarningCount}
warnings"); | 189 JUnitTestCase.fail("Expected ${expectedErrorCount} errors and ${expectedWa
rningCount} warnings, found ${actualErrorCount} errors and ${actualWarningCount}
warnings"); |
190 } | 190 } |
191 } | 191 } |
192 /** | 192 /** |
193 * Assert that no errors have been gathered. | 193 * Assert that no errors have been gathered. |
194 * @throws AssertionFailedError if any errors have been gathered | 194 * @throws AssertionFailedError if any errors have been gathered |
195 */ | 195 */ |
196 void assertNoErrors() { | 196 void assertNoErrors() { |
197 assertErrors(GatheringErrorListener._NO_ERRORS); | 197 assertErrors(_NO_ERRORS); |
198 } | 198 } |
199 /** | 199 /** |
200 * Return the errors that were collected. | 200 * Return the errors that were collected. |
201 * @return the errors that were collected | 201 * @return the errors that were collected |
202 */ | 202 */ |
203 List<AnalysisError> get errors => _errors; | 203 List<AnalysisError> get errors => _errors; |
204 /** | 204 /** |
205 * Return {@code true} if an error with the given error code has been gathered
. | 205 * Return {@code true} if an error with the given error code has been gathered
. |
206 * @param errorCode the error code being searched for | 206 * @param errorCode the error code being searched for |
207 * @return {@code true} if an error with the given error code has been gathere
d | 207 * @return {@code true} if an error with the given error code has been gathere
d |
208 */ | 208 */ |
209 bool hasError(ErrorCode errorCode) { | 209 bool hasError(ErrorCode errorCode4) { |
210 for (AnalysisError error in _errors) { | 210 for (AnalysisError error in _errors) { |
211 if (error.errorCode == errorCode) { | 211 if (identical(error.errorCode, errorCode4)) { |
212 return true; | 212 return true; |
213 } | 213 } |
214 } | 214 } |
215 return false; | 215 return false; |
216 } | 216 } |
217 void onError(AnalysisError error) { | 217 void onError(AnalysisError error) { |
218 if (_rawSource != null) { | 218 if (_rawSource != null) { |
219 int left = error.offset; | 219 int left = error.offset; |
220 int right = left + error.length - 1; | 220 int right = left + error.length - 1; |
221 _markedSource = "${_rawSource.substring(0, left)}^${_rawSource.substring(l
eft, right)}^${_rawSource.substring(right)}"; | 221 _markedSource = "${_rawSource.substring(0, left)}^${_rawSource.substring(l
eft, right)}^${_rawSource.substring(right)}"; |
(...skipping 15 matching lines...) Expand all Loading... |
237 */ | 237 */ |
238 void setLineInfo2(Source source, LineInfo lineInfo) { | 238 void setLineInfo2(Source source, LineInfo lineInfo) { |
239 _lineInfoMap[source] = lineInfo; | 239 _lineInfoMap[source] = lineInfo; |
240 } | 240 } |
241 /** | 241 /** |
242 * Return {@code true} if the two errors are equivalent. | 242 * Return {@code true} if the two errors are equivalent. |
243 * @param firstError the first error being compared | 243 * @param firstError the first error being compared |
244 * @param secondError the second error being compared | 244 * @param secondError the second error being compared |
245 * @return {@code true} if the two errors are equivalent | 245 * @return {@code true} if the two errors are equivalent |
246 */ | 246 */ |
247 bool equals(AnalysisError firstError, AnalysisError secondError) => firstError
.errorCode == secondError.errorCode && firstError.offset == secondError.offset &
& firstError.length == secondError.length && equals3(firstError.source, secondEr
ror.source); | 247 bool equals(AnalysisError firstError, AnalysisError secondError) => identical(
firstError.errorCode, secondError.errorCode) && firstError.offset == secondError
.offset && firstError.length == secondError.length && equals3(firstError.source,
secondError.source); |
248 /** | 248 /** |
249 * Return {@code true} if the two sources are equivalent. | 249 * Return {@code true} if the two sources are equivalent. |
250 * @param firstSource the first source being compared | 250 * @param firstSource the first source being compared |
251 * @param secondSource the second source being compared | 251 * @param secondSource the second source being compared |
252 * @return {@code true} if the two sources are equivalent | 252 * @return {@code true} if the two sources are equivalent |
253 */ | 253 */ |
254 bool equals3(Source firstSource, Source secondSource) { | 254 bool equals3(Source firstSource, Source secondSource) { |
255 if (firstSource == null) { | 255 if (firstSource == null) { |
256 return secondSource == null; | 256 return secondSource == null; |
257 } else if (secondSource == null) { | 257 } else if (secondSource == null) { |
258 return false; | 258 return false; |
259 } | 259 } |
260 return firstSource == secondSource; | 260 return firstSource == secondSource; |
261 } | 261 } |
262 /** | 262 /** |
263 * Assert that the number of errors that have been gathered matches the number
of errors that are | 263 * Assert that the number of errors that have been gathered matches the number
of errors that are |
264 * given and that they have the expected error codes. The order in which the e
rrors were gathered | 264 * given and that they have the expected error codes. The order in which the e
rrors were gathered |
265 * is ignored. | 265 * is ignored. |
266 * @param errorCodes the errors that should have been gathered | 266 * @param errorCodes the errors that should have been gathered |
267 * @throws AssertionFailedError with | 267 * @throws AssertionFailedError with |
268 */ | 268 */ |
269 void fail(List<AnalysisError> expectedErrors) { | 269 void fail(List<AnalysisError> expectedErrors) { |
270 PrintStringWriter writer = new PrintStringWriter(); | 270 PrintStringWriter writer = new PrintStringWriter(); |
271 writer.print("Expected "); | 271 writer.print("Expected "); |
272 writer.print(expectedErrors.length); | 272 writer.print(expectedErrors.length); |
273 writer.print(" errors:"); | 273 writer.print(" errors:"); |
274 for (AnalysisError error in expectedErrors) { | 274 for (AnalysisError error in expectedErrors) { |
275 Source source5 = error.source; | 275 Source source9 = error.source; |
276 LineInfo lineInfo = _lineInfoMap[source5]; | 276 LineInfo lineInfo = _lineInfoMap[source9]; |
277 writer.println(); | 277 writer.println(); |
278 if (lineInfo == null) { | 278 if (lineInfo == null) { |
279 int offset8 = error.offset; | 279 int offset9 = error.offset; |
280 writer.printf(" %s %s (%d..%d)", [source5 == null ? "" : source5.shortN
ame, error.errorCode, offset8, offset8 + error.length]); | 280 writer.printf(" %s %s (%d..%d)", [source9 == null ? "" : source9.shortN
ame, error.errorCode, offset9, offset9 + error.length]); |
281 } else { | 281 } else { |
282 LineInfo_Location location = lineInfo.getLocation(error.offset); | 282 LineInfo_Location location = lineInfo.getLocation(error.offset); |
283 writer.printf(" %s %s (%d, %d/%d)", [source5 == null ? "" : source5.sho
rtName, error.errorCode, location.lineNumber, location.columnNumber, error.lengt
h]); | 283 writer.printf(" %s %s (%d, %d/%d)", [source9 == null ? "" : source9.sho
rtName, error.errorCode, location.lineNumber, location.columnNumber, error.lengt
h]); |
284 } | 284 } |
285 } | 285 } |
286 writer.println(); | 286 writer.println(); |
287 writer.print("found "); | 287 writer.print("found "); |
288 writer.print(_errors.length); | 288 writer.print(_errors.length); |
289 writer.print(" errors:"); | 289 writer.print(" errors:"); |
290 for (AnalysisError error in _errors) { | 290 for (AnalysisError error in _errors) { |
291 Source source6 = error.source; | 291 Source source10 = error.source; |
292 LineInfo lineInfo = _lineInfoMap[source6]; | 292 LineInfo lineInfo = _lineInfoMap[source10]; |
293 writer.println(); | 293 writer.println(); |
294 if (lineInfo == null) { | 294 if (lineInfo == null) { |
295 int offset9 = error.offset; | 295 int offset10 = error.offset; |
296 writer.printf(" %s %s (%d..%d): %s", [source6 == null ? "" : source6.sh
ortName, error.errorCode, offset9, offset9 + error.length, error.message]); | 296 writer.printf(" %s %s (%d..%d): %s", [source10 == null ? "" : source10.
shortName, error.errorCode, offset10, offset10 + error.length, error.message]); |
297 } else { | 297 } else { |
298 LineInfo_Location location = lineInfo.getLocation(error.offset); | 298 LineInfo_Location location = lineInfo.getLocation(error.offset); |
299 writer.printf(" %s %s (%d, %d/%d): %s", [source6 == null ? "" : source6
.shortName, error.errorCode, location.lineNumber, location.columnNumber, error.l
ength, error.message]); | 299 writer.printf(" %s %s (%d, %d/%d): %s", [source10 == null ? "" : source
10.shortName, error.errorCode, location.lineNumber, location.columnNumber, error
.length, error.message]); |
300 } | 300 } |
301 } | 301 } |
302 JUnitTestCase.fail(writer.toString()); | 302 JUnitTestCase.fail(writer.toString()); |
303 } | 303 } |
304 /** | 304 /** |
305 * Search through the given list of errors for an error that is equal to the t
arget error. If one | 305 * Search through the given list of errors for an error that is equal to the t
arget error. If one |
306 * is found, remove it from the list and return {@code true}, otherwise return
{@code false}without modifying the list. | 306 * is found, remove it from the list and return {@code true}, otherwise return
{@code false}without modifying the list. |
307 * @param errors the errors through which we are searching | 307 * @param errors the errors through which we are searching |
308 * @param targetError the error being searched for | 308 * @param targetError the error being searched for |
309 * @return {@code true} if the error is found and removed from the list | 309 * @return {@code true} if the error is found and removed from the list |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 369 } |
370 } | 370 } |
371 } | 371 } |
372 /** | 372 /** |
373 * Assert that a given String is equal to an expected value. | 373 * Assert that a given String is equal to an expected value. |
374 * @param expected the expected String value | 374 * @param expected the expected String value |
375 * @param actual the actual String value | 375 * @param actual the actual String value |
376 */ | 376 */ |
377 static void assertEqualString(String expected, String actual) { | 377 static void assertEqualString(String expected, String actual) { |
378 if (actual == null || expected == null) { | 378 if (actual == null || expected == null) { |
379 if (actual == expected) { | 379 if (identical(actual, expected)) { |
380 return; | 380 return; |
381 } | 381 } |
382 if (actual == null) { | 382 if (actual == null) { |
383 JUnitTestCase.assertTrueMsg("Content not as expected: is 'null' expected
: ${expected}", false); | 383 JUnitTestCase.assertTrueMsg("Content not as expected: is 'null' expected
: ${expected}", false); |
384 } else { | 384 } else { |
385 JUnitTestCase.assertTrueMsg("Content not as expected: expected 'null' is
: ${actual}", false); | 385 JUnitTestCase.assertTrueMsg("Content not as expected: expected 'null' is
: ${actual}", false); |
386 } | 386 } |
387 } | 387 } |
388 int diffPos = getDiffPos(expected, actual); | 388 int diffPos = getDiffPos(expected, actual); |
389 if (diffPos != -1) { | 389 if (diffPos != -1) { |
390 int diffAhead = Math.max(0, diffPos - EngineTestCase._PRINT_RANGE); | 390 int diffAhead = Math.max(0, diffPos - _PRINT_RANGE); |
391 int diffAfter = Math.min(actual.length, diffPos + EngineTestCase._PRINT_RA
NGE); | 391 int diffAfter = Math.min(actual.length, diffPos + _PRINT_RANGE); |
392 String diffStr = "${actual.substring(diffAhead, diffPos)}^${actual.substri
ng(diffPos, diffAfter)}"; | 392 String diffStr = "${actual.substring(diffAhead, diffPos)}^${actual.substri
ng(diffPos, diffAfter)}"; |
393 String message = "Content not as expected: is\n${actual}\nDiffers at pos $
{diffPos}: ${diffStr}\nexpected:\n${expected}"; | 393 String message = "Content not as expected: is\n${actual}\nDiffers at pos $
{diffPos}: ${diffStr}\nexpected:\n${expected}"; |
394 JUnitTestCase.assertEqualsMsg(message, expected, actual); | 394 JUnitTestCase.assertEqualsMsg(message, expected, actual); |
395 } | 395 } |
396 } | 396 } |
397 /** | 397 /** |
398 * Assert that the given list is non-{@code null} and has exactly expected ele
ments. | 398 * Assert that the given list is non-{@code null} and has exactly expected ele
ments. |
399 * @param list the list being tested | 399 * @param list the list being tested |
400 * @param expectedElements the expected elements | 400 * @param expectedElements the expected elements |
401 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected elements | 401 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected elements |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 * Assert that the given object is an instance of the expected class. | 464 * Assert that the given object is an instance of the expected class. |
465 * @param expectedClass the class that the object is expected to be an instanc
e of | 465 * @param expectedClass the class that the object is expected to be an instanc
e of |
466 * @param object the object being tested | 466 * @param object the object being tested |
467 * @return the object that was being tested | 467 * @return the object that was being tested |
468 * @throws Exception if the object is not an instance of the expected class | 468 * @throws Exception if the object is not an instance of the expected class |
469 */ | 469 */ |
470 static Object assertInstanceOf(Type expectedClass, Object object) { | 470 static Object assertInstanceOf(Type expectedClass, Object object) { |
471 if (!isInstanceOf(object, expectedClass)) { | 471 if (!isInstanceOf(object, expectedClass)) { |
472 JUnitTestCase.fail("Expected instance of ${expectedClass.toString()}, foun
d ${(object == null ? "null" : object.runtimeType.toString())}"); | 472 JUnitTestCase.fail("Expected instance of ${expectedClass.toString()}, foun
d ${(object == null ? "null" : object.runtimeType.toString())}"); |
473 } | 473 } |
474 return object as Object; | 474 return (object as Object); |
475 } | 475 } |
476 /** | 476 /** |
477 * Assert that the given array is non-{@code null} and has the expected number
of elements. | 477 * Assert that the given array is non-{@code null} and has the expected number
of elements. |
478 * @param expectedLength the expected number of elements | 478 * @param expectedLength the expected number of elements |
479 * @param array the array being tested | 479 * @param array the array being tested |
480 * @throws AssertionFailedError if the array is {@code null} or does not have
the expected number | 480 * @throws AssertionFailedError if the array is {@code null} or does not have
the expected number |
481 * of elements | 481 * of elements |
482 */ | 482 */ |
483 static void assertLength(int expectedLength, List<Object> array) { | 483 static void assertLength(int expectedLength, List<Object> array) { |
484 if (array == null) { | 484 if (array == null) { |
485 JUnitTestCase.fail("Expected array of length ${expectedLength}; found null
"); | 485 JUnitTestCase.fail("Expected array of length ${expectedLength}; found null
"); |
486 } else if (array.length != expectedLength) { | 486 } else if (array.length != expectedLength) { |
487 JUnitTestCase.fail("Expected array of length ${expectedLength}; contained
${array.length} elements"); | 487 JUnitTestCase.fail("Expected array of length ${expectedLength}; contained
${array.length} elements"); |
488 } | 488 } |
489 } | 489 } |
490 /** | 490 /** |
491 * Assert that the actual token has the same type and lexeme as the expected t
oken. Note that this | 491 * Assert that the actual token has the same type and lexeme as the expected t
oken. Note that this |
492 * does not assert anything about the offsets of the tokens (although the leng
ths will be equal). | 492 * does not assert anything about the offsets of the tokens (although the leng
ths will be equal). |
493 * @param expectedToken the token that was expected | 493 * @param expectedToken the token that was expected |
494 * @param actualToken the token that was found | 494 * @param actualToken the token that was found |
495 * @throws AssertionFailedError if the two tokens are not the same | 495 * @throws AssertionFailedError if the two tokens are not the same |
496 */ | 496 */ |
497 static void assertMatches(Token expectedToken, Token actualToken) { | 497 static void assertMatches(Token expectedToken, Token actualToken) { |
498 JUnitTestCase.assertEquals(expectedToken.type, actualToken.type); | 498 JUnitTestCase.assertEquals(expectedToken.type, actualToken.type); |
499 if (expectedToken is KeywordToken) { | 499 if (expectedToken is KeywordToken) { |
500 assertInstanceOf(KeywordToken, actualToken); | 500 assertInstanceOf(KeywordToken, actualToken); |
501 JUnitTestCase.assertEquals((expectedToken as KeywordToken).keyword, (actua
lToken as KeywordToken).keyword); | 501 JUnitTestCase.assertEquals(((expectedToken as KeywordToken)).keyword, ((ac
tualToken as KeywordToken)).keyword); |
502 } else if (expectedToken is StringToken) { | 502 } else if (expectedToken is StringToken) { |
503 assertInstanceOf(StringToken, actualToken); | 503 assertInstanceOf(StringToken, actualToken); |
504 JUnitTestCase.assertEquals((expectedToken as StringToken).lexeme, (actualT
oken as StringToken).lexeme); | 504 JUnitTestCase.assertEquals(((expectedToken as StringToken)).lexeme, ((actu
alToken as StringToken)).lexeme); |
505 } | 505 } |
506 } | 506 } |
507 /** | 507 /** |
508 * Assert that the given list is non-{@code null} and has the expected number
of elements. | 508 * Assert that the given list is non-{@code null} and has the expected number
of elements. |
509 * @param expectedSize the expected number of elements | 509 * @param expectedSize the expected number of elements |
510 * @param list the list being tested | 510 * @param list the list being tested |
511 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected number | 511 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected number |
512 * of elements | 512 * of elements |
513 */ | 513 */ |
514 static void assertSize(int expectedSize, List<Object> list) { | 514 static void assertSize(int expectedSize, List<Object> list) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 /** | 547 /** |
548 * Calculate the offset where the given strings differ. | 548 * Calculate the offset where the given strings differ. |
549 * @param str1 the first String to compare | 549 * @param str1 the first String to compare |
550 * @param str2 the second String to compare | 550 * @param str2 the second String to compare |
551 * @return the offset at which the strings differ (or <code>-1</code> if they
do not) | 551 * @return the offset at which the strings differ (or <code>-1</code> if they
do not) |
552 */ | 552 */ |
553 static int getDiffPos(String str1, String str2) { | 553 static int getDiffPos(String str1, String str2) { |
554 int len1 = Math.min(str1.length, str2.length); | 554 int len1 = Math.min(str1.length, str2.length); |
555 int diffPos = -1; | 555 int diffPos = -1; |
556 for (int i = 0; i < len1; i++) { | 556 for (int i = 0; i < len1; i++) { |
557 if (str1.charCodeAt(i) != str2.charCodeAt(i)) { | 557 if (str1.codeUnitAt(i) != str2.codeUnitAt(i)) { |
558 diffPos = i; | 558 diffPos = i; |
559 break; | 559 break; |
560 } | 560 } |
561 } | 561 } |
562 if (diffPos == -1 && str1.length != str2.length) { | 562 if (diffPos == -1 && str1.length != str2.length) { |
563 diffPos = len1; | 563 diffPos = len1; |
564 } | 564 } |
565 return diffPos; | 565 return diffPos; |
566 } | 566 } |
567 static dartSuite() { | 567 static dartSuite() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 return trampoline(target, arguments[0], arguments[1]); | 613 return trampoline(target, arguments[0], arguments[1]); |
614 case 3: | 614 case 3: |
615 return trampoline(target, arguments[0], arguments[1], arguments[2]); | 615 return trampoline(target, arguments[0], arguments[1], arguments[2]); |
616 case 4: | 616 case 4: |
617 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); | 617 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); |
618 default: | 618 default: |
619 throw new IllegalArgumentException("Not implemented for > 4 arguments"); | 619 throw new IllegalArgumentException("Not implemented for > 4 arguments"); |
620 } | 620 } |
621 } | 621 } |
622 } | 622 } |
OLD | NEW |