Closed
Description
For example:
class Monster {
// Returns current health after applying [hp] damage to this monster.
int damage(int hp);
// Returns current health after applying [f()] damage to this monster.
int damageFromClosure(int f());
}
class MockMonster extends Mock implements Monster {}
var mock = new MockMonster();
when(mock.damage(argThat(isPositive))).thenReturn(100);
when(mock.damageFromClosure(argThat(isFunction))).thenReturn(200);
We'll want to allow mock.damage
to avoid the cast to int
. This is safe because when using nSM to implement abstract methods, the method is conceptually implemented by a method that forwards to nSM, and that method can widen the argument types to Object.