Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #library('unittestTest'); | 5 #library('unittestTest'); |
| 6 #import('../../../lib/unittest/unittest.dart'); | 6 #import('../../../lib/unittest/unittest.dart'); |
| 7 | 7 |
| 8 class MockList extends Mock implements List { | 8 class MockList extends Mock implements List { |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 logList.add(e); | 595 logList.add(e); |
| 596 } | 596 } |
| 597 int total = 0; | 597 int total = 0; |
| 598 logList.stepwiseValidate((log, pos) { | 598 logList.stepwiseValidate((log, pos) { |
| 599 total += log[pos].args[0] * log[pos + 1].args[0]; | 599 total += log[pos].args[0] * log[pos + 1].args[0]; |
| 600 expect(log[pos + 1].args[0] - log[pos].args[0], equals(1)); | 600 expect(log[pos + 1].args[0] - log[pos].args[0], equals(1)); |
| 601 return 2; | 601 return 2; |
| 602 }); | 602 }); |
| 603 expect(total, equals((0 * 1) + (2 * 3) + (4 * 5) + (6 * 7) + (8 * 9))); | 603 expect(total, equals((0 * 1) + (2 * 3) + (4 * 5) + (6 * 7) + (8 * 9))); |
| 604 }); | 604 }); |
| 605 | |
| 606 test('Mocking: clearLogs', () { | |
| 607 var m = new Mock(); | |
| 608 m.foo(); | |
| 609 m.foo(); | |
| 610 m.foo(); | |
| 611 expect(m.log.logs, hasLength(3)); | |
| 612 m.clearLogs(); | |
| 613 expect(m.log.logs, hasLength(0)); | |
| 614 LogEntryList log = new LogEntryList(); | |
| 615 var m1 = new Mock.custom(name: 'm1', log: log); | |
| 616 var m2 = new Mock.custom(name: 'm2', log: log); | |
| 617 var m3 = new Mock.custom(name: 'm3', log: log); | |
| 618 for (var i = 0; i < 3; i++) { | |
| 619 m1.foo(); | |
| 620 m2.bar(); | |
| 621 m3.pow(); | |
| 622 } | |
| 623 expect(log.logs, hasLength(9)); | |
| 624 m1.clearLogs(); | |
| 625 expect(log.logs, hasLength(6)); | |
|
Siggi Cherem (dart-lang)
2012/08/13 17:09:12
I'd check also that:
log.logs.every((e) => e.mockN
| |
| 626 m2.clearLogs(); | |
|
Siggi Cherem (dart-lang)
2012/08/13 17:09:12
I'd also check that calling m1.clearLogs() again i
| |
| 627 expect(log.logs, hasLength(3)); | |
| 628 m3.clearLogs(); | |
| 629 expect(log.logs, hasLength(0)); | |
| 630 }); | |
| 605 } | 631 } |
| OLD | NEW |