http://qs321.pair.com?node_id=947593


in reply to Pre/post subroutine assertions and documentation module?

Couldn't you just put in extra lines of code with a test flag?
sub myFunc { my ($x, $y) = @_; ### Assertion if ($::test) { ### Do something } ### Rest of sub }

Might help if you could give an example of what a simple sub might do with and without an assertion.

Replies are listed 'Best First'.
Re^2: Pre/post subroutine assertions and documentation module?
by educated_foo (Vicar) on Jan 12, 2012 at 18:22 UTC
    If you do this, you want to make $::test a constant, so it can be optimized away when you're done testing, e.g.
    use constant TEST => $ENV{TEST}; if (TEST) { ... }
Re^2: Pre/post subroutine assertions and documentation module?
by suaveant (Parson) on Jan 12, 2012 at 18:19 UTC
    I can think of a number of ways I could do it in a custom manner, I'm just making sure I'm not reinventing anything.

                    - Ant
                    - Some of my best work - (1 2 3)