Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Aug 13, 2024

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 remove_context_* methods would ignore their arguments and always remove everything.

@exodist
Copy link
Member

exodist commented Aug 13, 2024

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
Copy link
Contributor Author

mauke commented Aug 13, 2024

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

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 remove_context_* methods would ignore their
arguments and always remove everything.
@mauke mauke force-pushed the fix-remove-handler-logic-bug branch from 2ea0a29 to b570354 Compare August 13, 2024 15:06
@exodist
Copy link
Member

exodist commented Aug 13, 2024

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
Copy link
Member

exodist commented Aug 13, 2024

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

@exodist exodist merged commit f8341a2 into Test-More:master Aug 13, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants