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

Review Range and Interval, resolve infinite loop issue #3408

Merged
merged 17 commits into from
Apr 20, 2022

Conversation

radeusgd
Copy link
Member

@radeusgd radeusgd commented Apr 19, 2022

Pull Request Description

Implements: https://www.pivotaltracker.com/story/show/181652841

Important Notes

Checklist

Please include the following checklist in your PR:

  • The documentation has been updated if necessary.
  • All code conforms to the Scala, Java, and Rust style guides.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed: Enso GUI was tested when built using BOTH ./run dist and ./run watch.

@radeusgd radeusgd requested a review from 4e6 as a code owner April 19, 2022 16:02
@radeusgd radeusgd self-assigned this Apr 19, 2022
@radeusgd radeusgd requested a review from hubertp April 19, 2022 16:06
Copy link
Member

@jdunkerley jdunkerley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing major but a few little tweaks.

test/Tests/src/Data/Range_Spec.enso Outdated Show resolved Hide resolved
test/Tests/src/Data/Range_Spec.enso Show resolved Hide resolved
@@ -27,7 +64,9 @@ type Range

0.up_to 100 . is_empty
is_empty : Boolean
is_empty = this.end <= this.start
is_empty = if this.step > 0 then this.end <= this.start else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interval.inclusive 0 0 means this will throw an error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interval is not related to Range


Test.specify "should report errors if trying to set step to 0" <|
0.up_to 0 . with_step 0 . should_fail_with Illegal_State_Error
invalid_range = Range 0 0 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe test Range 0 0 2 as well? Just to cover corner cases

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this range is not invalid, it is just empty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A range is only invalid if its step is 0 - because the step should be a non-zero integer (so technically a range is also invalid if the step is decimal, but this is a typelevel check).

A range whose step exceeds end-start is still valid, but will be empty if start=end or contain just a single element [start].

@radeusgd radeusgd force-pushed the wip/radeusgd/unify-range-interval-181435598 branch from 1c7a199 to 6cc1faa Compare April 20, 2022 09:46
Copy link
Contributor

@4e6 4e6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. An extra test for with BigIntegers would be quite handy

test/Tests/src/Data/Numbers_Spec.enso Show resolved Hide resolved
@radeusgd radeusgd force-pushed the wip/radeusgd/unify-range-interval-181435598 branch from cfa9b49 to 80b771d Compare April 20, 2022 15:39
@radeusgd radeusgd added the CI: Ready to merge This PR is eligible for automatic merge label Apr 20, 2022
@mergify mergify bot merged commit fecaa81 into develop Apr 20, 2022
@mergify mergify bot deleted the wip/radeusgd/unify-range-interval-181435598 branch April 20, 2022 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants