@@ -174,9 +174,11 @@ describe('NumberParser', function () {
174
174
} ) ;
175
175
176
176
describe ( 'round trips' , function ( ) {
177
+ fc . configureGlobal ( { numRuns : 200 } ) ;
177
178
// Locales have to include: 'de-DE', 'ar-EG', 'fr-FR' and possibly others
178
179
// But for the moment they are not properly supported
179
180
const localesArb = fc . constantFrom ( ...locales ) ;
181
+ const numeralArb = fc . constantFrom ( 'latn' , 'arab' , 'hanidec' , 'deva' , 'beng' ) ;
180
182
const styleOptsArb = fc . oneof (
181
183
{ withCrossShrink : true } ,
182
184
fc . record ( { style : fc . constant ( 'decimal' ) } ) ,
@@ -210,35 +212,35 @@ describe('NumberParser', function () {
210
212
fc . double ( { next : true , noNaN : true , min : DOUBLE_MIN , max : 1 / DOUBLE_MIN } )
211
213
) . map ( ( [ sign , value ] ) => sign * value ) ;
212
214
213
- const inputsArb = fc . tuple ( valueArb , localesArb , styleOptsArb , genericOptsArb )
214
- . map ( ( [ d , locale , styleOpts , genericOpts ] ) => ( { d, opts : { ...styleOpts , ...genericOpts } , locale} ) )
215
+ const inputsArb = fc . tuple ( valueArb , localesArb , styleOptsArb , genericOptsArb , numeralArb )
216
+ . map ( ( [ d , locale , styleOpts , genericOpts , numerals ] ) => ( { d, opts : { ...styleOpts , ...genericOpts } , locale, numerals } ) )
215
217
. filter ( ( { opts} ) => opts . minimumFractionDigits === undefined || opts . maximumFractionDigits === undefined || opts . minimumFractionDigits <= opts . maximumFractionDigits )
216
218
. filter ( ( { opts} ) => opts . minimumSignificantDigits === undefined || opts . maximumSignificantDigits === undefined || opts . minimumSignificantDigits <= opts . maximumSignificantDigits )
217
- . map ( ( { d, opts, locale} ) => {
219
+ . map ( ( { d, opts, locale, numerals } ) => {
218
220
if ( opts . style === 'percent' ) {
219
221
opts . minimumFractionDigits = opts . minimumFractionDigits > 18 ? 18 : opts . minimumFractionDigits ;
220
222
opts . maximumFractionDigits = opts . maximumFractionDigits > 18 ? 18 : opts . maximumFractionDigits ;
221
223
}
222
- return { d, opts, locale} ;
224
+ return { d, opts, locale, numerals } ;
223
225
} )
224
- . map ( ( { d, opts, locale} ) => {
226
+ . map ( ( { d, opts, locale, numerals } ) => {
225
227
let adjustedNumberForFractions = d ;
226
228
if ( Math . abs ( d ) < 1 && opts . minimumFractionDigits && opts . minimumFractionDigits > 1 ) {
227
229
adjustedNumberForFractions = d * ( 10 ** ( opts . minimumFractionDigits || 2 ) ) ;
228
230
} else if ( Math . abs ( d ) > 1 && opts . minimumFractionDigits && opts . minimumFractionDigits > 1 ) {
229
231
adjustedNumberForFractions = d / ( 10 ** ( opts . minimumFractionDigits || 2 ) ) ;
230
232
}
231
- return { adjustedNumberForFractions, opts, locale} ;
233
+ return { adjustedNumberForFractions, opts, locale, numerals } ;
232
234
} ) ;
233
235
234
236
// skipping until we can reliably run it, until then, it's good to run manually
235
237
// track counter examples below
236
- it . skip ( 'should fully reverse NumberFormat' , function ( ) {
238
+ it ( 'should fully reverse NumberFormat' , function ( ) {
237
239
fc . assert (
238
240
fc . property (
239
241
inputsArb ,
240
- function ( { adjustedNumberForFractions, locale, opts} ) {
241
- const formatter = new Intl . NumberFormat ( locale , opts ) ;
242
+ function ( { adjustedNumberForFractions, locale, opts, numerals } ) {
243
+ const formatter = new Intl . NumberFormat ( ` ${ locale } -u-nu- ${ numerals } ` , opts ) ;
242
244
const parser = new NumberParser ( locale , opts ) ;
243
245
244
246
const formattedOnce = formatter . format ( adjustedNumberForFractions ) ;
@@ -264,7 +266,7 @@ describe('NumberParser', function () {
264
266
expect ( formatter . format ( parser . parse ( formattedOnce ) ) ) . toBe ( formattedOnce ) ;
265
267
} ) ;
266
268
// See Bug https://github.com/nodejs/node/issues/49919
267
- it . skip ( 'formatted units keep their number' , ( ) => {
269
+ it ( 'formatted units keep their number' , ( ) => {
268
270
let locale = 'da-DK' ;
269
271
let options = {
270
272
style : 'unit' ,
0 commit comments