-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Possible issue 6830 fix #7526
Possible issue 6830 fix #7526
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! I left an inline comment, and could you also update the changelog, please? 🙂
packages/expect/src/utils.js
Outdated
return true; | ||
} | ||
} | ||
} | ||
|
||
const bIterator = b[IteratorSymbol](); | ||
|
||
for (const aValue of a) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put count
and iterableControler
(also typo, but call it maxIterations
or something) here, instead of at the top level?
If that messes up, at least put count
at the top of iterableEquality
so that we avoid the value leaking across assertions 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will do it right away! Thanks for the feedback and the help. Any ideas why it didn't pass through all the checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I keep the count = 0 everytime the program returns or delete it and only let it inside the cycle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reset it for every time the equality function is called
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This change was motivated by a college discipline. We were asked to pick a open source project and then choose two issues to solve.
Test plan
The problem before was the fact that when using Iterables the program would get stuck in a infinite loop when making recursive calls. We added a global variable to control how many times the function can recurse. Once a counter is bigger than the control variable the function returns. This way the program can't produce the error: RangeError: Maximum call stack size exceeded. As the controler is a global variable, the value can be changed to the value the programmer wishes.
Here is an image that shows that the alteration made to the code works for the example used. The example that was used was originally proposed by another contributor.