What steps will reproduce the problem?
Stub a function on a mock_object N times with overloaded return values. Call
the function on the mock_object's instance (getInstance()) N times. Stub the
function again with another overload. Call the function on the instance and
observe that the last overload did not take effect; the returned value is that
which was specified in the Nth overload.
However, if you stub the function with N overloads, then call the function
(N-1) times, then add the (N+1)th overload, then call the function twice more
you observe that the (N+1)th function call returns the value specified in the
(N+1)th overload, which is exactly what you would expect. (Any subsequent call
also returns this same value, as expected.)
See attached code.
What is the expected output? What do you see instead?
I expect that no matter the state of the mock_object and how many times the
instance functions have been evaluated, setting a new stub overload will cause
that overload to take effect as early as possible; in particular, if there are
other non-evaluated overloads the new overload will be queued at the end, and
if all overloads have been evaluated the new overload will take effect on the
next function call.
What version of the product are you using? On what operating system?
mockitopp trunk rev158
$ uname -a
Linux [redacted] 2.6.32-220.23.1.el6.x86_64 #1 SMP Mon Jun 18 09:58:09 CDT 2012
x86_64 x86_64 x86_64 GNU/Linux
Please provide any additional information below.
Original issue reported on code.google.com by
nwon...@gmail.comon 5 Aug 2013 at 9:49Attachments: