Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Pre/post subroutine assertions and documentation module?

by TJPride (Pilgrim)
on Jan 12, 2012 at 17:59 UTC ( [id://947593]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://947593]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-03-19 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found