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

Just check the BigDecimal 3.1+ behavior at NumericalityValidationTest #49152

Merged

Conversation

yahonda
Copy link
Member

@yahonda yahonda commented Sep 5, 2023

Motivation / Background

To prepare Ruby 3.4 will ship bigdecimal as bundled gem, bigdecimal has been added to Active Support runtime dependency via #49039

It will install BigDecimal version 3.1.4 or higher, so we just check the BigDecimal 3.1+ behavior at NumericalityValidationTest.

Detail

None

Additional information

Refer to
#49039
ruby/bigdecimal#180
ruby/bigdecimal#70

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

To prepare Ruby 3.4 will ship `bigdecimal` as bundled gem,
`bigdecimal` has been added to Active Support runtime dependency
via rails#49039

It will install BigDecimal version 3.1.4 or higher,
so we just check the BigDecimal 3.1+ behavior at `NumericalityValidationTest`.

Refer to
rails#49039
ruby/bigdecimal#180
ruby/bigdecimal#70
@rafaelfranca rafaelfranca merged commit f9e4fb9 into rails:main Sep 5, 2023
4 checks passed
yahonda added a commit to yahonda/rails that referenced this pull request Sep 19, 2023
Follow up rails#49152
rails#49039

- `bigdecimal_to_d.rb`
```
require 'bigdecimal/util'
p "Ruby version: #{RUBY_VERSION}"
p "BigDecimal version: #{BigDecimal::VERSION}"
p "123.455.to_d(5): #{123.455.to_d(5)}"
```

- Ruby 2.7 and 3.0 rounds down
```
$ ruby bigdecimal_to_d.rb
"Ruby version: 2.7.8"
"BigDecimal version: 2.0.0"
"123.455.to_d(5): 0.12345e3"
```

```
$ ruby bigdecimal_to_d.rb
"Ruby version: 3.0.6"
"BigDecimal version: 3.0.0"
"123.455.to_d(5): 0.12345e3"
```

- Ruby 3.1 and 3.2 rounds up

```
$ ruby bigdecimal_to_d.rb
"Ruby version: 3.1.4"
"BigDecimal version: 3.1.1"
"123.455.to_d(5): 0.12346e3"
```

```
$ ruby bigdecimal_to_d.rb
"Ruby version: 3.2.2"
"BigDecimal version: 3.1.3"
"123.455.to_d(5): 0.12346e3"
```
@yahonda yahonda deleted the bigdecimal_314_or_higher_will_be_installed branch April 19, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants