-
Notifications
You must be signed in to change notification settings - Fork 170
Add nested loop tests for else clause in loops #2630
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
Conversation
Hello @advikkabra ! Thanks for this. I think we can add a reference test for this to check the control flow output. @Thirumalai-Shaktivel, @Shaikh-Ubaid what do think about it? |
I think integration tests are fine for this. |
Please mark as "Ready for review" when ready. |
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.
Thanks for this! I think we need to fix the following:
- There seems to be a bug in the
for-else
implementation. - Test cases need to be robust by adding asserts on variables values.
integration_tests/loop_10.py
Outdated
print(10) | ||
assert j == 2 |
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.
Please also print the values before the asserts
. That helps during debugging.
integration_tests/loop_10.py
Outdated
print("outer: " + str(i)) | ||
for j in range(10, 20): | ||
print(" inner: " + str(j)) | ||
break | ||
else: | ||
print("no break in outer loop") | ||
return | ||
assert False |
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.
No need for return here. Just increment some variable (inside the loops
, before the breaks
, etc.). You can use different variables for different loops here.
At the end of the function print the final values for the variables and add asserts for them. I think this would make it a much more robust test. You can follow this approach for other tests as well. 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.
It looks good to me. Thanks!
02eb3dd
to
d8a8b19
Compare
* Add nested loop tests for else clause in loops * Add nested else test * Fix bug in for else implementation * Update tests to use assert * Add print statements in tests
* Add nested loop tests for else clause in loops * Add nested else test * Fix bug in for else implementation * Update tests to use assert * Add print statements in tests
Continuation of #2555 .
Nested loops were not added completely in tests.