Re: Should Test2 maintain $! and $@?
[email protected] (Kent Fredric) Tue, 12 Jan 2016 14:34:11 +1300
| Newsgroups | perl.cpan.workers |
|---|---|
| Message-ID | <CAATnKFCXn0MhqgFookcV5LeuQ7Kchm-79PNsquckS4DLdA6VGw@mail.gmail.com> |
On 12 January 2016 at 13:53, Chad Granum <[email protected]> wrote: > $! and $@ are altered by many many things, adding { local ... } around all > of them is a pain As much as I agree, and as much as this is a "thing in all perl, so we should expect this problem from every module" If I was to offer a counter example, consider the effort of a `*.t` file needing to preserve these things instead. > ok(do_something_scary()); > is($!, 0, "expected $! val"); > is($@, undef, '$@ not changed'); vs > my ( $error, $exception ); > ok(do { > local $@; > local $!; > my $ret = do_something_scary()); > ( $error, $exception ) = ($!, $@); > $ret > }); > is($error, 0, "expected $! val"); > is($exception, undef, '$@ not changed); I'm not sure I'd consider the second of these an "improvement". -- Kent KENTNL - https://metacpan.org/author/KENTNL