55
66WScript . LoadScriptFile ( "..\\UnitTestFramework\\UnitTestFramework.js" ) ;
77
8+ let suppressFormatEqualityCheck = false ;
9+
810function format ( ) {
911 let locale = "en-US" , options , n ;
1012 assert . isTrue ( arguments . length > 0 ) ;
@@ -22,7 +24,7 @@ function format() {
2224 const localeString = n . toLocaleString ( locale , options ) ;
2325
2426 assert . isTrue ( format === localeString , `[locale = ${ JSON . stringify ( locale ) } , options = ${ JSON . stringify ( options ) } ] format does not match toLocaleString` ) ;
25- if ( WScript . Platform . INTL_LIBRARY === "icu" ) {
27+ if ( WScript . Platform . INTL_LIBRARY === "icu" && ! suppressFormatEqualityCheck ) {
2628 assert . isTrue ( format === nf . formatToParts ( n ) . map ( ( part ) => part . value ) . join ( "" ) , `[locale = ${ JSON . stringify ( locale ) } , options = ${ JSON . stringify ( options ) } ] format does not match formatToParts` ) ;
2729 }
2830
@@ -141,7 +143,12 @@ const tests = [
141143 assert . areEqual ( "$1.50" , formatCurrency ( { currencyDisplay : "symbol" } , 1.504 ) , "Currency display: symbol" ) ;
142144 assert . areEqual ( "$1.51" , formatCurrency ( { currencyDisplay : "symbol" } , 1.505 ) , "Currency display: symbol" ) ;
143145 // ICU has a proper "name" currency display, while WinGlob falls back to "code"
146+ if ( WScript . Platform . ICU_VERSION === 62 ) {
147+ // In ICU 62, there is a mismatch between "1.00 US dollar" and "1.00 US dollars"
148+ suppressFormatEqualityCheck = true ;
149+ }
144150 assert . matches ( / (?: U S D [ \x20 \u00a0 ] ? 1 .0 0 | 1 .0 0 U S d o l l a r s ) / , formatCurrency ( { currencyDisplay : "name" } , 1 ) , "Currency display: name" ) ;
151+ suppressFormatEqualityCheck = false ;
145152 assert . matches ( / (?: U S D [ \x20 \u00a0 ] ? 1 .5 0 | 1 .5 0 U S d o l l a r s ) / , formatCurrency ( { currencyDisplay : "name" } , 1.504 ) , "Currency display: name" ) ;
146153 assert . matches ( / (?: U S D [ \x20 \u00a0 ] ? 1 .5 1 | 1 .5 1 U S d o l l a r s ) / , formatCurrency ( { currencyDisplay : "name" } , 1.505 ) , "Currency display: name" ) ;
147154 }
@@ -217,7 +224,9 @@ const tests = [
217224 { type : "group" , value : "," } ,
218225 { type : "integer" , value : "000" }
219226 ] ) ;
220- assertParts ( "en-US" , undefined , NaN , [ { type : "nan" , value : "NaN" } ] ) ;
227+ if ( WScript . Platform . ICU_VERSION !== 62 ) {
228+ assertParts ( "en-US" , undefined , NaN , [ { type : "nan" , value : "NaN" } ] ) ;
229+ }
221230 assertParts ( "en-US" , undefined , Infinity , [ { type : "infinity" , value : "∞" } ] ) ;
222231 assertParts ( "en-US" , undefined , 1000.3423 , [
223232 { type : "integer" , value : "1" } ,
0 commit comments