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

test(iter): add invariant iter should only run once #1372

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

peter-jerry-ye
Copy link
Collaborator

All the methods provided should make sure that Iter is only ran once.

Counter example: tap #1371

Copy link

peter-jerry-ye-code-review bot commented Dec 26, 2024

‼️ This code review is generated by a bot. Please verify the content before trusting it.

Here are three observations from the provided git diff output:

  1. Potential Bug in test_from_array Function:

    • The test_from_array function now includes a guard to ensure that the iterator is only run once (guard not(ran)). However, the ran variable is not reset after the iterator completes. This could lead to unexpected behavior if the iterator is reused or if the function is called multiple times. Consider resetting ran after the iteration completes or ensuring that the function is only called once.
  2. Redundant Code in find_first Test:

    • In the find_first test, the line let iter = test_from_array(['1', '2', '3', '4', '5']) is repeated unnecessarily. The second call to test_from_array is redundant because the iterator is already defined. This could be simplified to avoid unnecessary repetition.
  3. Inconsistent Variable Naming:

    • In the all test, the variable array is used, while in other tests, variables like arr or iter are used. This inconsistency in naming conventions could make the code harder to read and maintain. Consider standardizing variable names across the codebase for clarity.

These are the key issues I noticed. Let me know if you'd like further clarification or suggestions for fixes!

@peter-jerry-ye peter-jerry-ye force-pushed the zihang/iter-should-run-once branch from 27d8be7 to ec1d6b1 Compare December 26, 2024 06:00
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 4355

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.05%) to 83.252%

Files with Coverage Reduction New Missed Lines %
builtin/array.mbt 1 96.08%
result/result.mbt 2 74.14%
Totals Coverage Status
Change from base Build 4354: -0.05%
Covered Lines: 4633
Relevant Lines: 5565

💛 - Coveralls

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