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

Side by Side Diff: pkg/analyzer_experimental/test/generated/test_support.dart

Issue 17249003: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 // 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 library engine.test_support; 3 library engine.test_support;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'package:analyzer_experimental/src/generated/java_core.dart'; 5 import 'package:analyzer_experimental/src/generated/java_core.dart';
6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 6 import 'package:analyzer_experimental/src/generated/java_engine.dart';
7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 7 import 'package:analyzer_experimental/src/generated/java_junit.dart';
8 import 'package:analyzer_experimental/src/generated/source.dart'; 8 import 'package:analyzer_experimental/src/generated/source.dart';
9 import 'package:analyzer_experimental/src/generated/error.dart'; 9 import 'package:analyzer_experimental/src/generated/error.dart';
10 import 'package:analyzer_experimental/src/generated/scanner.dart'; 10 import 'package:analyzer_experimental/src/generated/scanner.dart';
11 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;
12 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;
13 import 'package:unittest/unittest.dart' as _ut; 13 import 'package:unittest/unittest.dart' as _ut;
14 /** 14 /**
15 * Instances of the class {@code GatheringErrorListener} implement an error list ener that collects 15 * Instances of the class `GatheringErrorListener` implement an error listener t hat collects
16 * all of the errors passed to it for later examination. 16 * all of the errors passed to it for later examination.
17 */ 17 */
18 class GatheringErrorListener implements AnalysisErrorListener { 18 class GatheringErrorListener implements AnalysisErrorListener {
19 19
20 /** 20 /**
21 * The source being parsed. 21 * The source being parsed.
22 */ 22 */
23 String _rawSource; 23 String _rawSource;
24 24
25 /** 25 /**
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 assertErrors(_NO_ERRORS); 220 assertErrors(_NO_ERRORS);
221 } 221 }
222 222
223 /** 223 /**
224 * Return the errors that were collected. 224 * Return the errors that were collected.
225 * @return the errors that were collected 225 * @return the errors that were collected
226 */ 226 */
227 List<AnalysisError> get errors => _errors; 227 List<AnalysisError> get errors => _errors;
228 228
229 /** 229 /**
230 * 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 `null` if no line
231 * information has been associated with the source. 231 * information has been associated with the source.
232 * @param source the source with which the line information is associated 232 * @param source the source with which the line information is associated
233 * @return the line information associated with the source 233 * @return the line information associated with the source
234 */ 234 */
235 LineInfo getLineInfo(Source source) => _lineInfoMap[source]; 235 LineInfo getLineInfo(Source source) => _lineInfoMap[source];
236 236
237 /** 237 /**
238 * Return {@code true} if an error with the given error code has been gathered . 238 * Return `true` if an error with the given error code has been gathered.
239 * @param errorCode the error code being searched for 239 * @param errorCode the error code being searched for
240 * @return {@code true} if an error with the given error code has been gathere d 240 * @return `true` if an error with the given error code has been gathered
241 */ 241 */
242 bool hasError(ErrorCode errorCode2) { 242 bool hasError(ErrorCode errorCode2) {
243 for (AnalysisError error in _errors) { 243 for (AnalysisError error in _errors) {
244 if (identical(error.errorCode, errorCode2)) { 244 if (identical(error.errorCode, errorCode2)) {
245 return true; 245 return true;
246 } 246 }
247 } 247 }
248 return false; 248 return false;
249 } 249 }
250 250
251 /** 251 /**
252 * Return {@code true} if at least one error has been gathered. 252 * Return `true` if at least one error has been gathered.
253 * @return {@code true} if at least one error has been gathered 253 * @return `true` if at least one error has been gathered
254 */ 254 */
255 bool hasErrors() => _errors.length > 0; 255 bool hasErrors() => _errors.length > 0;
256 void onError(AnalysisError error) { 256 void onError(AnalysisError error) {
257 if (_rawSource != null) { 257 if (_rawSource != null) {
258 int left = error.offset; 258 int left = error.offset;
259 int right = left + error.length - 1; 259 int right = left + error.length - 1;
260 _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)}";
261 } 261 }
262 _errors.add(error); 262 _errors.add(error);
263 } 263 }
(...skipping 10 matching lines...) Expand all
274 /** 274 /**
275 * 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.
276 * @param source the source with which the line information is associated 276 * @param source the source with which the line information is associated
277 * @param lineInfo the line information to be associated with the source 277 * @param lineInfo the line information to be associated with the source
278 */ 278 */
279 void setLineInfo2(Source source, LineInfo lineInfo) { 279 void setLineInfo2(Source source, LineInfo lineInfo) {
280 _lineInfoMap[source] = lineInfo; 280 _lineInfoMap[source] = lineInfo;
281 } 281 }
282 282
283 /** 283 /**
284 * Return {@code true} if the two errors are equivalent. 284 * Return `true` if the two errors are equivalent.
285 * @param firstError the first error being compared 285 * @param firstError the first error being compared
286 * @param secondError the second error being compared 286 * @param secondError the second error being compared
287 * @return {@code true} if the two errors are equivalent 287 * @return `true` if the two errors are equivalent
288 */ 288 */
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); 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);
290 290
291 /** 291 /**
292 * Return {@code true} if the two sources are equivalent. 292 * Return `true` if the two sources are equivalent.
293 * @param firstSource the first source being compared 293 * @param firstSource the first source being compared
294 * @param secondSource the second source being compared 294 * @param secondSource the second source being compared
295 * @return {@code true} if the two sources are equivalent 295 * @return `true` if the two sources are equivalent
296 */ 296 */
297 bool equals4(Source firstSource, Source secondSource) { 297 bool equals4(Source firstSource, Source secondSource) {
298 if (firstSource == null) { 298 if (firstSource == null) {
299 return secondSource == null; 299 return secondSource == null;
300 } else if (secondSource == null) { 300 } else if (secondSource == null) {
301 return false; 301 return false;
302 } 302 }
303 return firstSource == secondSource; 303 return firstSource == secondSource;
304 } 304 }
305 305
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } else { 341 } else {
342 LineInfo_Location location = lineInfo.getLocation(error.offset); 342 LineInfo_Location location = lineInfo.getLocation(error.offset);
343 writer.printf(" %s %s (%d, %d/%d): %s", [source == null ? "" : source.s hortName, error.errorCode, location.lineNumber, location.columnNumber, error.len gth, error.message]); 343 writer.printf(" %s %s (%d, %d/%d): %s", [source == null ? "" : source.s hortName, error.errorCode, location.lineNumber, location.columnNumber, error.len gth, error.message]);
344 } 344 }
345 } 345 }
346 JUnitTestCase.fail(writer.toString()); 346 JUnitTestCase.fail(writer.toString());
347 } 347 }
348 348
349 /** 349 /**
350 * 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
351 * 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 `true`, otherwise return `fals e`without modifying the list.
352 * @param errors the errors through which we are searching 352 * @param errors the errors through which we are searching
353 * @param targetError the error being searched for 353 * @param targetError the error being searched for
354 * @return {@code true} if the error is found and removed from the list 354 * @return `true` if the error is found and removed from the list
355 */ 355 */
356 bool foundAndRemoved(List<AnalysisError> errors, AnalysisError targetError) { 356 bool foundAndRemoved(List<AnalysisError> errors, AnalysisError targetError) {
357 for (AnalysisError error in errors) { 357 for (AnalysisError error in errors) {
358 if (equals3(error, targetError)) { 358 if (equals3(error, targetError)) {
359 errors.remove(error); 359 errors.remove(error);
360 return true; 360 return true;
361 } 361 }
362 } 362 }
363 return true; 363 return true;
364 } 364 }
365 } 365 }
366 /** 366 /**
367 * The class {@code EngineTestCase} defines utility methods for making assertion s. 367 * The class `EngineTestCase` defines utility methods for making assertions.
368 */ 368 */
369 class EngineTestCase extends JUnitTestCase { 369 class EngineTestCase extends JUnitTestCase {
370 static int _PRINT_RANGE = 6; 370 static int _PRINT_RANGE = 6;
371 371
372 /** 372 /**
373 * 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
374 * 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
375 * offsets of the tokens (although the lengths will be equal). 375 * offsets of the tokens (although the lengths will be equal).
376 * @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
377 * @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
378 * @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
379 */ 379 */
380 static void assertAllMatch(Token expectedStream, Token actualStream) { 380 static void assertAllMatch(Token expectedStream, Token actualStream) {
381 Token left = expectedStream; 381 Token left = expectedStream;
382 Token right = actualStream; 382 Token right = actualStream;
383 while (left.type != TokenType.EOF && right.type != TokenType.EOF) { 383 while (left.type != TokenType.EOF && right.type != TokenType.EOF) {
384 assertMatches(left, right); 384 assertMatches(left, right);
385 left = left.next; 385 left = left.next;
386 right = right.next; 386 right = right.next;
387 } 387 }
388 } 388 }
389 389
390 /** 390 /**
391 * Assert that the given array is non-{@code null} and contains the expected e lements. The 391 * Assert that the given array is non-`null` and contains the expected element s. The
392 * elements can appear in any order. 392 * elements can appear in any order.
393 * @param array the array being tested 393 * @param array the array being tested
394 * @param expectedElements the expected elements 394 * @param expectedElements the expected elements
395 * @throws AssertionFailedError if the array is {@code null} or does not conta in the expected 395 * @throws AssertionFailedError if the array is `null` or does not contain the expected
396 * elements 396 * elements
397 */ 397 */
398 static void assertContains(List<Object> array, List<Object> expectedElements) { 398 static void assertContains(List<Object> array, List<Object> expectedElements) {
399 int expectedSize = expectedElements.length; 399 int expectedSize = expectedElements.length;
400 if (array == null) { 400 if (array == null) {
401 JUnitTestCase.fail("Expected array of length ${expectedSize}; found null") ; 401 JUnitTestCase.fail("Expected array of length ${expectedSize}; found null") ;
402 } 402 }
403 if (array.length != expectedSize) { 403 if (array.length != expectedSize) {
404 JUnitTestCase.fail("Expected array of length ${expectedSize}; contained ${ array.length} elements"); 404 JUnitTestCase.fail("Expected array of length ${expectedSize}; contained ${ array.length} elements");
405 } 405 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (diffPos != -1) { 459 if (diffPos != -1) {
460 int diffAhead = Math.max(0, diffPos - _PRINT_RANGE); 460 int diffAhead = Math.max(0, diffPos - _PRINT_RANGE);
461 int diffAfter = Math.min(actual.length, diffPos + _PRINT_RANGE); 461 int diffAfter = Math.min(actual.length, diffPos + _PRINT_RANGE);
462 String diffStr = "${actual.substring(diffAhead, diffPos)}^${actual.substri ng(diffPos, diffAfter)}"; 462 String diffStr = "${actual.substring(diffAhead, diffPos)}^${actual.substri ng(diffPos, diffAfter)}";
463 String message = "Content not as expected: is\n${actual}\nDiffers at pos $ {diffPos}: ${diffStr}\nexpected:\n${expected}"; 463 String message = "Content not as expected: is\n${actual}\nDiffers at pos $ {diffPos}: ${diffStr}\nexpected:\n${expected}";
464 JUnitTestCase.assertEqualsMsg(message, expected, actual); 464 JUnitTestCase.assertEqualsMsg(message, expected, actual);
465 } 465 }
466 } 466 }
467 467
468 /** 468 /**
469 * Assert that the given list is non-{@code null} and has exactly expected ele ments. 469 * Assert that the given list is non-`null` and has exactly expected elements.
470 * @param list the list being tested 470 * @param list the list being tested
471 * @param expectedElements the expected elements 471 * @param expectedElements the expected elements
472 * @throws AssertionFailedError if the list is {@code null} or does not have t he expected elements 472 * @throws AssertionFailedError if the list is `null` or does not have the exp ected elements
473 */ 473 */
474 static void assertExactElements(List<Object> list, List<Object> expectedElemen ts) { 474 static void assertExactElements(List<Object> list, List<Object> expectedElemen ts) {
475 int expectedSize = expectedElements.length; 475 int expectedSize = expectedElements.length;
476 if (list == null) { 476 if (list == null) {
477 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); 477 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null");
478 } 478 }
479 if (list.length != expectedSize) { 479 if (list.length != expectedSize) {
480 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${lis t.length} elements"); 480 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${lis t.length} elements");
481 } 481 }
482 for (int i = 0; i < expectedSize; i++) { 482 for (int i = 0; i < expectedSize; i++) {
483 Object element = list[i]; 483 Object element = list[i];
484 Object expectedElement = expectedElements[i]; 484 Object expectedElement = expectedElements[i];
485 if (!element == expectedElement) { 485 if (!element == expectedElement) {
486 JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${eleme nt}"); 486 JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${eleme nt}");
487 } 487 }
488 } 488 }
489 } 489 }
490 490
491 /** 491 /**
492 * Assert that the given array is non-{@code null} and has exactly expected el ements. 492 * Assert that the given array is non-`null` and has exactly expected elements .
493 * @param array the array being tested 493 * @param array the array being tested
494 * @param expectedElements the expected elements 494 * @param expectedElements the expected elements
495 * @throws AssertionFailedError if the array is {@code null} or does not have the expected 495 * @throws AssertionFailedError if the array is `null` or does not have the ex pected
496 * elements 496 * elements
497 */ 497 */
498 static void assertExactElements2(List<Object> array, List<Object> expectedElem ents) { 498 static void assertExactElements2(List<Object> array, List<Object> expectedElem ents) {
499 int expectedSize = expectedElements.length; 499 int expectedSize = expectedElements.length;
500 if (array == null) { 500 if (array == null) {
501 JUnitTestCase.fail("Expected array of size ${expectedSize}; found null"); 501 JUnitTestCase.fail("Expected array of size ${expectedSize}; found null");
502 } 502 }
503 if (array.length != expectedSize) { 503 if (array.length != expectedSize) {
504 JUnitTestCase.fail("Expected array of size ${expectedSize}; contained ${ar ray.length} elements"); 504 JUnitTestCase.fail("Expected array of size ${expectedSize}; contained ${ar ray.length} elements");
505 } 505 }
506 for (int i = 0; i < expectedSize; i++) { 506 for (int i = 0; i < expectedSize; i++) {
507 Object element = array[i]; 507 Object element = array[i];
508 Object expectedElement = expectedElements[i]; 508 Object expectedElement = expectedElements[i];
509 if (!element == expectedElement) { 509 if (!element == expectedElement) {
510 JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${eleme nt}"); 510 JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${eleme nt}");
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 /** 515 /**
516 * Assert that the given list is non-{@code null} and has exactly expected ele ments. 516 * Assert that the given list is non-`null` and has exactly expected elements.
517 * @param set the list being tested 517 * @param set the list being tested
518 * @param expectedElements the expected elements 518 * @param expectedElements the expected elements
519 * @throws AssertionFailedError if the list is {@code null} or does not have t he expected elements 519 * @throws AssertionFailedError if the list is `null` or does not have the exp ected elements
520 */ 520 */
521 static void assertExactElements3(Set<Object> set, List<Object> expectedElement s) { 521 static void assertExactElements3(Set<Object> set, List<Object> expectedElement s) {
522 int expectedSize = expectedElements.length; 522 int expectedSize = expectedElements.length;
523 if (set == null) { 523 if (set == null) {
524 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); 524 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null");
525 } 525 }
526 if (set.length != expectedSize) { 526 if (set.length != expectedSize) {
527 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${set .length} elements"); 527 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${set .length} elements");
528 } 528 }
529 for (int i = 0; i < expectedSize; i++) { 529 for (int i = 0; i < expectedSize; i++) {
(...skipping 12 matching lines...) Expand all
542 * @throws Exception if the object is not an instance of the expected class 542 * @throws Exception if the object is not an instance of the expected class
543 */ 543 */
544 static Object assertInstanceOf(Type expectedClass, Object object) { 544 static Object assertInstanceOf(Type expectedClass, Object object) {
545 if (!isInstanceOf(object, expectedClass)) { 545 if (!isInstanceOf(object, expectedClass)) {
546 JUnitTestCase.fail("Expected instance of ${expectedClass.toString()}, foun d ${(object == null ? "null" : object.runtimeType.toString())}"); 546 JUnitTestCase.fail("Expected instance of ${expectedClass.toString()}, foun d ${(object == null ? "null" : object.runtimeType.toString())}");
547 } 547 }
548 return object as Object; 548 return object as Object;
549 } 549 }
550 550
551 /** 551 /**
552 * Assert that the given array is non-{@code null} and has the expected number of elements. 552 * Assert that the given array is non-`null` and has the expected number of el ements.
553 * @param expectedLength the expected number of elements 553 * @param expectedLength the expected number of elements
554 * @param array the array being tested 554 * @param array the array being tested
555 * @throws AssertionFailedError if the array is {@code null} or does not have the expected number 555 * @throws AssertionFailedError if the array is `null` or does not have the ex pected number
556 * of elements 556 * of elements
557 */ 557 */
558 static void assertLength(int expectedLength, List<Object> array) { 558 static void assertLength(int expectedLength, List<Object> array) {
559 if (array == null) { 559 if (array == null) {
560 JUnitTestCase.fail("Expected array of length ${expectedLength}; found null "); 560 JUnitTestCase.fail("Expected array of length ${expectedLength}; found null ");
561 } else if (array.length != expectedLength) { 561 } else if (array.length != expectedLength) {
562 JUnitTestCase.fail("Expected array of length ${expectedLength}; contained ${array.length} elements"); 562 JUnitTestCase.fail("Expected array of length ${expectedLength}; contained ${array.length} elements");
563 } 563 }
564 } 564 }
565 565
566 /** 566 /**
567 * Assert that the actual token has the same type and lexeme as the expected t oken. Note that this 567 * Assert that the actual token has the same type and lexeme as the expected t oken. Note that this
568 * does not assert anything about the offsets of the tokens (although the leng ths will be equal). 568 * does not assert anything about the offsets of the tokens (although the leng ths will be equal).
569 * @param expectedToken the token that was expected 569 * @param expectedToken the token that was expected
570 * @param actualToken the token that was found 570 * @param actualToken the token that was found
571 * @throws AssertionFailedError if the two tokens are not the same 571 * @throws AssertionFailedError if the two tokens are not the same
572 */ 572 */
573 static void assertMatches(Token expectedToken, Token actualToken) { 573 static void assertMatches(Token expectedToken, Token actualToken) {
574 JUnitTestCase.assertEquals(expectedToken.type, actualToken.type); 574 JUnitTestCase.assertEquals(expectedToken.type, actualToken.type);
575 if (expectedToken is KeywordToken) { 575 if (expectedToken is KeywordToken) {
576 assertInstanceOf(KeywordToken, actualToken); 576 assertInstanceOf(KeywordToken, actualToken);
577 JUnitTestCase.assertEquals(((expectedToken as KeywordToken)).keyword, ((ac tualToken as KeywordToken)).keyword); 577 JUnitTestCase.assertEquals(((expectedToken as KeywordToken)).keyword, ((ac tualToken as KeywordToken)).keyword);
578 } else if (expectedToken is StringToken) { 578 } else if (expectedToken is StringToken) {
579 assertInstanceOf(StringToken, actualToken); 579 assertInstanceOf(StringToken, actualToken);
580 JUnitTestCase.assertEquals(((expectedToken as StringToken)).lexeme, ((actu alToken as StringToken)).lexeme); 580 JUnitTestCase.assertEquals(((expectedToken as StringToken)).lexeme, ((actu alToken as StringToken)).lexeme);
581 } 581 }
582 } 582 }
583 583
584 /** 584 /**
585 * Assert that the given list is non-{@code null} and has the expected number of elements. 585 * Assert that the given list is non-`null` and has the expected number of ele ments.
586 * @param expectedSize the expected number of elements 586 * @param expectedSize the expected number of elements
587 * @param list the list being tested 587 * @param list the list being tested
588 * @throws AssertionFailedError if the list is {@code null} or does not have t he expected number 588 * @throws AssertionFailedError if the list is `null` or does not have the exp ected number
589 * of elements 589 * of elements
590 */ 590 */
591 static void assertSize(int expectedSize, List<Object> list) { 591 static void assertSize(int expectedSize, List<Object> list) {
592 if (list == null) { 592 if (list == null) {
593 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); 593 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null");
594 } else if (list.length != expectedSize) { 594 } else if (list.length != expectedSize) {
595 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${lis t.length} elements"); 595 JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${lis t.length} elements");
596 } 596 }
597 } 597 }
598 598
599 /** 599 /**
600 * Assert that the given map is non-{@code null} and has the expected number o f elements. 600 * Assert that the given map is non-`null` and has the expected number of elem ents.
601 * @param expectedSize the expected number of elements 601 * @param expectedSize the expected number of elements
602 * @param map the map being tested 602 * @param map the map being tested
603 * @throws AssertionFailedError if the map is {@code null} or does not have th e expected number of 603 * @throws AssertionFailedError if the map is `null` or does not have the expe cted number of
604 * elements 604 * elements
605 */ 605 */
606 static void assertSize2(int expectedSize, Map<Object, Object> map) { 606 static void assertSize2(int expectedSize, Map<Object, Object> map) {
607 if (map == null) { 607 if (map == null) {
608 JUnitTestCase.fail("Expected map of size ${expectedSize}; found null"); 608 JUnitTestCase.fail("Expected map of size ${expectedSize}; found null");
609 } else if (map.length != expectedSize) { 609 } else if (map.length != expectedSize) {
610 JUnitTestCase.fail("Expected map of size ${expectedSize}; contained ${map. length} elements"); 610 JUnitTestCase.fail("Expected map of size ${expectedSize}; contained ${map. length} elements");
611 } 611 }
612 } 612 }
613 613
614 /** 614 /**
615 * Assert that the given set is non-{@code null} and has the expected number o f elements. 615 * Assert that the given set is non-`null` and has the expected number of elem ents.
616 * @param expectedSize the expected number of elements 616 * @param expectedSize the expected number of elements
617 * @param set the set being tested 617 * @param set the set being tested
618 * @throws AssertionFailedError if the set is {@code null} or does not have th e expected number of 618 * @throws AssertionFailedError if the set is `null` or does not have the expe cted number of
619 * elements 619 * elements
620 */ 620 */
621 static void assertSize3(int expectedSize, Set<Object> set) { 621 static void assertSize3(int expectedSize, Set<Object> set) {
622 if (set == null) { 622 if (set == null) {
623 JUnitTestCase.fail("Expected set of size ${expectedSize}; found null"); 623 JUnitTestCase.fail("Expected set of size ${expectedSize}; found null");
624 } else if (set.length != expectedSize) { 624 } else if (set.length != expectedSize) {
625 JUnitTestCase.fail("Expected set of size ${expectedSize}; contained ${set. length} elements"); 625 JUnitTestCase.fail("Expected set of size ${expectedSize}; contained ${set. length} elements");
626 } 626 }
627 } 627 }
628 628
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 return trampoline(target, arguments[0], arguments[1]); 785 return trampoline(target, arguments[0], arguments[1]);
786 case 3: 786 case 3:
787 return trampoline(target, arguments[0], arguments[1], arguments[2]); 787 return trampoline(target, arguments[0], arguments[1], arguments[2]);
788 case 4: 788 case 4:
789 return trampoline(target, arguments[0], arguments[1], arguments[2], argu ments[3]); 789 return trampoline(target, arguments[0], arguments[1], arguments[2], argu ments[3]);
790 default: 790 default:
791 throw new IllegalArgumentException("Not implemented for > 4 arguments"); 791 throw new IllegalArgumentException("Not implemented for > 4 arguments");
792 } 792 }
793 } 793 }
794 } 794 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/test/generated/scanner_test.dart ('k') | tests/language/language_analyzer2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698