mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
Improve matcher descriptions that match against objects, and thus fix a bug
in mocking library. See https://code.google.com/p/dart/issues/detail?id=7039 Review URL: https://codereview.chromium.org//12207123 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18386 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
3520e88c04
commit
dad3b5ae60
2 changed files with 18 additions and 0 deletions
|
@ -47,6 +47,12 @@ class StringDescription implements Description {
|
|||
String description = (value == null) ? "null" : value.toString();
|
||||
if (description.startsWith('<') && description.endsWith('>')) {
|
||||
add(description);
|
||||
} else if (description.startsWith("Instance of")) {
|
||||
add('<');
|
||||
add(description);
|
||||
add(':');
|
||||
add(value.hashCode.toString());
|
||||
add('>');
|
||||
} else {
|
||||
add('<');
|
||||
add(description);
|
||||
|
|
|
@ -649,4 +649,16 @@ main() {
|
|||
m3.clearLogs();
|
||||
expect(log.logs, hasLength(0));
|
||||
});
|
||||
|
||||
test("Mocking: instances", () {
|
||||
var alice = new Object();
|
||||
var bob = new Object();
|
||||
var m = new Mock();
|
||||
m.when(callsTo("foo", alice)).alwaysReturn(true);
|
||||
m.when(callsTo("foo", bob)).alwaysReturn(false);
|
||||
expect(m.foo(alice), true);
|
||||
expect(m.foo(bob), false);
|
||||
expect(m.foo(alice), true);
|
||||
expect(m.foo(bob), false);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue