I'm writing a test double library similar to Ruby's rspec. The first signs of
life can be downloaded via:
Gofer new 
    squeaksource: 'BDDExtensions'; 
    package: 'Mock'; 
    load.

One of the features is to partially stub a class, so one could have e.g.
DateAndTime>>#now return a canned value. It's easy enough to implement, but
the wheels fall off in the debugger, where the VM quits and leaves no log on
the last line of the following snippet. In a workspace, I just get a DNU,
described in the comment:

    startTime := DateAndTime now.
    DateAndTime stub: #now andReturn: startTime.

    "DoIt this last line... works great. Debug this last line... DateAndTime
class(Object)>>doesNotUnderstand: 224@116. It originally ran into
Object>>at: error not indexable until I implemented at: and forwarded it to
the original CompiledMethod"
    DateAndTime now.

The ObjectAsMethodWrapper approach has a similar limitation:
    wrapper := ObjectAsMethodWrapper installOn: DateAndTime class selector:
#now.

    "Debugging  this line leads to 'Error: Instances of
ObjectAsMethodWrapper are not indexable'"
    DateAndTime now.

I'm going to take a look at the other MethodWrapper implementation, which I
think creates CompiledMethods, so maybe that will fare better...

Any other ideas?

Thanks.
Sean

--
View this message in context: 
http://forum.world.st/Method-Wrappers-and-the-Debugger-tp4601773.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.

Reply via email to