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

Side by Side Diff: pkg/unittest/test/mock_test.dart

Issue 12207123: Improve matcher descriptions that match against objects, and thus fix a bug (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/unittest/lib/src/description.dart ('k') | no next file » | 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 library mock_test; 5 library mock_test;
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/mock.dart'; 7 import 'package:unittest/mock.dart';
8 8
9 class MockList extends Mock implements List { 9 class MockList extends Mock implements List {
10 } 10 }
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 m1.clearLogs(); 642 m1.clearLogs();
643 expect(log.logs, hasLength(6)); 643 expect(log.logs, hasLength(6));
644 expect(log.logs.every((e) => e.mockName == 'm2' || e.mockName == 'm3'), 644 expect(log.logs.every((e) => e.mockName == 'm2' || e.mockName == 'm3'),
645 isTrue); 645 isTrue);
646 m2.clearLogs(); 646 m2.clearLogs();
647 expect(log.logs, hasLength(3)); 647 expect(log.logs, hasLength(3));
648 expect(log.logs.every((e) => e.mockName =='m3'), isTrue); 648 expect(log.logs.every((e) => e.mockName =='m3'), isTrue);
649 m3.clearLogs(); 649 m3.clearLogs();
650 expect(log.logs, hasLength(0)); 650 expect(log.logs, hasLength(0));
651 }); 651 });
652
653 test("Mocking: instances", () {
654 var alice = new Object();
655 var bob = new Object();
656 var m = new Mock();
657 m.when(callsTo("foo", alice)).alwaysReturn(true);
658 m.when(callsTo("foo", bob)).alwaysReturn(false);
659 expect(m.foo(alice), true);
660 expect(m.foo(bob), false);
661 expect(m.foo(alice), true);
662 expect(m.foo(bob), false);
663 });
652 } 664 }
OLDNEW
« no previous file with comments | « pkg/unittest/lib/src/description.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698