| 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 | |
| 4 library engine.test_support; | 3 library engine.test_support; |
| 5 | |
| 6 import 'dart:collection'; | 4 import 'dart:collection'; |
| 7 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
| 8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; | 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; |
| 9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
| 10 import 'package:analyzer_experimental/src/generated/source.dart'; | 8 import 'package:analyzer_experimental/src/generated/source.dart'; |
| 11 import 'package:analyzer_experimental/src/generated/error.dart'; | 9 import 'package:analyzer_experimental/src/generated/error.dart'; |
| 12 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
| 13 import 'package:analyzer_experimental/src/generated/element.dart' show Interface
Type, MethodElement, PropertyAccessorElement; | 11 import 'package:analyzer_experimental/src/generated/element.dart' show Interface
Type, MethodElement, PropertyAccessorElement; |
| 14 import 'package:analyzer_experimental/src/generated/engine.dart' show AnalysisCo
ntext, AnalysisContextImpl, RecordingErrorListener; | 12 import 'package:analyzer_experimental/src/generated/engine.dart' show AnalysisCo
ntext, AnalysisContextImpl, RecordingErrorListener; |
| 15 import 'package:unittest/unittest.dart' as _ut; | 13 import 'package:unittest/unittest.dart' as _ut; |
| 16 | |
| 17 | |
| 18 /** | 14 /** |
| 19 * Instances of the class {@code GatheringErrorListener} implement an error list
ener that collects | 15 * Instances of the class {@code GatheringErrorListener} implement an error list
ener that collects |
| 20 * all of the errors passed to it for later examination. | 16 * all of the errors passed to it for later examination. |
| 21 */ | 17 */ |
| 22 class GatheringErrorListener implements AnalysisErrorListener { | 18 class GatheringErrorListener implements AnalysisErrorListener { |
| 23 | 19 |
| 24 /** | 20 /** |
| 25 * The source being parsed. | 21 * The source being parsed. |
| 26 */ | 22 */ |
| 27 String _rawSource; | 23 String _rawSource; |
| 28 | 24 |
| 29 /** | 25 /** |
| 30 * The source being parsed after inserting a marker at the beginning and end o
f the range of the | 26 * The source being parsed after inserting a marker at the beginning and end o
f the range of the |
| 31 * most recent error. | 27 * most recent error. |
| 32 */ | 28 */ |
| 33 String _markedSource; | 29 String _markedSource; |
| 34 | 30 |
| 35 /** | 31 /** |
| 36 * A list containing the errors that were collected. | 32 * A list containing the errors that were collected. |
| 37 */ | 33 */ |
| 38 List<AnalysisError> _errors = new List<AnalysisError>(); | 34 List<AnalysisError> _errors = new List<AnalysisError>(); |
| 39 | 35 |
| 40 /** | 36 /** |
| 41 * A table mapping sources to the line information for the source. | 37 * A table mapping sources to the line information for the source. |
| 42 */ | 38 */ |
| 43 Map<Source, LineInfo> _lineInfoMap = new Map<Source, LineInfo>(); | 39 Map<Source, LineInfo> _lineInfoMap = new Map<Source, LineInfo>(); |
| 44 | 40 |
| 45 /** | 41 /** |
| 46 * An empty array of errors used when no errors are expected. | 42 * An empty array of errors used when no errors are expected. |
| 47 */ | 43 */ |
| 48 static List<AnalysisError> _NO_ERRORS = new List<AnalysisError>(0); | 44 static List<AnalysisError> _NO_ERRORS = new List<AnalysisError>(0); |
| 49 | 45 |
| 50 /** | 46 /** |
| 51 * Initialize a newly created error listener to collect errors. | 47 * Initialize a newly created error listener to collect errors. |
| 52 */ | 48 */ |
| 53 GatheringErrorListener() : super() { | 49 GatheringErrorListener() : super() { |
| 54 _jtd_constructor_357_impl(); | 50 _jtd_constructor_359_impl(); |
| 55 } | 51 } |
| 56 _jtd_constructor_357_impl() { | 52 _jtd_constructor_359_impl() { |
| 57 } | 53 } |
| 58 | 54 |
| 59 /** | 55 /** |
| 60 * Initialize a newly created error listener to collect errors. | 56 * Initialize a newly created error listener to collect errors. |
| 61 */ | 57 */ |
| 62 GatheringErrorListener.con1(String rawSource2) { | 58 GatheringErrorListener.con1(String rawSource2) { |
| 63 _jtd_constructor_358_impl(rawSource2); | 59 _jtd_constructor_360_impl(rawSource2); |
| 64 } | 60 } |
| 65 _jtd_constructor_358_impl(String rawSource2) { | 61 _jtd_constructor_360_impl(String rawSource2) { |
| 66 this._rawSource = rawSource2; | 62 this._rawSource = rawSource2; |
| 67 this._markedSource = rawSource2; | 63 this._markedSource = rawSource2; |
| 68 } | 64 } |
| 69 | 65 |
| 70 /** | 66 /** |
| 71 * Add all of the errors recorded by the given listener to this listener. | 67 * Add all of the errors recorded by the given listener to this listener. |
| 72 * @param listener the listener that has recorded the errors to be added | 68 * @param listener the listener that has recorded the errors to be added |
| 73 */ | 69 */ |
| 74 void addAll(RecordingErrorListener listener) { | 70 void addAll(RecordingErrorListener listener) { |
| 75 for (AnalysisError error in listener.errors) { | 71 for (AnalysisError error in listener.errors) { |
| 76 onError(error); | 72 onError(error); |
| 77 } | 73 } |
| 78 } | 74 } |
| 79 | 75 |
| 80 /** | 76 /** |
| 81 * Assert that the number of errors that have been gathered matches the number
of errors that are | 77 * Assert that the number of errors that have been gathered matches the number
of errors that are |
| 82 * given and that they have the expected error codes and locations. The order
in which the errors | 78 * given and that they have the expected error codes and locations. The order
in which the errors |
| 83 * were gathered is ignored. | 79 * were gathered is ignored. |
| 84 * @param errorCodes the errors that should have been gathered | 80 * @param errorCodes the errors that should have been gathered |
| 85 * @throws AssertionFailedError if a different number of errors have been gath
ered than were | 81 * @throws AssertionFailedError if a different number of errors have been gath
ered than were |
| 86 * expected or if they do not have the same codes and locations | 82 * expected or if they do not have the same codes and locations |
| 87 */ | 83 */ |
| 88 void assertErrors(List<AnalysisError> expectedErrors) { | 84 void assertErrors(List<AnalysisError> expectedErrors) { |
| 89 if (_errors.length != expectedErrors.length) { | 85 if (_errors.length != expectedErrors.length) { |
| 90 fail(expectedErrors); | 86 fail(expectedErrors); |
| 91 } | 87 } |
| 92 List<AnalysisError> remainingErrors = new List<AnalysisError>(); | 88 List<AnalysisError> remainingErrors = new List<AnalysisError>(); |
| 93 for (AnalysisError error in expectedErrors) { | 89 for (AnalysisError error in expectedErrors) { |
| 94 remainingErrors.add(error); | 90 remainingErrors.add(error); |
| 95 } | 91 } |
| 96 for (AnalysisError error in _errors) { | 92 for (AnalysisError error in _errors) { |
| 97 if (!foundAndRemoved(remainingErrors, error)) { | 93 if (!foundAndRemoved(remainingErrors, error)) { |
| 98 fail(expectedErrors); | 94 fail(expectedErrors); |
| 99 } | 95 } |
| 100 } | 96 } |
| 101 } | 97 } |
| 102 | 98 |
| 103 /** | 99 /** |
| 104 * Assert that the number of errors that have been gathered matches the number
of errors that are | 100 * Assert that the number of errors that have been gathered matches the number
of errors that are |
| 105 * given and that they have the expected error codes. The order in which the e
rrors were gathered | 101 * given and that they have the expected error codes. The order in which the e
rrors were gathered |
| 106 * is ignored. | 102 * is ignored. |
| 107 * @param expectedErrorCodes the error codes of the errors that should have be
en gathered | 103 * @param expectedErrorCodes the error codes of the errors that should have be
en gathered |
| 108 * @throws AssertionFailedError if a different number of errors have been gath
ered than were | 104 * @throws AssertionFailedError if a different number of errors have been gath
ered than were |
| 109 * expected | 105 * expected |
| 110 */ | 106 */ |
| 111 void assertErrors2(List<ErrorCode> expectedErrorCodes) { | 107 void assertErrors2(List<ErrorCode> expectedErrorCodes) { |
| 112 JavaStringBuilder builder = new JavaStringBuilder(); | 108 JavaStringBuilder builder = new JavaStringBuilder(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 builder.append(", "); | 172 builder.append(", "); |
| 177 } | 173 } |
| 178 builder.append(error.offset); | 174 builder.append(error.offset); |
| 179 } | 175 } |
| 180 builder.append(")"); | 176 builder.append(")"); |
| 181 } | 177 } |
| 182 if (builder.length > 0) { | 178 if (builder.length > 0) { |
| 183 JUnitTestCase.fail(builder.toString()); | 179 JUnitTestCase.fail(builder.toString()); |
| 184 } | 180 } |
| 185 } | 181 } |
| 186 | 182 |
| 187 /** | 183 /** |
| 188 * Assert that the number of errors that have been gathered matches the number
of severities that | 184 * Assert that the number of errors that have been gathered matches the number
of severities that |
| 189 * are given and that there are the same number of errors and warnings as spec
ified by the | 185 * are given and that there are the same number of errors and warnings as spec
ified by the |
| 190 * argument. The order in which the errors were gathered is ignored. | 186 * argument. The order in which the errors were gathered is ignored. |
| 191 * @param expectedSeverities the severities of the errors that should have bee
n gathered | 187 * @param expectedSeverities the severities of the errors that should have bee
n gathered |
| 192 * @throws AssertionFailedError if a different number of errors have been gath
ered than were | 188 * @throws AssertionFailedError if a different number of errors have been gath
ered than were |
| 193 * expected | 189 * expected |
| 194 */ | 190 */ |
| 195 void assertErrors3(List<ErrorSeverity> expectedSeverities) { | 191 void assertErrors3(List<ErrorSeverity> expectedSeverities) { |
| 196 int expectedErrorCount = 0; | 192 int expectedErrorCount = 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 208 if (identical(error.errorCode.errorSeverity, ErrorSeverity.ERROR)) { | 204 if (identical(error.errorCode.errorSeverity, ErrorSeverity.ERROR)) { |
| 209 actualErrorCount++; | 205 actualErrorCount++; |
| 210 } else { | 206 } else { |
| 211 actualWarningCount++; | 207 actualWarningCount++; |
| 212 } | 208 } |
| 213 } | 209 } |
| 214 if (expectedErrorCount != actualErrorCount || expectedWarningCount != actual
WarningCount) { | 210 if (expectedErrorCount != actualErrorCount || expectedWarningCount != actual
WarningCount) { |
| 215 JUnitTestCase.fail("Expected ${expectedErrorCount} errors and ${expectedWa
rningCount} warnings, found ${actualErrorCount} errors and ${actualWarningCount}
warnings"); | 211 JUnitTestCase.fail("Expected ${expectedErrorCount} errors and ${expectedWa
rningCount} warnings, found ${actualErrorCount} errors and ${actualWarningCount}
warnings"); |
| 216 } | 212 } |
| 217 } | 213 } |
| 218 | 214 |
| 219 /** | 215 /** |
| 220 * Assert that no errors have been gathered. | 216 * Assert that no errors have been gathered. |
| 221 * @throws AssertionFailedError if any errors have been gathered | 217 * @throws AssertionFailedError if any errors have been gathered |
| 222 */ | 218 */ |
| 223 void assertNoErrors() { | 219 void assertNoErrors() { |
| 224 assertErrors(_NO_ERRORS); | 220 assertErrors(_NO_ERRORS); |
| 225 } | 221 } |
| 226 | 222 |
| 227 /** | 223 /** |
| 228 * Return the errors that were collected. | 224 * Return the errors that were collected. |
| 229 * @return the errors that were collected | 225 * @return the errors that were collected |
| 230 */ | 226 */ |
| 231 List<AnalysisError> get errors => _errors; | 227 List<AnalysisError> get errors => _errors; |
| 232 | 228 |
| 233 /** | 229 /** |
| 234 * Return the line information associated with the given source, or {@code nul
l} if no line | 230 * Return the line information associated with the given source, or {@code nul
l} if no line |
| 235 * information has been associated with the source. | 231 * information has been associated with the source. |
| 236 * @param source the source with which the line information is associated | 232 * @param source the source with which the line information is associated |
| 237 * @return the line information associated with the source | 233 * @return the line information associated with the source |
| 238 */ | 234 */ |
| 239 LineInfo getLineInfo(Source source) => _lineInfoMap[source]; | 235 LineInfo getLineInfo(Source source) => _lineInfoMap[source]; |
| 240 | 236 |
| 241 /** | 237 /** |
| 242 * Return {@code true} if an error with the given error code has been gathered
. | 238 * Return {@code true} if an error with the given error code has been gathered
. |
| 243 * @param errorCode the error code being searched for | 239 * @param errorCode the error code being searched for |
| 244 * @return {@code true} if an error with the given error code has been gathere
d | 240 * @return {@code true} if an error with the given error code has been gathere
d |
| 245 */ | 241 */ |
| 246 bool hasError(ErrorCode errorCode2) { | 242 bool hasError(ErrorCode errorCode2) { |
| 247 for (AnalysisError error in _errors) { | 243 for (AnalysisError error in _errors) { |
| 248 if (identical(error.errorCode, errorCode2)) { | 244 if (identical(error.errorCode, errorCode2)) { |
| 249 return true; | 245 return true; |
| 250 } | 246 } |
| 251 } | 247 } |
| 252 return false; | 248 return false; |
| 253 } | 249 } |
| 254 | 250 |
| 255 /** | 251 /** |
| 256 * Return {@code true} if at least one error has been gathered. | 252 * Return {@code true} if at least one error has been gathered. |
| 257 * @return {@code true} if at least one error has been gathered | 253 * @return {@code true} if at least one error has been gathered |
| 258 */ | 254 */ |
| 259 bool hasErrors() => _errors.length > 0; | 255 bool hasErrors() => _errors.length > 0; |
| 260 void onError(AnalysisError error) { | 256 void onError(AnalysisError error) { |
| 261 if (_rawSource != null) { | 257 if (_rawSource != null) { |
| 262 int left = error.offset; | 258 int left = error.offset; |
| 263 int right = left + error.length - 1; | 259 int right = left + error.length - 1; |
| 264 _markedSource = "${_rawSource.substring(0, left)}^${_rawSource.substring(l
eft, right)}^${_rawSource.substring(right)}"; | 260 _markedSource = "${_rawSource.substring(0, left)}^${_rawSource.substring(l
eft, right)}^${_rawSource.substring(right)}"; |
| 265 } | 261 } |
| 266 _errors.add(error); | 262 _errors.add(error); |
| 267 } | 263 } |
| 268 | 264 |
| 269 /** | 265 /** |
| 270 * Set the line information associated with the given source to the given info
rmation. | 266 * Set the line information associated with the given source to the given info
rmation. |
| 271 * @param source the source with which the line information is associated | 267 * @param source the source with which the line information is associated |
| 272 * @param lineStarts the line start information to be associated with the sour
ce | 268 * @param lineStarts the line start information to be associated with the sour
ce |
| 273 */ | 269 */ |
| 274 void setLineInfo(Source source, List<int> lineStarts) { | 270 void setLineInfo(Source source, List<int> lineStarts) { |
| 275 _lineInfoMap[source] = new LineInfo(lineStarts); | 271 _lineInfoMap[source] = new LineInfo(lineStarts); |
| 276 } | 272 } |
| 277 | 273 |
| 278 /** | 274 /** |
| 279 * Set the line information associated with the given source to the given info
rmation. | 275 * Set the line information associated with the given source to the given info
rmation. |
| 280 * @param source the source with which the line information is associated | 276 * @param source the source with which the line information is associated |
| 281 * @param lineInfo the line information to be associated with the source | 277 * @param lineInfo the line information to be associated with the source |
| 282 */ | 278 */ |
| 283 void setLineInfo2(Source source, LineInfo lineInfo) { | 279 void setLineInfo2(Source source, LineInfo lineInfo) { |
| 284 _lineInfoMap[source] = lineInfo; | 280 _lineInfoMap[source] = lineInfo; |
| 285 } | 281 } |
| 286 | 282 |
| 287 /** | 283 /** |
| 288 * Return {@code true} if the two errors are equivalent. | 284 * Return {@code true} if the two errors are equivalent. |
| 289 * @param firstError the first error being compared | 285 * @param firstError the first error being compared |
| 290 * @param secondError the second error being compared | 286 * @param secondError the second error being compared |
| 291 * @return {@code true} if the two errors are equivalent | 287 * @return {@code true} if the two errors are equivalent |
| 292 */ | 288 */ |
| 293 bool equals3(AnalysisError firstError, AnalysisError secondError) => identical
(firstError.errorCode, secondError.errorCode) && firstError.offset == secondErro
r.offset && firstError.length == secondError.length && equals4(firstError.source
, secondError.source); | 289 bool equals3(AnalysisError firstError, AnalysisError secondError) => identical
(firstError.errorCode, secondError.errorCode) && firstError.offset == secondErro
r.offset && firstError.length == secondError.length && equals4(firstError.source
, secondError.source); |
| 294 | 290 |
| 295 /** | 291 /** |
| 296 * Return {@code true} if the two sources are equivalent. | 292 * Return {@code true} if the two sources are equivalent. |
| 297 * @param firstSource the first source being compared | 293 * @param firstSource the first source being compared |
| 298 * @param secondSource the second source being compared | 294 * @param secondSource the second source being compared |
| 299 * @return {@code true} if the two sources are equivalent | 295 * @return {@code true} if the two sources are equivalent |
| 300 */ | 296 */ |
| 301 bool equals4(Source firstSource, Source secondSource) { | 297 bool equals4(Source firstSource, Source secondSource) { |
| 302 if (firstSource == null) { | 298 if (firstSource == null) { |
| 303 return secondSource == null; | 299 return secondSource == null; |
| 304 } else if (secondSource == null) { | 300 } else if (secondSource == null) { |
| 305 return false; | 301 return false; |
| 306 } | 302 } |
| 307 return firstSource == secondSource; | 303 return firstSource == secondSource; |
| 308 } | 304 } |
| 309 | 305 |
| 310 /** | 306 /** |
| 311 * Assert that the number of errors that have been gathered matches the number
of errors that are | 307 * Assert that the number of errors that have been gathered matches the number
of errors that are |
| 312 * given and that they have the expected error codes. The order in which the e
rrors were gathered | 308 * given and that they have the expected error codes. The order in which the e
rrors were gathered |
| 313 * is ignored. | 309 * is ignored. |
| 314 * @param errorCodes the errors that should have been gathered | 310 * @param errorCodes the errors that should have been gathered |
| 315 * @throws AssertionFailedError with | 311 * @throws AssertionFailedError with |
| 316 */ | 312 */ |
| 317 void fail(List<AnalysisError> expectedErrors) { | 313 void fail(List<AnalysisError> expectedErrors) { |
| 318 PrintStringWriter writer = new PrintStringWriter(); | 314 PrintStringWriter writer = new PrintStringWriter(); |
| 319 writer.print("Expected "); | 315 writer.print("Expected "); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 342 if (lineInfo == null) { | 338 if (lineInfo == null) { |
| 343 int offset3 = error.offset; | 339 int offset3 = error.offset; |
| 344 writer.printf(" %s %s (%d..%d): %s", [source3 == null ? "" : source3.sh
ortName, error.errorCode, offset3, offset3 + error.length, error.message]); | 340 writer.printf(" %s %s (%d..%d): %s", [source3 == null ? "" : source3.sh
ortName, error.errorCode, offset3, offset3 + error.length, error.message]); |
| 345 } else { | 341 } else { |
| 346 LineInfo_Location location = lineInfo.getLocation(error.offset); | 342 LineInfo_Location location = lineInfo.getLocation(error.offset); |
| 347 writer.printf(" %s %s (%d, %d/%d): %s", [source3 == null ? "" : source3
.shortName, error.errorCode, location.lineNumber, location.columnNumber, error.l
ength, error.message]); | 343 writer.printf(" %s %s (%d, %d/%d): %s", [source3 == null ? "" : source3
.shortName, error.errorCode, location.lineNumber, location.columnNumber, error.l
ength, error.message]); |
| 348 } | 344 } |
| 349 } | 345 } |
| 350 JUnitTestCase.fail(writer.toString()); | 346 JUnitTestCase.fail(writer.toString()); |
| 351 } | 347 } |
| 352 | 348 |
| 353 /** | 349 /** |
| 354 * Search through the given list of errors for an error that is equal to the t
arget error. If one | 350 * Search through the given list of errors for an error that is equal to the t
arget error. If one |
| 355 * is found, remove it from the list and return {@code true}, otherwise return
{@code false}without modifying the list. | 351 * is found, remove it from the list and return {@code true}, otherwise return
{@code false}without modifying the list. |
| 356 * @param errors the errors through which we are searching | 352 * @param errors the errors through which we are searching |
| 357 * @param targetError the error being searched for | 353 * @param targetError the error being searched for |
| 358 * @return {@code true} if the error is found and removed from the list | 354 * @return {@code true} if the error is found and removed from the list |
| 359 */ | 355 */ |
| 360 bool foundAndRemoved(List<AnalysisError> errors, AnalysisError targetError) { | 356 bool foundAndRemoved(List<AnalysisError> errors, AnalysisError targetError) { |
| 361 for (AnalysisError error in errors) { | 357 for (AnalysisError error in errors) { |
| 362 if (equals3(error, targetError)) { | 358 if (equals3(error, targetError)) { |
| 363 errors.remove(error); | 359 errors.remove(error); |
| 364 return true; | 360 return true; |
| 365 } | 361 } |
| 366 } | 362 } |
| 367 return true; | 363 return true; |
| 368 } | 364 } |
| 369 } | 365 } |
| 370 | |
| 371 /** | 366 /** |
| 372 * The class {@code EngineTestCase} defines utility methods for making assertion
s. | 367 * The class {@code EngineTestCase} defines utility methods for making assertion
s. |
| 373 */ | 368 */ |
| 374 class EngineTestCase extends JUnitTestCase { | 369 class EngineTestCase extends JUnitTestCase { |
| 375 static int _PRINT_RANGE = 6; | 370 static int _PRINT_RANGE = 6; |
| 376 | 371 |
| 377 /** | 372 /** |
| 378 * Assert that the tokens in the actual stream of tokens have the same types a
nd lexemes as the | 373 * Assert that the tokens in the actual stream of tokens have the same types a
nd lexemes as the |
| 379 * tokens in the expected stream of tokens. Note that this does not assert any
thing about the | 374 * tokens in the expected stream of tokens. Note that this does not assert any
thing about the |
| 380 * offsets of the tokens (although the lengths will be equal). | 375 * offsets of the tokens (although the lengths will be equal). |
| 381 * @param expectedStream the head of the stream of tokens that were expected | 376 * @param expectedStream the head of the stream of tokens that were expected |
| 382 * @param actualStream the head of the stream of tokens that were actually fou
nd | 377 * @param actualStream the head of the stream of tokens that were actually fou
nd |
| 383 * @throws AssertionFailedError if the two streams of tokens are not the same | 378 * @throws AssertionFailedError if the two streams of tokens are not the same |
| 384 */ | 379 */ |
| 385 static void assertAllMatch(Token expectedStream, Token actualStream) { | 380 static void assertAllMatch(Token expectedStream, Token actualStream) { |
| 386 Token left = expectedStream; | 381 Token left = expectedStream; |
| 387 Token right = actualStream; | 382 Token right = actualStream; |
| 388 while (left.type != TokenType.EOF && right.type != TokenType.EOF) { | 383 while (left.type != TokenType.EOF && right.type != TokenType.EOF) { |
| 389 assertMatches(left, right); | 384 assertMatches(left, right); |
| 390 left = left.next; | 385 left = left.next; |
| 391 right = right.next; | 386 right = right.next; |
| 392 } | 387 } |
| 393 } | 388 } |
| 394 | 389 |
| 395 /** | 390 /** |
| 396 * Assert that the array of actual values contain exactly the same values as t
hose in the array of | 391 * Assert that the array of actual values contain exactly the same values as t
hose in the array of |
| 397 * expected value, with the exception that the order of the elements is not re
quired to be the | 392 * expected value, with the exception that the order of the elements is not re
quired to be the |
| 398 * same. | 393 * same. |
| 399 * @param expectedValues the values that are expected to be found | 394 * @param expectedValues the values that are expected to be found |
| 400 * @param actualValues the actual values that are being compared against the e
xpected values | 395 * @param actualValues the actual values that are being compared against the e
xpected values |
| 401 */ | 396 */ |
| 402 static void assertEqualsIgnoreOrder(List<Object> expectedValues, List<Object>
actualValues) { | 397 static void assertEqualsIgnoreOrder(List<Object> expectedValues, List<Object>
actualValues) { |
| 403 JUnitTestCase.assertNotNull(actualValues); | 398 JUnitTestCase.assertNotNull(actualValues); |
| 404 int expectedLength = expectedValues.length; | 399 int expectedLength = expectedValues.length; |
| 405 JUnitTestCase.assertEquals(expectedLength, actualValues.length); | 400 JUnitTestCase.assertEquals(expectedLength, actualValues.length); |
| 406 List<bool> found = new List<bool>.filled(expectedLength, false); | 401 List<bool> found = new List<bool>.filled(expectedLength, false); |
| 407 for (int i = 0; i < expectedLength; i++) { | 402 for (int i = 0; i < expectedLength; i++) { |
| 408 found[i] = false; | 403 found[i] = false; |
| 409 } | 404 } |
| 410 for (Object actualValue in actualValues) { | 405 for (Object actualValue in actualValues) { |
| 411 bool wasExpected = false; | 406 bool wasExpected = false; |
| 412 for (int i = 0; i < expectedLength; i++) { | 407 for (int i = 0; i < expectedLength; i++) { |
| 413 if (!found[i] && expectedValues[i] == actualValue) { | 408 if (!found[i] && expectedValues[i] == actualValue) { |
| 414 found[i] = true; | 409 found[i] = true; |
| 415 wasExpected = true; | 410 wasExpected = true; |
| 416 break; | 411 break; |
| 417 } | 412 } |
| 418 } | 413 } |
| 419 if (!wasExpected) { | 414 if (!wasExpected) { |
| 420 JUnitTestCase.fail("The actual value ${actualValue} was not expected"); | 415 JUnitTestCase.fail("The actual value ${actualValue} was not expected"); |
| 421 } | 416 } |
| 422 } | 417 } |
| 423 } | 418 } |
| 424 | 419 |
| 425 /** | 420 /** |
| 426 * Assert that a given String is equal to an expected value. | 421 * Assert that a given String is equal to an expected value. |
| 427 * @param expected the expected String value | 422 * @param expected the expected String value |
| 428 * @param actual the actual String value | 423 * @param actual the actual String value |
| 429 */ | 424 */ |
| 430 static void assertEqualString(String expected, String actual) { | 425 static void assertEqualString(String expected, String actual) { |
| 431 if (actual == null || expected == null) { | 426 if (actual == null || expected == null) { |
| 432 if (identical(actual, expected)) { | 427 if (identical(actual, expected)) { |
| 433 return; | 428 return; |
| 434 } | 429 } |
| 435 if (actual == null) { | 430 if (actual == null) { |
| 436 JUnitTestCase.assertTrueMsg("Content not as expected: is 'null' expected
: ${expected}", false); | 431 JUnitTestCase.assertTrueMsg("Content not as expected: is 'null' expected
: ${expected}", false); |
| 437 } else { | 432 } else { |
| 438 JUnitTestCase.assertTrueMsg("Content not as expected: expected 'null' is
: ${actual}", false); | 433 JUnitTestCase.assertTrueMsg("Content not as expected: expected 'null' is
: ${actual}", false); |
| 439 } | 434 } |
| 440 } | 435 } |
| 441 int diffPos = getDiffPos(expected, actual); | 436 int diffPos = getDiffPos(expected, actual); |
| 442 if (diffPos != -1) { | 437 if (diffPos != -1) { |
| 443 int diffAhead = Math.max(0, diffPos - _PRINT_RANGE); | 438 int diffAhead = Math.max(0, diffPos - _PRINT_RANGE); |
| 444 int diffAfter = Math.min(actual.length, diffPos + _PRINT_RANGE); | 439 int diffAfter = Math.min(actual.length, diffPos + _PRINT_RANGE); |
| 445 String diffStr = "${actual.substring(diffAhead, diffPos)}^${actual.substri
ng(diffPos, diffAfter)}"; | 440 String diffStr = "${actual.substring(diffAhead, diffPos)}^${actual.substri
ng(diffPos, diffAfter)}"; |
| 446 String message = "Content not as expected: is\n${actual}\nDiffers at pos $
{diffPos}: ${diffStr}\nexpected:\n${expected}"; | 441 String message = "Content not as expected: is\n${actual}\nDiffers at pos $
{diffPos}: ${diffStr}\nexpected:\n${expected}"; |
| 447 JUnitTestCase.assertEqualsMsg(message, expected, actual); | 442 JUnitTestCase.assertEqualsMsg(message, expected, actual); |
| 448 } | 443 } |
| 449 } | 444 } |
| 450 | 445 |
| 451 /** | 446 /** |
| 452 * Assert that the given list is non-{@code null} and has exactly expected ele
ments. | 447 * Assert that the given list is non-{@code null} and has exactly expected ele
ments. |
| 453 * @param list the list being tested | 448 * @param list the list being tested |
| 454 * @param expectedElements the expected elements | 449 * @param expectedElements the expected elements |
| 455 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected elements | 450 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected elements |
| 456 */ | 451 */ |
| 457 static void assertExactElements(List<Object> list, List<Object> expectedElemen
ts) { | 452 static void assertExactElements(List<Object> list, List<Object> expectedElemen
ts) { |
| 458 int expectedSize = expectedElements.length; | 453 int expectedSize = expectedElements.length; |
| 459 if (list == null) { | 454 if (list == null) { |
| 460 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); | 455 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); |
| 461 } | 456 } |
| 462 if (list.length != expectedSize) { | 457 if (list.length != expectedSize) { |
| 463 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${lis
t.length} elements"); | 458 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${lis
t.length} elements"); |
| 464 } | 459 } |
| 465 for (int i = 0; i < expectedElements.length; i++) { | 460 for (int i = 0; i < expectedElements.length; i++) { |
| 466 Object element = list[i]; | 461 Object element = list[i]; |
| 467 Object expectedElement = expectedElements[i]; | 462 Object expectedElement = expectedElements[i]; |
| 468 if (!element == expectedElement) { | 463 if (!element == expectedElement) { |
| 469 JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${eleme
nt}"); | 464 JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${eleme
nt}"); |
| 470 } | 465 } |
| 471 } | 466 } |
| 472 } | 467 } |
| 473 | 468 |
| 474 /** | 469 /** |
| 475 * Assert that the given array is non-{@code null} and has exactly expected el
ements. | 470 * Assert that the given array is non-{@code null} and has exactly expected el
ements. |
| 476 * @param array the array being tested | 471 * @param array the array being tested |
| 477 * @param expectedElements the expected elements | 472 * @param expectedElements the expected elements |
| 478 * @throws AssertionFailedError if the array is {@code null} or does not have
the expected | 473 * @throws AssertionFailedError if the array is {@code null} or does not have
the expected |
| 479 * elements | 474 * elements |
| 480 */ | 475 */ |
| 481 static void assertExactElements2(List<Object> array, List<Object> expectedElem
ents) { | 476 static void assertExactElements2(List<Object> array, List<Object> expectedElem
ents) { |
| 482 int expectedSize = expectedElements.length; | 477 int expectedSize = expectedElements.length; |
| 483 if (array == null) { | 478 if (array == null) { |
| 484 JUnitTestCase.fail("Expected array of size ${expectedSize}; found null"); | 479 JUnitTestCase.fail("Expected array of size ${expectedSize}; found null"); |
| 485 } | 480 } |
| 486 if (array.length != expectedSize) { | 481 if (array.length != expectedSize) { |
| 487 JUnitTestCase.fail("Expected array of size ${expectedSize}; contained ${ar
ray.length} elements"); | 482 JUnitTestCase.fail("Expected array of size ${expectedSize}; contained ${ar
ray.length} elements"); |
| 488 } | 483 } |
| 489 for (int i = 0; i < expectedElements.length; i++) { | 484 for (int i = 0; i < expectedElements.length; i++) { |
| 490 Object element = array[i]; | 485 Object element = array[i]; |
| 491 Object expectedElement = expectedElements[i]; | 486 Object expectedElement = expectedElements[i]; |
| 492 if (!element == expectedElement) { | 487 if (!element == expectedElement) { |
| 493 JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${eleme
nt}"); | 488 JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${eleme
nt}"); |
| 494 } | 489 } |
| 495 } | 490 } |
| 496 } | 491 } |
| 497 | 492 |
| 498 /** | 493 /** |
| 499 * Assert that the given list is non-{@code null} and has exactly expected ele
ments. | 494 * Assert that the given list is non-{@code null} and has exactly expected ele
ments. |
| 500 * @param set the list being tested | 495 * @param set the list being tested |
| 501 * @param expectedElements the expected elements | 496 * @param expectedElements the expected elements |
| 502 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected elements | 497 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected elements |
| 503 */ | 498 */ |
| 504 static void assertExactElements3(Set<Object> set, List<Object> expectedElement
s) { | 499 static void assertExactElements3(Set<Object> set, List<Object> expectedElement
s) { |
| 505 int expectedSize = expectedElements.length; | 500 int expectedSize = expectedElements.length; |
| 506 if (set == null) { | 501 if (set == null) { |
| 507 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); | 502 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); |
| 508 } | 503 } |
| 509 if (set.length != expectedSize) { | 504 if (set.length != expectedSize) { |
| 510 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${set
.length} elements"); | 505 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${set
.length} elements"); |
| 511 } | 506 } |
| 512 for (int i = 0; i < expectedElements.length; i++) { | 507 for (int i = 0; i < expectedElements.length; i++) { |
| 513 Object expectedElement = expectedElements[i]; | 508 Object expectedElement = expectedElements[i]; |
| 514 if (!set.contains(expectedElement)) { | 509 if (!set.contains(expectedElement)) { |
| 515 JUnitTestCase.fail("Expected ${expectedElement} in set${set}"); | 510 JUnitTestCase.fail("Expected ${expectedElement} in set${set}"); |
| 516 } | 511 } |
| 517 } | 512 } |
| 518 } | 513 } |
| 519 | 514 |
| 520 /** | 515 /** |
| 521 * Assert that the given object is an instance of the expected class. | 516 * Assert that the given object is an instance of the expected class. |
| 522 * @param expectedClass the class that the object is expected to be an instanc
e of | 517 * @param expectedClass the class that the object is expected to be an instanc
e of |
| 523 * @param object the object being tested | 518 * @param object the object being tested |
| 524 * @return the object that was being tested | 519 * @return the object that was being tested |
| 525 * @throws Exception if the object is not an instance of the expected class | 520 * @throws Exception if the object is not an instance of the expected class |
| 526 */ | 521 */ |
| 527 static Object assertInstanceOf(Type expectedClass, Object object) { | 522 static Object assertInstanceOf(Type expectedClass, Object object) { |
| 528 if (!isInstanceOf(object, expectedClass)) { | 523 if (!isInstanceOf(object, expectedClass)) { |
| 529 JUnitTestCase.fail("Expected instance of ${expectedClass.toString()}, foun
d ${(object == null ? "null" : object.runtimeType.toString())}"); | 524 JUnitTestCase.fail("Expected instance of ${expectedClass.toString()}, foun
d ${(object == null ? "null" : object.runtimeType.toString())}"); |
| 530 } | 525 } |
| 531 return object as Object; | 526 return object as Object; |
| 532 } | 527 } |
| 533 | 528 |
| 534 /** | 529 /** |
| 535 * Assert that the given array is non-{@code null} and has the expected number
of elements. | 530 * Assert that the given array is non-{@code null} and has the expected number
of elements. |
| 536 * @param expectedLength the expected number of elements | 531 * @param expectedLength the expected number of elements |
| 537 * @param array the array being tested | 532 * @param array the array being tested |
| 538 * @throws AssertionFailedError if the array is {@code null} or does not have
the expected number | 533 * @throws AssertionFailedError if the array is {@code null} or does not have
the expected number |
| 539 * of elements | 534 * of elements |
| 540 */ | 535 */ |
| 541 static void assertLength(int expectedLength, List<Object> array) { | 536 static void assertLength(int expectedLength, List<Object> array) { |
| 542 if (array == null) { | 537 if (array == null) { |
| 543 JUnitTestCase.fail("Expected array of length ${expectedLength}; found null
"); | 538 JUnitTestCase.fail("Expected array of length ${expectedLength}; found null
"); |
| 544 } else if (array.length != expectedLength) { | 539 } else if (array.length != expectedLength) { |
| 545 JUnitTestCase.fail("Expected array of length ${expectedLength}; contained
${array.length} elements"); | 540 JUnitTestCase.fail("Expected array of length ${expectedLength}; contained
${array.length} elements"); |
| 546 } | 541 } |
| 547 } | 542 } |
| 548 | 543 |
| 549 /** | 544 /** |
| 550 * Assert that the actual token has the same type and lexeme as the expected t
oken. Note that this | 545 * Assert that the actual token has the same type and lexeme as the expected t
oken. Note that this |
| 551 * does not assert anything about the offsets of the tokens (although the leng
ths will be equal). | 546 * does not assert anything about the offsets of the tokens (although the leng
ths will be equal). |
| 552 * @param expectedToken the token that was expected | 547 * @param expectedToken the token that was expected |
| 553 * @param actualToken the token that was found | 548 * @param actualToken the token that was found |
| 554 * @throws AssertionFailedError if the two tokens are not the same | 549 * @throws AssertionFailedError if the two tokens are not the same |
| 555 */ | 550 */ |
| 556 static void assertMatches(Token expectedToken, Token actualToken) { | 551 static void assertMatches(Token expectedToken, Token actualToken) { |
| 557 JUnitTestCase.assertEquals(expectedToken.type, actualToken.type); | 552 JUnitTestCase.assertEquals(expectedToken.type, actualToken.type); |
| 558 if (expectedToken is KeywordToken) { | 553 if (expectedToken is KeywordToken) { |
| 559 assertInstanceOf(KeywordToken, actualToken); | 554 assertInstanceOf(KeywordToken, actualToken); |
| 560 JUnitTestCase.assertEquals(((expectedToken as KeywordToken)).keyword, ((ac
tualToken as KeywordToken)).keyword); | 555 JUnitTestCase.assertEquals(((expectedToken as KeywordToken)).keyword, ((ac
tualToken as KeywordToken)).keyword); |
| 561 } else if (expectedToken is StringToken) { | 556 } else if (expectedToken is StringToken) { |
| 562 assertInstanceOf(StringToken, actualToken); | 557 assertInstanceOf(StringToken, actualToken); |
| 563 JUnitTestCase.assertEquals(((expectedToken as StringToken)).lexeme, ((actu
alToken as StringToken)).lexeme); | 558 JUnitTestCase.assertEquals(((expectedToken as StringToken)).lexeme, ((actu
alToken as StringToken)).lexeme); |
| 564 } | 559 } |
| 565 } | 560 } |
| 566 | 561 |
| 567 /** | 562 /** |
| 568 * Assert that the given list is non-{@code null} and has the expected number
of elements. | 563 * Assert that the given list is non-{@code null} and has the expected number
of elements. |
| 569 * @param expectedSize the expected number of elements | 564 * @param expectedSize the expected number of elements |
| 570 * @param list the list being tested | 565 * @param list the list being tested |
| 571 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected number | 566 * @throws AssertionFailedError if the list is {@code null} or does not have t
he expected number |
| 572 * of elements | 567 * of elements |
| 573 */ | 568 */ |
| 574 static void assertSize(int expectedSize, List<Object> list) { | 569 static void assertSize(int expectedSize, List<Object> list) { |
| 575 if (list == null) { | 570 if (list == null) { |
| 576 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); | 571 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); |
| 577 } else if (list.length != expectedSize) { | 572 } else if (list.length != expectedSize) { |
| 578 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${lis
t.length} elements"); | 573 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${lis
t.length} elements"); |
| 579 } | 574 } |
| 580 } | 575 } |
| 581 | 576 |
| 582 /** | 577 /** |
| 583 * Assert that the given map is non-{@code null} and has the expected number o
f elements. | 578 * Assert that the given map is non-{@code null} and has the expected number o
f elements. |
| 584 * @param expectedSize the expected number of elements | 579 * @param expectedSize the expected number of elements |
| 585 * @param map the map being tested | 580 * @param map the map being tested |
| 586 * @throws AssertionFailedError if the map is {@code null} or does not have th
e expected number of | 581 * @throws AssertionFailedError if the map is {@code null} or does not have th
e expected number of |
| 587 * elements | 582 * elements |
| 588 */ | 583 */ |
| 589 static void assertSize2(int expectedSize, Map<Object, Object> map) { | 584 static void assertSize2(int expectedSize, Map<Object, Object> map) { |
| 590 if (map == null) { | 585 if (map == null) { |
| 591 JUnitTestCase.fail("Expected map of size ${expectedSize}; found null"); | 586 JUnitTestCase.fail("Expected map of size ${expectedSize}; found null"); |
| 592 } else if (map.length != expectedSize) { | 587 } else if (map.length != expectedSize) { |
| 593 JUnitTestCase.fail("Expected map of size ${expectedSize}; contained ${map.
length} elements"); | 588 JUnitTestCase.fail("Expected map of size ${expectedSize}; contained ${map.
length} elements"); |
| 594 } | 589 } |
| 595 } | 590 } |
| 596 | 591 |
| 597 /** | 592 /** |
| 598 * Assert that the given set is non-{@code null} and has the expected number o
f elements. | 593 * Assert that the given set is non-{@code null} and has the expected number o
f elements. |
| 599 * @param expectedSize the expected number of elements | 594 * @param expectedSize the expected number of elements |
| 600 * @param set the set being tested | 595 * @param set the set being tested |
| 601 * @throws AssertionFailedError if the set is {@code null} or does not have th
e expected number of | 596 * @throws AssertionFailedError if the set is {@code null} or does not have th
e expected number of |
| 602 * elements | 597 * elements |
| 603 */ | 598 */ |
| 604 static void assertSize3(int expectedSize, Set<Object> set) { | 599 static void assertSize3(int expectedSize, Set<Object> set) { |
| 605 if (set == null) { | 600 if (set == null) { |
| 606 JUnitTestCase.fail("Expected set of size ${expectedSize}; found null"); | 601 JUnitTestCase.fail("Expected set of size ${expectedSize}; found null"); |
| 607 } else if (set.length != expectedSize) { | 602 } else if (set.length != expectedSize) { |
| 608 JUnitTestCase.fail("Expected set of size ${expectedSize}; contained ${set.
length} elements"); | 603 JUnitTestCase.fail("Expected set of size ${expectedSize}; contained ${set.
length} elements"); |
| 609 } | 604 } |
| 610 } | 605 } |
| 611 | 606 |
| 612 /** | 607 /** |
| 613 * Convert the given array of lines into a single source string. | 608 * Convert the given array of lines into a single source string. |
| 614 * @param lines the lines to be merged into a single source string | 609 * @param lines the lines to be merged into a single source string |
| 615 * @return the source string composed of the given lines | 610 * @return the source string composed of the given lines |
| 616 */ | 611 */ |
| 617 static String createSource(List<String> lines) { | 612 static String createSource(List<String> lines) { |
| 618 PrintStringWriter writer = new PrintStringWriter(); | 613 PrintStringWriter writer = new PrintStringWriter(); |
| 619 for (String line in lines) { | 614 for (String line in lines) { |
| 620 writer.println(line); | 615 writer.println(line); |
| 621 } | 616 } |
| 622 return writer.toString(); | 617 return writer.toString(); |
| 623 } | 618 } |
| 624 | 619 |
| 625 /** | 620 /** |
| 626 * Calculate the offset where the given strings differ. | 621 * Calculate the offset where the given strings differ. |
| 627 * @param str1 the first String to compare | 622 * @param str1 the first String to compare |
| 628 * @param str2 the second String to compare | 623 * @param str2 the second String to compare |
| 629 * @return the offset at which the strings differ (or <code>-1</code> if they
do not) | 624 * @return the offset at which the strings differ (or <code>-1</code> if they
do not) |
| 630 */ | 625 */ |
| 631 static int getDiffPos(String str1, String str2) { | 626 static int getDiffPos(String str1, String str2) { |
| 632 int len1 = Math.min(str1.length, str2.length); | 627 int len1 = Math.min(str1.length, str2.length); |
| 633 int diffPos = -1; | 628 int diffPos = -1; |
| 634 for (int i = 0; i < len1; i++) { | 629 for (int i = 0; i < len1; i++) { |
| 635 if (str1.codeUnitAt(i) != str2.codeUnitAt(i)) { | 630 if (str1.codeUnitAt(i) != str2.codeUnitAt(i)) { |
| 636 diffPos = i; | 631 diffPos = i; |
| 637 break; | 632 break; |
| 638 } | 633 } |
| 639 } | 634 } |
| 640 if (diffPos == -1 && str1.length != str2.length) { | 635 if (diffPos == -1 && str1.length != str2.length) { |
| 641 diffPos = len1; | 636 diffPos = len1; |
| 642 } | 637 } |
| 643 return diffPos; | 638 return diffPos; |
| 644 } | 639 } |
| 645 AnalysisContextImpl createAnalysisContext() { | 640 AnalysisContextImpl createAnalysisContext() { |
| 646 AnalysisContextImpl context = new AnalysisContextImpl(); | 641 AnalysisContextImpl context = new AnalysisContextImpl(); |
| 647 context.sourceFactory = new SourceFactory.con2([]); | 642 context.sourceFactory = new SourceFactory.con2([]); |
| 648 return context; | 643 return context; |
| 649 } | 644 } |
| 650 | 645 |
| 651 /** | 646 /** |
| 652 * Return the getter in the given type with the given name. Inherited getters
are ignored. | 647 * Return the getter in the given type with the given name. Inherited getters
are ignored. |
| 653 * @param type the type in which the getter is declared | 648 * @param type the type in which the getter is declared |
| 654 * @param getterName the name of the getter to be returned | 649 * @param getterName the name of the getter to be returned |
| 655 * @return the property accessor element representing the getter with the give
n name | 650 * @return the property accessor element representing the getter with the give
n name |
| 656 */ | 651 */ |
| 657 PropertyAccessorElement getGetter(InterfaceType type, String getterName) { | 652 PropertyAccessorElement getGetter(InterfaceType type, String getterName) { |
| 658 for (PropertyAccessorElement accessor in type.element.accessors) { | 653 for (PropertyAccessorElement accessor in type.element.accessors) { |
| 659 if (accessor.isGetter() && accessor.name == getterName) { | 654 if (accessor.isGetter() && accessor.name == getterName) { |
| 660 return accessor; | 655 return accessor; |
| 661 } | 656 } |
| 662 } | 657 } |
| 663 JUnitTestCase.fail("Could not find getter named ${getterName} in ${type.disp
layName}"); | 658 JUnitTestCase.fail("Could not find getter named ${getterName} in ${type.disp
layName}"); |
| 664 return null; | 659 return null; |
| 665 } | 660 } |
| 666 | 661 |
| 667 /** | 662 /** |
| 668 * Return the method in the given type with the given name. Inherited methods
are ignored. | 663 * Return the method in the given type with the given name. Inherited methods
are ignored. |
| 669 * @param type the type in which the method is declared | 664 * @param type the type in which the method is declared |
| 670 * @param methodName the name of the method to be returned | 665 * @param methodName the name of the method to be returned |
| 671 * @return the method element representing the method with the given name | 666 * @return the method element representing the method with the given name |
| 672 */ | 667 */ |
| 673 MethodElement getMethod(InterfaceType type, String methodName) { | 668 MethodElement getMethod(InterfaceType type, String methodName) { |
| 674 for (MethodElement method in type.element.methods) { | 669 for (MethodElement method in type.element.methods) { |
| 675 if (method.name == methodName) { | 670 if (method.name == methodName) { |
| 676 return method; | 671 return method; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 return trampoline(target, arguments[0], arguments[1]); | 740 return trampoline(target, arguments[0], arguments[1]); |
| 746 case 3: | 741 case 3: |
| 747 return trampoline(target, arguments[0], arguments[1], arguments[2]); | 742 return trampoline(target, arguments[0], arguments[1], arguments[2]); |
| 748 case 4: | 743 case 4: |
| 749 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); | 744 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); |
| 750 default: | 745 default: |
| 751 throw new IllegalArgumentException("Not implemented for > 4 arguments"); | 746 throw new IllegalArgumentException("Not implemented for > 4 arguments"); |
| 752 } | 747 } |
| 753 } | 748 } |
| 754 } | 749 } |
| OLD | NEW |