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

Add Decimal.min and .max #9663

Merged
merged 9 commits into from
Apr 11, 2024
Merged

Add Decimal.min and .max #9663

merged 9 commits into from
Apr 11, 2024

Conversation

GregoryTravis
Copy link
Contributor

@GregoryTravis GregoryTravis commented Apr 9, 2024

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@GregoryTravis GregoryTravis marked this pull request as ready for review April 9, 2024 17:59
Decimal.new "12E73" . max (Decimal.new "13E60") . should_equal (Decimal.new "12E73")
Decimal.new "12E73" . max (Decimal.new "13E80") . should_equal (Decimal.new "13E80")
Decimal.new "-12E73" . max (Decimal.new "-13E60") . should_equal (Decimal.new "-13E60")
Decimal.new "-12E73" . max (Decimal.new "-13E80") . should_equal (Decimal.new "-12E73")
Copy link
Member

Choose a reason for hiding this comment

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

There are no tests for cases where decimals and non-decimals are intertwined.

I think both

Decimal.new "123" . max 100 . should_equal 123
124 . max (Decimal.new "101") . should_equal 124

would be good to check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Decimal.new "12" . max (Decimal.new "13")
# => Decimal.new "13"
max : Number -> Number
max self that = if self > that then self else that
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
max self that = if self > that then self else that
max self (that : Number) = if self > that then self else that

It feels like we should also have the checked type ascription here - this should probably make for better widgets in the GUI (at least in future) and will aid type checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done -- actually changed to Decimal; Number was wrong.

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

I appreciate the small PRs, it makes them so much easier to review! 👍

I'd add a few more tests for this one.

@GregoryTravis GregoryTravis requested a review from radeusgd April 10, 2024 14:03
@GregoryTravis GregoryTravis merged commit 676e989 into develop Apr 11, 2024
36 checks passed
@GregoryTravis GregoryTravis deleted the wip/gmt/8982-min-max branch April 11, 2024 13:58
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