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

Side by Side Diff: pkg/unittest/lib/mock.dart

Issue 13956006: Remove insertRange. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebuild DOM (unrelated CL) and update status files. Created 7 years, 8 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
« no previous file with comments | « pkg/serialization/lib/src/serialization_rule.dart ('k') | pkg/yaml/lib/model.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * A simple mocking/spy library. 6 * A simple mocking/spy library.
7 * 7 *
8 * To create a mock objects for some class T, create a new class using: 8 * To create a mock objects for some class T, create a new class using:
9 * 9 *
10 * class MockT extends Mock implements T {}; 10 * class MockT extends Mock implements T {};
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 LogEntryList rtn = new LogEntryList(filterName); 506 LogEntryList rtn = new LogEntryList(filterName);
507 MatchState matchState = new MatchState(); 507 MatchState matchState = new MatchState();
508 for (var i = 0; i < logs.length; i++) { 508 for (var i = 0; i < logs.length; i++) {
509 LogEntry entry = logs[i]; 509 LogEntry entry = logs[i];
510 if (mockNameFilter.matches(entry.mockName, matchState) && 510 if (mockNameFilter.matches(entry.mockName, matchState) &&
511 entryFilter(entry)) { 511 entryFilter(entry)) {
512 if (actionMatcher == null || 512 if (actionMatcher == null ||
513 actionMatcher.matches(entry, matchState)) { 513 actionMatcher.matches(entry, matchState)) {
514 rtn.add(entry); 514 rtn.add(entry);
515 if (destructive) { 515 if (destructive) {
516 logs.removeRange(i--, 1); 516 int startIndex = i--;
517 logs.removeRange(startIndex, startIndex + 1);
517 } 518 }
518 } 519 }
519 } 520 }
520 } 521 }
521 return rtn; 522 return rtn;
522 } 523 }
523 524
524 /** Apply a unit test [Matcher] to the [LogEntryList]. */ 525 /** Apply a unit test [Matcher] to the [LogEntryList]. */
525 LogEntryList verify(Matcher matcher) { 526 LogEntryList verify(Matcher matcher) {
526 if (_mockFailureHandler == null) { 527 if (_mockFailureHandler == null) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 * the case that no match is found. 615 * the case that no match is found.
615 */ 616 */
616 LogEntryList _head(logFilter, bool inPlace, 617 LogEntryList _head(logFilter, bool inPlace,
617 String description, int defaultPosition) { 618 String description, int defaultPosition) {
618 if (filter != null) { 619 if (filter != null) {
619 description = '$filter $description'; 620 description = '$filter $description';
620 } 621 }
621 int pos = findLogEntry(logFilter, 0, defaultPosition); 622 int pos = findLogEntry(logFilter, 0, defaultPosition);
622 if (inPlace) { 623 if (inPlace) {
623 if (pos < logs.length) { 624 if (pos < logs.length) {
624 logs.removeRange(pos, logs.length - pos); 625 logs.removeRange(pos, logs.length);
625 } 626 }
626 filter = description; 627 filter = description;
627 return this; 628 return this;
628 } else { 629 } else {
629 LogEntryList newList = new LogEntryList(description); 630 LogEntryList newList = new LogEntryList(description);
630 for (var i = 0; i < pos; i++) { 631 for (var i = 0; i < pos; i++) {
631 newList.logs.add(logs[i]); 632 newList.logs.add(logs[i]);
632 } 633 }
633 return newList; 634 return newList;
634 } 635 }
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 } 1479 }
1479 } 1480 }
1480 } 1481 }
1481 1482
1482 /** Clear both logs and behavior. */ 1483 /** Clear both logs and behavior. */
1483 void reset() { 1484 void reset() {
1484 resetBehavior(); 1485 resetBehavior();
1485 clearLogs(); 1486 clearLogs();
1486 } 1487 }
1487 } 1488 }
OLDNEW
« no previous file with comments | « pkg/serialization/lib/src/serialization_rule.dart ('k') | pkg/yaml/lib/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698