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

Closed
wants to merge 2 commits into 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 git diff output:

  1. Redundant Iteration in find_first Test:

    • In the find_first test, the line let iter = test_from_array(['1', '2', '3', '4', '5']) is repeated unnecessarily. This could lead to confusion or inefficiency if the array is large or the initialization is costly. The second iteration could reuse the first iter variable instead of reinitializing it.
  2. Inconsistent Variable Naming in all Test:

    • In the all test, the variable array is used instead of arr, which was used in the any test. This inconsistency in naming could make the code harder to read and maintain. It would be better to use a consistent naming convention across tests.
  3. Potential Issue with guard not(ran) in test_from_array:

    • The guard not(ran) statement in the test_from_array function ensures that the iterator only runs once. However, if the iterator is reused or reset, this guard could prevent it from running again, which might not be the intended behavior. This could lead to subtle bugs if the iterator is expected to be reusable. Consider whether this guard is necessary or if it should be reset under certain conditions.

These observations highlight areas where the code could be improved for clarity, consistency, and correctness.

@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

coveralls commented Dec 26, 2024

Pull Request Test Coverage Report for Build 4370

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 83.289%

Files with Coverage Reduction New Missed Lines %
builtin/array.mbt 1 96.08%
Totals Coverage Status
Change from base Build 4366: -0.02%
Covered Lines: 4650
Relevant Lines: 5583

💛 - Coveralls

@lynzrand
Copy link
Collaborator

My best guess is that the reduction in result.mbt comes from a rare name clash in coverage data output, as I can't reproduce it in my local environment. A PR there is under way: moonbitlang/moon#538

@rami3l rami3l closed this Dec 27, 2024
@rami3l rami3l deleted the zihang/iter-should-run-once branch December 27, 2024 06:03
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.

4 participants