Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Kent Fredric
On 12 January 2016 at 13:53, Chad Granum 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

Should Test2 maintain $! and $@?

2016-01-11 Thread Chad Granum
Test::More/Test::Builder work VERY hard to ensure nothing inside them alters $! or $@. This is for thing like this: ok(do_something_scary()); > is($!, 0, "expected $! val"); > is($@, undef, '$@ not changed'); Without Test::More/Builder being careful to support this, the second 2

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Ricardo Signes
* Chad Granum [2016-01-11T19:53:15] > However. It is easy enough to have Test::Builder/More protect $! and $@ > without requiring Test2 to do so. I don't have really strong feelings here, but the general reaction on p5p over the years to "some core library changes $!

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Karen Etheridge
> Test2, the dist, is just internals. It provides no tools. It does not have ok(), is(), etc. Um, so... what *is* Test2 then? (And the second question would be: and what does it have to do with Test::More?) Without context, your first question is equivalent to "should Foo::Bar maintain $! and

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Chad Granum
The magic is already there, but it is there by localizing the vars in a ton of non obvious places. Between that and having it done in one obvious and documented place seems like a Much better option. On Jan 11, 2016 7:21 PM, "Kent Fredric" wrote: > On 12 January 2016 at

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Chad Granum
Some things I forgot to mention: Test2, the dist, is just internals. It provides no tools. It does not have ok(), is(), etc. What I am talking about is not thr simple task of putting local $! In some exports. This is localizing $! Around any call to use, require, open, close, etc. Anything that

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Chad Granum
https://github.com/Test-More/Test2/issues/9 Issue created to do this the easy/efficient way. On Jan 11, 2016 7:14 PM, "Chad Granum" wrote: > Some things I forgot to mention: > > Test2, the dist, is just internals. It provides no tools. It does not have > ok(), is(), etc.

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Kent Fredric
On 12 January 2016 at 16:14, Chad Granum wrote: > That said, it just occured to me that this can possibly be accomplished by > having a context store $! And $@ when it is obtained, then restore them when > it is released, which would avoid needing to use local everywhere, and

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Chris Nandor
I agree, Kent. Shouldn't it be simple to wrap ok() and is() accordingly, to simply save-and-restore $! and $@, without going deep into anything? There's already a working example of how to do that right here. sub ok { my($err, $exception) = ($!, $@); # ... ($!, $@) = ($err, $exception);