On 6/16/07, Joshua ben Jore <[EMAIL PROTECTED]> wrote:
I took chromatic's Runops::Trace and hacked it up so I could do code
coverage. I can now tell which code path is triggered by which inputs.
Check this badness out. The punchline is the lists of equivalent
inputs. Roughly. Ops can return different things and I'm not paying
attention to the inputs - it's only the path traversed.
Ok, so now here's a new version. It's less hacky. I figure a change of
namespaces is in order. Whatever chromatic's newer and unpublished
version did, this doesn't do quite the same thing. He called the
callback all the time, period. I only call the tracing callback when
requested and it's over a single code reference. I suppose I could
emulate chromatic's code though.
Dunno. I've got the tool I needed. The rest of you can also have it at
http://diotalevi.isa-geek.net/~josh/cpan/Runops-Trace-0.03.tar.gz
until it changes name and goes up on CPAN.
Here's a nice example:
Given the code in
http://diotalevi.isa-geek.net/~josh/cpan/Runops-Trace-0.03/eg/is-even,
I get back a md5sum of the code path for each input and can describe
which inputs were identical.
There's two sugared functions. One returns the md5sum of the code path
and the other just returns the unique string. The latter is more
interesting to look at but isn't needed for most work. I guess.
A hash of md5sumed code paths vs inputs that trigger them:
---
48c92ccbd609ab8e22e4ec6fe3bb1983:
- 0
- 2
- 4
- 6
- 8
- 10
61ddc137197f9145c3d10d13d98516e4:
- 1
- 3
- 5
- 7
- 9
A hash of "readable" code paths vs the inputs that trigger them:
---
nextstate=(0x81a3ac8) pushmark=(0x81a4118) padsv=(0x81ccb60)
gv=(0x81b7200) entersub=(0x8144f10) nextstate=(0x81a3db8)
aelemfast=(0x8141fd0) const=(0x8142318) modulo=(0x817b800)
const=(0x81b6ef0) eq=(0x8145c28) cond_expr=(0x813be68)
const=(0x81b6c80) leavesub=(0x81b70e0) leavesub=(0x81b5780):
- 0
- 2
- 4
- 6
- 8
- 10
nextstate=(0x81a3ac8) pushmark=(0x81a4118) padsv=(0x81ccb60)
gv=(0x81b7200) entersub=(0x8144f10) nextstate=(0x81a3db8)
aelemfast=(0x8141fd0) const=(0x8142318) modulo=(0x817b800)
const=(0x81b6ef0) eq=(0x8145c28) cond_expr=(0x813be68)
const=(0x81b7198) leavesub=(0x81b70e0) leavesub=(0x81b5780):
- 1
- 3
- 5
- 7
- 9
The base primitive is a function _do_trace( TRACE, CODE ). I guess
I'll describe it more later. I've got to go now.
Josh