As part of some testing, I'm looking to, temporarily, replace the contents of a message with one that will return a predictable set of test values. What is the standard Smalltalk-y way to do this type of work? Is there some sample code for me to look at?
Some clarification:
Here's some pseudocode for what I'm looking to write:
replaceMessage: 'fibonacci'
onClass: 'funFunctions'
with: 'returnsPredictableNumbersWithoutCalculatingThem'.
self runTestSet1.
restoreMessage: 'fibonacci'
onClass: 'funFunctions'.
self runFollowUpSet1. "Depends on state set by Set1"
replaceMessage: 'fibonacci'
onClass: 'funFunctions'
with: 'returnsPredictableNumbersWithoutCalculatingThemPart2'.
self runFollowUpSet2. "Depends on state set by followupset1"
restoreMessage: 'fibonacci'
onClass: 'funFunctions'.
To replace one message with another you could:
a) in corresponding method(s), change the selector, which responsible for given message send.
b) use proxies, to wrap all objects of interest and intercept given message in order to use different evaluation path than in original method.