On Sun, Jan 29, 2012 at 1:25 PM, Stéphane Ducasse <stephane.duca...@inria.fr
> wrote:

> Hi
>
> I would like to write some tests about MethodContext and BlockClosure
> activation.
> To start I wanted to write a simple invocation and step in from context to
> context.
>
> I could manually annotate the code with thisContext and store the
> resulting contexts
> somewhere. But does anybody has some magic information so that I can reuse
> the debugger logic?
>

ContextPart>runSimulated:atEachStep:, e.g.

| last |
last := thisContext.
thisContext runSimulated: [#(1 2 3) detect: [:e| e even]]
contextAtEachStep: [:c| c ~~ last ifTrue: [Transcript print: c; cr; flush.
last := c]]

=>

[] in UndefinedObject>>DoIt
Array(Collection)>>detect:
Array(Collection)>>detect:ifNone:
Array(SequenceableCollection)>>do:
[] in Array(Collection)>>detect:ifNone:
[] in [] in UndefinedObject>>DoIt
SmallInteger>>even
[] in [] in UndefinedObject>>DoIt
[] in Array(Collection)>>detect:ifNone:
Array(SequenceableCollection)>>do:
[] in Array(Collection)>>detect:ifNone:
[] in [] in UndefinedObject>>DoIt
SmallInteger>>even
[] in [] in UndefinedObject>>DoIt
[] in Array(Collection)>>detect:ifNone:
Array(Collection)>>detect:
[] in UndefinedObject>>DoIt


or...


| last home indent |
last := nil.
home := thisContext.
indent := 0.
thisContext
runSimulated: [#(1 2 3) detect: [:e| e even]]
contextAtEachStep:
[:c| | ctxt |
c ~~ last ifTrue:
[last := c.
 indent := 0. ctxt := c sender.
 [ctxt ~~ home] whileTrue:
[ctxt := ctxt sender. indent := indent + 1].
Transcript crtab: indent; print: c; flush]]

[] in UndefinedObject>>DoIt
Array(Collection)>>detect:
Array(Collection)>>detect:ifNone:
Array(SequenceableCollection)>>do:
[] in Array(Collection)>>detect:ifNone:
[] in [] in UndefinedObject>>DoIt
SmallInteger>>even
[] in [] in UndefinedObject>>DoIt
[] in Array(Collection)>>detect:ifNone:
Array(SequenceableCollection)>>do:
[] in Array(Collection)>>detect:ifNone:
[] in [] in UndefinedObject>>DoIt
SmallInteger>>even
[] in [] in UndefinedObject>>DoIt
[] in Array(Collection)>>detect:ifNone:
Array(Collection)>>detect:
[] in UndefinedObject>>DoIt



-- 
best,
Eliot

Reply via email to