Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^8: Introspecting function signatures

by szabgab (Priest)
on Mar 07, 2021 at 05:59 UTC ( [id://11129240]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Introspecting function signatures
in thread Introspecting function signatures

This can indeed be a good solution. Given that perl will reliably call DESTROY when an object goes out of scope, this could ensure that whatever the object holds will be cleaned up. It is a bit more code to write as we need to call the function, but might be reasonable.
sub test_something { my $tempdir = create_tempdir(); # ... }

I don't know where the idea came from that in Python people include the tests in the main code. Maybe that was the case 10 years ago, but these days the standard is that tests are in separate files called test_SOMETHING.py.

Replies are listed 'Best First'.
Re^9: Introspecting function signatures
by LanX (Saint) on Mar 07, 2021 at 13:48 UTC
      I am not sure what closure are you talking about here, but the best would be if you could show a code snippet how you think it would be used in a test? And yes, it would be nice to avoid the linked problem.
        > show a code snippet how you think it would be used in a test?

        pseudocode, because I don't know your project sufficiently well

        { my $fixture_A = temdir(); # fixture in closure sub test1 ($fixture_B) { # no need to repeat A # uses fixture A and B } sub test2 ($fixture_C) { # no need to repeat A # uses fixture A and B } }

        NB: I use "closure" in the original sense, it's the hull with "enclosed vars" not the enclosed sub.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found