Title: [282923] trunk
Revision
282923
Author
ysuz...@apple.com
Date
2021-09-22 21:56:05 -0700 (Wed, 22 Sep 2021)

Log Message

[JSC] Adjust Intl currency enumeration
https://bugs.webkit.org/show_bug.cgi?id=230656

Reviewed by Ross Kirsling.

JSTests:

* stress/intl-enumeration.js:
* test262/expectations.yaml:

Source/_javascript_Core:

1. List up all available currencies.
2. Introduce a work-around for VES, LSM, and EQE

* runtime/IntlObject.cpp:
(JSC::availableCurrencies):

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (282922 => 282923)


--- trunk/JSTests/ChangeLog	2021-09-23 04:52:05 UTC (rev 282922)
+++ trunk/JSTests/ChangeLog	2021-09-23 04:56:05 UTC (rev 282923)
@@ -1,5 +1,15 @@
 2021-09-22  Yusuke Suzuki  <ysuz...@apple.com>
 
+        [JSC] Adjust Intl currency enumeration
+        https://bugs.webkit.org/show_bug.cgi?id=230656
+
+        Reviewed by Ross Kirsling.
+
+        * stress/intl-enumeration.js:
+        * test262/expectations.yaml:
+
+2021-09-22  Yusuke Suzuki  <ysuz...@apple.com>
+
         [JSC] emoji and eor collations are missing
         https://bugs.webkit.org/show_bug.cgi?id=230652
 

Modified: trunk/JSTests/stress/intl-enumeration.js (282922 => 282923)


--- trunk/JSTests/stress/intl-enumeration.js	2021-09-23 04:52:05 UTC (rev 282922)
+++ trunk/JSTests/stress/intl-enumeration.js	2021-09-23 04:56:05 UTC (rev 282923)
@@ -22,7 +22,7 @@
 shouldBe(JSON.stringify(collations), `["big5han","compat","dict","emoji","eor","gb2312","phonebk","phonetic","pinyin","reformed","searchjl","stroke","trad","unihan","zhuyin"]`);
 
 let currencies = Intl.supportedValuesOf("currency");
-shouldBe(JSON.stringify(currencies), `["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF",&q
 uot;IDR","ILS","INR","IQD","IRR","ISK","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","S
 GD","SHP","SLL","SOS","SRD","SSP","STN","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEF","VND","VUV","WST","XAF","XCD","XOF","XPF","YER","ZAR","ZMW"]`);
+shouldBe(JSON.stringify(currencies), `["ADP","AED","AFA","AFN","ALK","ALL","AMD","ANG","AOA","AOK","AON","AOR","ARA","ARL","ARM","ARP","ARS","ATS","AUD","AWG","AZM","AZN","BAD","BAM","BAN","BBD","BDT","BEC","BEF","BEL","BGL","BGM","BGN","BGO","BHD","BIF","BMD","BND","BOB","BOL","BOP","BOV","BRB","BRC","BRE","BRL","BRN","BRR","BRZ","BSD","BTN","BUK","BWP","BYB","BYN","BYR","BZD","CAD","CDF",&qu
 ot;CHE","CHF","CHW","CLE","CLF","CLP","CNH","CNX","CNY","COP","COU","CRC","CSD","CSK","CUC","CUP","CVE","CYP","CZK","DDM","DEM","DJF","DKK","DOP","DZD","ECS","ECV","EEK","EGP","ERN","ESA","ESB","ESP","ETB","EUR","FIM","FJD","FKP","FRF","GBP","GEK","GEL","GHC","GHS","GIP","GMD","GNF","GNS","GQE","GRD","GTQ","GWE","GWP","GYD","HKD","HNL","HRD","HRK","HTG","HUF","IDR","IEP","IL
 P","ILR","ILS","INR","IQD","IRR","ISJ","ISK","ITL","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRH","KRO","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LTL","LTT","LUC","LUF","LUL","LVL","LVR","LYD","MAD","MAF","MCF","MDC","MDL","MGA","MGF","MKD","MKN","MLF","MMK","MNT","MOP","MRO","MRU","MTL","MTP","MUR","MVP","MVR","MWK","MXN","MXP","MXV","MYR","MZE","MZM&quo
 t;,"MZN","NAD","NGN","NIC","NIO","NLG","NOK","NPR","NZD","OMR","PAB","PEI","PEN","PES","PGK","PHP","PKR","PLN","PLZ","PTE","PYG","QAR","RHD","ROL","RON","RSD","RUB","RUR","RWF","SAR","SBD","SCR","SDD","SDG","SDP","SEK","SGD","SHP","SIT","SKK","SLL","SOS","SRD","SRG","SSP","STD","STN","SUR","SVC","SYP","SZL","THB","TJR","TJS","TMM","TMT","TND","TOP","TPE","TRL","TRY","TTD",&q
 uot;TWD","TZS","UAH","UAK","UGS","UGX","USD","USN","USS","UYI","UYP","UYU","UYW","UZS","VEB","VEF","VES","VND","VNN","VUV","WST","XAF","XAG","XAU","XBA","XBB","XBC","XBD","XCD","XDR","XEU","XFO","XFU","XOF","XPD","XPF","XPT","XRE","XSU","XTS","XUA","XXX","YDD","YER","YUD","YUM","YUN","YUR","ZAL","ZAR","ZMK","ZMW","ZRN","ZRZ","ZWD","ZWL","ZWR"]`);
 
 let numberingSystems = Intl.supportedValuesOf("numberingSystem");
 let numberingSystemsString = JSON.stringify(numberingSystems);

Modified: trunk/JSTests/test262/expectations.yaml (282922 => 282923)


--- trunk/JSTests/test262/expectations.yaml	2021-09-23 04:52:05 UTC (rev 282922)
+++ trunk/JSTests/test262/expectations.yaml	2021-09-23 04:56:05 UTC (rev 282923)
@@ -849,9 +849,6 @@
 test/intl402/Intl/getCanonicalLocales/unicode-ext-canonicalize-subdivision.js:
   default: 'Test262Error: Expected SameValue(«und-NO-u-sd-no23», «und-NO-u-sd-no50») to be true'
   strict mode: 'Test262Error: Expected SameValue(«und-NO-u-sd-no23», «und-NO-u-sd-no50») to be true'
-test/intl402/Intl/supportedValuesOf/currencies-accepted-by-DisplayNames.js:
-  default: 'Test262Error: ADP supported but not returned by supportedValuesOf'
-  strict mode: 'Test262Error: ADP supported but not returned by supportedValuesOf'
 test/intl402/Intl/supportedValuesOf/numberingSystems-accepted-by-DateTimeFormat.js:
   default: 'Test262Error: armn is supported by DateTimeFormat Expected SameValue(«latn», «armn») to be true'
   strict mode: 'Test262Error: armn is supported by DateTimeFormat Expected SameValue(«latn», «armn») to be true'

Modified: trunk/Source/_javascript_Core/ChangeLog (282922 => 282923)


--- trunk/Source/_javascript_Core/ChangeLog	2021-09-23 04:52:05 UTC (rev 282922)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-09-23 04:56:05 UTC (rev 282923)
@@ -1,5 +1,18 @@
 2021-09-22  Yusuke Suzuki  <ysuz...@apple.com>
 
+        [JSC] Adjust Intl currency enumeration
+        https://bugs.webkit.org/show_bug.cgi?id=230656
+
+        Reviewed by Ross Kirsling.
+
+        1. List up all available currencies.
+        2. Introduce a work-around for VES, LSM, and EQE
+
+        * runtime/IntlObject.cpp:
+        (JSC::availableCurrencies):
+
+2021-09-22  Yusuke Suzuki  <ysuz...@apple.com>
+
         [JSC] emoji and eor collations are missing
         https://bugs.webkit.org/show_bug.cgi?id=230652
 

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (282922 => 282923)


--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2021-09-23 04:52:05 UTC (rev 282922)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2021-09-23 04:56:05 UTC (rev 282923)
@@ -1697,7 +1697,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     UErrorCode status = U_ZERO_ERROR;
-    auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(ucurr_openISOCurrencies(UCURR_COMMON | UCURR_NON_DEPRECATED, &status));
+    auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(ucurr_openISOCurrencies(UCURR_ALL, &status));
     if (U_FAILURE(status)) {
         throwTypeError(globalObject, scope, "failed to enumerate available currencies"_s);
         return { };
@@ -1710,15 +1710,28 @@
     }
 
     Vector<String, 1> elements;
-    elements.reserveInitialCapacity(count);
+    // ICU ~69 doesn't list VES and UYW, but it is actually supported via Intl.DisplayNames.
+    // And ICU ~69 lists up EQE / LSM while it cannot return information via Intl.DisplayNames.
+    // So, we need to add the following work-around.
+    //     1. Add VES and UYW
+    //     2. Do not add EQE and LSM
+    // https://unicode-org.atlassian.net/browse/ICU-21685
+    elements.reserveInitialCapacity(count + 2);
+    elements.append("VES"_s);
+    elements.append("UYW"_s);
     for (int32_t index = 0; index < count; ++index) {
         int32_t length = 0;
-        const char* currency = uenum_next(enumeration.get(), &length, &status);
+        const char* pointer = uenum_next(enumeration.get(), &length, &status);
         if (U_FAILURE(status)) {
             throwTypeError(globalObject, scope, "failed to enumerate available currencies"_s);
             return { };
         }
-        elements.constructAndAppend(currency, length);
+        String currency(pointer, length);
+        if (currency == "EQE"_s)
+            continue;
+        if (currency == "LSM"_s)
+            continue;
+        elements.append(WTFMove(currency));
     }
 
     // The AvailableCurrencies abstract operation returns a List, ordered as if an Array of the same
@@ -1727,6 +1740,8 @@
         [](const String& a, const String& b) {
             return WTF::codePointCompare(a, b) < 0;
         });
+    auto end = std::unique(elements.begin(), elements.end());
+    elements.resize(elements.size() - (elements.end() - end));
 
     RELEASE_AND_RETURN(scope, createArrayFromStringVector(globalObject, WTFMove(elements)));
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to