Test-More / test-more

Test2, Test::More, Test::Simple and Test::Builder Perl modules for writing tests
Other
140 stars 88 forks source link

Test2::Hub - fix remove_context_{aquire,init,release} logic #999

Closed mauke closed 2 months ago

mauke commented 2 months ago

As far as I can tell, the intended logic is:

  1. Build a set from passed-in arguments, represented as a hash.
  2. Keep only context handlers that are not elements of the set (i.e. not keys of the hash).

However, what the code actually did was to compare the result of ! (which is a boolean, numerically 0 or 1) to a coderef, which is always false. In other words, the removecontext* methods would ignore their arguments and always remove everything.

exodist commented 2 months ago

Do you have an example case where this was causing a problem? If so I would be interested in making a test related to it,

mauke commented 2 months ago

No, I don't even know what these methods are for. I noticed the issue because I added a new warning to blead perl.

exodist commented 2 months ago

I have to look deeper into this. I suspect I meant grep { !($subs{$_} == $_) } but I am not sure why I would not have just used != in that case...

exodist commented 2 months ago

actually, having re-read it, yeah, I think you got it correct here.