Skip to content

SR-7481: NumberFormatter inconsistency on Linux #1530

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

Merged
merged 2 commits into from
Apr 25, 2018

Conversation

spevans
Copy link
Contributor

@spevans spevans commented Apr 21, 2018

  • For the numberStyle .currency, use a minimumIntegerDigits of 1.

  • If minimumIntegerDigits is set to any value (including 0) before
    the numberStyle is set, preserve the original value.

- For the numberStyle .currency, use a minimumIntegerDigits of 1.

- If minimumIntegerDigits is set to any value (including 0) before
  the numberStyle is set, preserve the original value.
@spevans
Copy link
Contributor Author

spevans commented Apr 21, 2018

@swift-ci please test

@spevans spevans requested a review from parkera April 24, 2018 12:34
@parkera parkera requested a review from itaiferber April 24, 2018 20:17
Copy link
Contributor

@parkera parkera left a comment

Choose a reason for hiding this comment

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

LGTM, also adding @itaiferber

Copy link
Contributor

@itaiferber itaiferber left a comment

Choose a reason for hiding this comment

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

Looks reasonable, though if we care about 100% consistency, there are some other cases to take care of

@@ -190,12 +190,15 @@ open class NumberFormatter : Formatter {
case .currency, .currencyPlural, .currencyISOCode, .currencyAccounting:
_usesSignificantDigits = false
_usesGroupingSeparator = true
if _minimumIntegerDigits == nil {
_minimumIntegerDigits = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, I believe this value is 0 for .currencyPlural on Darwin. Likewise, I see the value being 1 for .percent, which I believe is falling into the default case (along with .scientific, which is correctly 0).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add some more test cases to compare against native Foundation and fix up these others.

- Fix rawValue for Style.{currencyISOCode,currencyPlural,currencyAccounting}

- Fix minimumIntegerDigits for .currencyPlural

- Fix usesSignificantDigits, minimumIntegerDigits and groupingSize for
  .percent
@spevans
Copy link
Contributor Author

spevans commented Apr 24, 2018

@itaiferber I added some more tests for all of the number styles and fixed an issue with the rawValues being wrong for .currencyISOCode,.currencyPlural,.currencyAccounting

Definitely needs more tests for the other properties but I think this fixes the .minimumIntegerDigits for now.

Validated against 10.13.4's Foundation.

@spevans
Copy link
Contributor Author

spevans commented Apr 24, 2018

@swift-ci please test

1 similar comment
@spevans
Copy link
Contributor Author

spevans commented Apr 25, 2018

@swift-ci please test

@itaiferber
Copy link
Contributor

@spevans LGTM, thanks! Good catch on the rawValues.

@spevans
Copy link
Contributor Author

spevans commented Apr 25, 2018

@swift-ci please test and merge

@swift-ci swift-ci merged commit 0464812 into swiftlang:master Apr 25, 2018
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