Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^8: Introspecting function signatures

by szabgab (Priest)
on Mar 07, 2021 at 05:59 UTC ( #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

Replies are listed 'Best First'.
Re^9: Introspecting function signatures
by LanX (Sage) 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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-08-08 22:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found