keeganwitt / gmock

Automatically exported from code.google.com/p/gmock
6 stars 2 forks source link

Fix the inconsistent behaviors of delegate of expectation closure and static closure #73

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, delegate of expectation closure and static closure has
inconsistent behaviors. Consider:

def m = mock {      // here, m == it == delegate
  match {}          // call on delegate, but actually call GMock.match(),
because I have done something tricky in MPMC.pickMethod()
  delegate.match {} // call m.match()
  it.match {}       // call m.match()
}

I suggest to introduce a MockDelegate class, which will be the class of the
delegates. So:

def m = mock {      // m == it != delegate, delegate instanceof MockDelegate
  match {}          // call GMock.match()
  delegate.match {} // call GMock.match()
  it.match {}       // call m.match()
}

I think it will work fine even if the method is cached by groovy, while the
current implements may not work fine.

Original issue reported on code.google.com by JohnnyJianHY on 9 Mar 2009 at 11:23

GoogleCodeExporter commented 9 years ago
Ok. I was wondering what was the pickMethod used for.

Original comment by julien.g...@gmail.com on 9 Mar 2009 at 7:26

GoogleCodeExporter commented 9 years ago

Original comment by JohnnyJianHY on 13 Mar 2009 at 8:18

GoogleCodeExporter commented 9 years ago

Original comment by JohnnyJianHY on 13 Mar 2009 at 2:51