diff --git a/spec.emu b/spec.emu index 46fa79a..562f17e 100644 --- a/spec.emu +++ b/spec.emu @@ -5,7 +5,7 @@
 title: Intl Sequence Units
-stage: 0
+stage: 2
 contributors: Shane F Carr
 
@@ -125,6 +125,8 @@ contributors: Shane F Carr 1. Else, 1. Let _mxfdDefault_ be 3. 1. Perform ? SetNumberFormatDigitOptions(_numberFormat_, _options_, _mnfdDefault_, _mxfdDefault_, _notation_). + 1. If _style_ is *"unit"* and StringIndexOf(_numberFormat_.[[Unit]], *"-and-"*, 0) is not ~not-found~, then + 1. If _numberFormat_.[[RoundingType]] is not ~fraction-digits~, throw a *RangeError* exception. 1. Let _compactDisplay_ be ? GetOption(_options_, *"compactDisplay"*, ~string~, « *"short"*, *"long"* », *"short"*). 1. Let _defaultUseGrouping_ be *"auto"*. 1. If _notation_ is *"compact"*, then @@ -209,14 +211,16 @@ contributors: Shane F Carr 1. If _value_ is not an Object, throw a *TypeError* exception. 1. Let _sequence_ be StringSplitToList(_unit_, *"-and-"*). + 1. Let _iteratorRecord_ be ? GetIterator(_value_, ~sync~). + 1. Let _iterableValues_ be ? IteratorToList(_iteratorRecord_). + 1. If the length of _iterableValues_ is not the length of _sequence_, throw a *RangeError* exception. 1. Let _values_ be a new empty List. 1. Let _hasNegative_ be *false*. 1. Let _hasPositive_ be *false*. 1. Let _hasNonInteger_ be *false*. 1. Let _i_ be 0. - 1. For each String _subUnit_ of _sequence_, do + 1. For each ECMAScript language value _subValue_ of _iterableValues_, do 1. If _i_ is the length of _sequence_ - 1, let _isLast_ be *true*; else let _isLast_ be *false*. - 1. Let _subValue_ be ? Get(_value_, _subUnit_). 1. If _subValue_ is *undefined*, throw a *TypeError* exception. 1. Let _x_ be ? ToIntlMathematicalValue(_subValue_). 1. If _isLast_ is *false* and _x_ is not an integer, set _hasNonInteger_ to *true*. @@ -288,6 +292,7 @@ contributors: Shane F Carr 1. Assert: _numberFormat_.[[Style]] is *"unit"* and StringIndexOf(_numberFormat_.[[Unit]], *"-and-"*, 0) is not ~not-found~. + 1. Assert: _numberFormat_.[[RoundingType]] is ~fraction-digits~. 1. Let _sequence_ be StringSplitToList(_numberFormat_.[[Unit]], *"-and-"*). 1. Let _partitionedPartsList_ be a new empty List. 1. Let _lfOpts_ be OrdinaryObjectCreate(*null*). @@ -296,11 +301,8 @@ contributors: Shane F Carr 1. Let _lf_ be ! Construct(%Intl.ListFormat%, « _numberFormat_.[[Locale]], _lfOpts_ »). 1. Let _strings_ be a new empty List. 1. Let _originalUnit_ be _numberFormat_.[[Unit]]. - 1. Let _originalRoundingType_ be _numberFormat_.[[RoundingType]]. 1. Let _originalMinFD_ be _numberFormat_.[[MinimumFractionDigits]]. 1. Let _originalMaxFD_ be _numberFormat_.[[MaximumFractionDigits]]. - 1. Let _originalMinSD_ be _numberFormat_.[[MinimumSignificantDigits]]. - 1. Let _originalMaxSD_ be _numberFormat_.[[MaximumSignificantDigits]]. 1. Let _i_ be 0. 1. For each Intl mathematical value _x_ of _values_, do 1. If _i_ is 0, let _isFirst_ be *true*; else let _isFirst_ be *false*. @@ -311,15 +313,11 @@ contributors: Shane F Carr 1. Let _subUnit_ be _sequence_[_i_]. 1. Set _numberFormat_.[[Unit]] to _subUnit_. 1. If _isLast_ is *false*, then - 1. Set _numberFormat_.[[RoundingType]] to ~fraction-digits~. 1. Set _numberFormat_.[[MinimumFractionDigits]] to 0. 1. Set _numberFormat_.[[MaximumFractionDigits]] to 3. 1. Else, - 1. Set _numberFormat_.[[RoundingType]] to _originalRoundingType_. 1. Set _numberFormat_.[[MinimumFractionDigits]] to _originalMinFD_. 1. Set _numberFormat_.[[MaximumFractionDigits]] to _originalMaxFD_. - 1. Set _numberFormat_.[[MinimumSignificantDigits]] to _originalMinSD_. - 1. Set _numberFormat_.[[MaximumSignificantDigits]] to _originalMaxSD_. 1. Let _parts_ be PartitionNumberPattern(_numberFormat_, _x_). 1. Append _parts_ to _partitionedPartsList_. 1. Let _string_ be the empty String.