Skip to content

Commit

Permalink
Normative: Fix order of rounding* option reads and resolvedOptions()
Browse files Browse the repository at this point in the history
Ref #768

* Read "roundingIncrement", "roundingMode", "roundingPriority", "trailingZeroDisplay" in alphabetic order.
* Output "pluralCategories", "roundingIncrement", "roundingMode", "roundingPriority", "trailingZeroDisplay" in alphabetic order.
  • Loading branch information
FrankYFTang committed Oct 3, 2023
1 parent 2f002b2 commit 5a43090
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
10 changes: 5 additions & 5 deletions spec/numberformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ <h1>
1. Let _mnsd_ be ? Get(_options_, *"minimumSignificantDigits"*).
1. Let _mxsd_ be ? Get(_options_, *"maximumSignificantDigits"*).
1. Set _intlObj_.[[MinimumIntegerDigits]] to _mnid_.
1. Let _roundingPriority_ be ? GetOption(_options_, *"roundingPriority"*, ~string~, &laquo; *"auto"*, *"morePrecision"*, *"lessPrecision"* &raquo;, *"auto"*).
1. Let _roundingIncrement_ be ? GetNumberOption(_options_, *"roundingIncrement"*, 1, 5000, 1).
1. If _roundingIncrement_ is not in « 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 », throw a *RangeError* exception.
1. Let _roundingMode_ be ? GetOption(_options_, *"roundingMode"*, ~string~, &laquo; *"ceil"*, *"floor"*, *"expand"*, *"trunc"*, *"halfCeil"*, *"halfFloor"*, *"halfExpand"*, *"halfTrunc"*, *"halfEven"* &raquo;, *"halfExpand"*).
1. Let _roundingPriority_ be ? GetOption(_options_, *"roundingPriority"*, ~string~, &laquo; *"auto"*, *"morePrecision"*, *"lessPrecision"* &raquo;, *"auto"*).
1. Let _trailingZeroDisplay_ be ? GetOption(_options_, *"trailingZeroDisplay"*, ~string~, &laquo; *"auto"*, *"stripIfInteger"* &raquo;, *"auto"*).
1. NOTE: All fields required by SetNumberFormatDigitOptions have now been read from _options_. The remainder of this AO interprets the options and may throw exceptions.
1. If _roundingIncrement_ is not 1, set _mxfdDefault_ to _mnfdDefault_.
Expand Down Expand Up @@ -490,14 +490,14 @@ <h1>Intl.NumberFormat.prototype.resolvedOptions ( )</h1>
<td>[[SignDisplay]]</td>
<td>*"signDisplay"*</td>
</tr>
<tr>
<td>[[RoundingMode]]</td>
<td>*"roundingMode"*</td>
</tr>
<tr>
<td>[[RoundingIncrement]]</td>
<td>*"roundingIncrement"*</td>
</tr>
<tr>
<td>[[RoundingMode]]</td>
<td>*"roundingMode"*</td>
</tr>
<tr>
<td>[[ComputedRoundingPriority]]</td>
<td>*"roundingPriority"*</td>
Expand Down
26 changes: 15 additions & 11 deletions spec/pluralrules.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,15 @@ <h1>Intl.PluralRules.prototype.resolvedOptions ( )</h1>
1. Let _pr_ be the *this* value.
1. Perform ? RequireInternalSlot(_pr_, [[InitializedPluralRules]]).
1. Let _options_ be OrdinaryObjectCreate(%Object.prototype%).
1. Let _pluralCategories_ be a List of Strings containing all possible results of <emu-xref href="#sec-pluralruleselect">PluralRuleSelect</emu-xref> for the selected locale _pr_.[[Locale]].
1. For each row of <emu-xref href="#table-pluralrules-resolvedoptions-properties"></emu-xref>, except the header row, in table order, do
1. Let _p_ be the Property value of the current row.
1. Let _v_ be the value of _pr_'s internal slot whose name is the Internal Slot value of the current row.
1. If _p_ is *"pluralCategories"*, then
1. Let _v_ be CreateArrayFromList(_pluralCategories_).
1. Else,
1. Let _v_ be the value of _pr_'s internal slot whose name is the Internal Slot value of the current row.
1. If _v_ is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_options_, _p_, _v_).
1. Let _pluralCategories_ be a List of Strings containing all possible results of <emu-xref href="#sec-pluralruleselect">PluralRuleSelect</emu-xref> for the selected locale _pr_.[[Locale]].
1. Perform ! CreateDataProperty(_options_, *"pluralCategories"*, CreateArrayFromList(_pluralCategories_)).
1. If _pr_.[[RoundingType]] is ~morePrecision~, then
1. Perform ! CreateDataPropertyOrThrow(_options_, *"roundingPriority"*, *"morePrecision"*).
1. Else if _pr_.[[RoundingType]] is ~lessPrecision~, then
1. Perform ! CreateDataPropertyOrThrow(_options_, *"roundingPriority"*, *"lessPrecision"*).
1. Else,
1. Perform ! CreateDataPropertyOrThrow(_options_, *"roundingPriority"*, *"auto"*).
1. Return _options_.
</emu-alg>

Expand Down Expand Up @@ -226,13 +222,21 @@ <h1>Intl.PluralRules.prototype.resolvedOptions ( )</h1>
<td>*"maximumSignificantDigits"*</td>
</tr>
<tr>
<td>[[RoundingMode]]</td>
<td>*"roundingMode"*</td>
<td> </td>
<td>*"pluralCategories"*</td>
</tr>
<tr>
<td>[[RoundingIncrement]]</td>
<td>*"roundingIncrement"*</td>
</tr>
<tr>
<td>[[RoundingMode]]</td>
<td>*"roundingMode"*</td>
</tr>
<tr>
<td>[[ComputedRoundingPriority]]</td>
<td>*"roundingPriority"*</td>
</tr>
<tr>
<td>[[TrailingZeroDisplay]]</td>
<td>*"trailingZeroDisplay"*</td>
Expand Down

0 comments on commit 5a43090

Please sign in to comment.