From f4e3da55859d3c9bf53490c82d81d400048d1194 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Thu, 18 Jul 2019 09:46:05 -0700 Subject: [PATCH] [Intl] camelCase except-zero and narrow-symbol Sync with https://github.com/tc39/proposal-unified-intl-numberformat/pull/54 Bug: v8:9483 Change-Id: I2aec5a78be235bddd4faa568665b73b9b84d7c93 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1700426 Reviewed-by: Adam Klein Reviewed-by: Mathias Bynens Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/master@{#62819} --- src/init/heap-symbols.h | 4 ++-- src/objects/js-number-format.cc | 16 ++++++++-------- .../number-format/unified/currency-display.js | 2 +- test/intl/number-format/unified/sign-display.js | 2 +- test/test262/test262.status | 3 +++ 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/init/heap-symbols.h b/src/init/heap-symbols.h index b8b09a1519..286a0cac76 100644 --- a/src/init/heap-symbols.h +++ b/src/init/heap-symbols.h @@ -32,7 +32,7 @@ V(_, first_string, "first") \ V(_, format_string, "format") \ V(_, fractionalSecond_string, "fractionalSecond") \ - V(_, except_zero_string, "except-zero") \ + V(_, exceptZero_string, "exceptZero") \ V(_, exponentInteger_string, "exponentInteger") \ V(_, exponentMinusSign_string, "exponentMinusSign") \ V(_, exponentSeparator_string, "exponentSeparator") \ @@ -70,7 +70,7 @@ V(_, minute_string, "minute") \ V(_, month_string, "month") \ V(_, nan_string, "nan") \ - V(_, narrow_symbol_string, "narrow-symbol") \ + V(_, narrowSymbol_string, "narrowSymbol") \ V(_, never_string, "never") \ V(_, none_string, "none") \ V(_, notation_string, "notation") \ diff --git a/src/objects/js-number-format.cc b/src/objects/js-number-format.cc index fdabe45904..c1fc7e299c 100644 --- a/src/objects/js-number-format.cc +++ b/src/objects/js-number-format.cc @@ -42,8 +42,8 @@ enum class Style { }; // [[CurrencyDisplay]] is one of the values "code", "symbol", "name", -// or "narrow-symbol" identifying the display of the currency number format. -// Note: "narrow-symbol" is added in proposal-unified-intl-numberformat +// or "narrowSymbol" identifying the display of the currency number format. +// Note: "narrowSymbol" is added in proposal-unified-intl-numberformat enum class CurrencyDisplay { CODE, SYMBOL, @@ -95,7 +95,7 @@ enum class CompactDisplay { }; // [[SignDisplay]] is one of the String values "auto", "always", "never", or -// "except-zero", specifying whether to show the sign on negative numbers +// "exceptZero", specifying whether to show the sign on negative numbers // only, positive and negative numbers including zero, neither positive nor // negative numbers, or positive and negative numbers but not zero. enum class SignDisplay { @@ -359,7 +359,7 @@ Handle CurrencyDisplayString(Isolate* isolate, // Ex: skeleton as // "currency/TWD .00 rounding-mode-half-up unit-width-narrow; if (skeleton.indexOf("unit-width-narrow") >= 0) { - return ReadOnlyRoots(isolate).narrow_symbol_string_handle(); + return ReadOnlyRoots(isolate).narrowSymbol_string_handle(); } // Ex: skeleton as "currency/TWD .00 rounding-mode-half-up" return ReadOnlyRoots(isolate).symbol_string_handle(); @@ -482,7 +482,7 @@ Handle SignDisplayString(Isolate* isolate, // "currency/TWD .00 rounding-mode-half-up sign-except-zero" if (skeleton.indexOf("sign-accounting-except-zero") >= 0 || skeleton.indexOf("sign-except-zero") >= 0) { - return ReadOnlyRoots(isolate).except_zero_string_handle(); + return ReadOnlyRoots(isolate).exceptZero_string_handle(); } return ReadOnlyRoots(isolate).auto_string_handle(); } @@ -1006,7 +1006,7 @@ MaybeHandle JSNumberFormat::New(Isolate* isolate, std::vector currency_display_enum_values( {CurrencyDisplay::CODE, CurrencyDisplay::SYMBOL, CurrencyDisplay::NAME}); if (FLAG_harmony_intl_numberformat_unified) { - currency_display_str_values.push_back("narrow-symbol"); + currency_display_str_values.push_back("narrowSymbol"); currency_display_enum_values.push_back(CurrencyDisplay::NARROW_SYMBOL); } Maybe maybe_currency_display = @@ -1210,10 +1210,10 @@ MaybeHandle JSNumberFormat::New(Isolate* isolate, if (FLAG_harmony_intl_numberformat_unified) { // 32. Let signDisplay be ? GetOption(options, "signDisplay", "string", « - // "auto", "never", "always", "except-zero" », "auto"). + // "auto", "never", "always", "exceptZero" », "auto"). Maybe maybe_sign_display = Intl::GetStringOption( isolate, options, "signDisplay", service, - {"auto", "never", "always", "except-zero"}, + {"auto", "never", "always", "exceptZero"}, {SignDisplay::AUTO, SignDisplay::NEVER, SignDisplay::ALWAYS, SignDisplay::EXCEPT_ZERO}, SignDisplay::AUTO); diff --git a/test/intl/number-format/unified/currency-display.js b/test/intl/number-format/unified/currency-display.js index 4f7acb97c8..effd026778 100644 --- a/test/intl/number-format/unified/currency-display.js +++ b/test/intl/number-format/unified/currency-display.js @@ -27,7 +27,7 @@ const testData = [ ["name", "123.00 New Taiwan dollars"], ["code", "TWD 123.00"], ["symbol", "NT$123.00"], - ["narrow-symbol", "$123.00"], // new + ["narrowSymbol", "$123.00"], // new ]; for (const [currencyDisplay, expectation] of testData) { diff --git a/test/intl/number-format/unified/sign-display.js b/test/intl/number-format/unified/sign-display.js index cdd7de0061..c71f57e67c 100644 --- a/test/intl/number-format/unified/sign-display.js +++ b/test/intl/number-format/unified/sign-display.js @@ -15,7 +15,7 @@ const testData = [ ["auto", "-123", "-0", "0", "123"], ["always", "-123", "-0", "+0", "+123"], ["never", "123", "0", "0", "123"], - ["except-zero", "-123", "-0", "0", "+123"], + ["exceptZero", "-123", "-0", "0", "+123"], ]; for (const [signDisplay, neg, negZero, zero, pos] of testData) { diff --git a/test/test262/test262.status b/test/test262/test262.status index 9a6a040f2c..2433130969 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -83,6 +83,9 @@ # https://bugs.chromium.org/p/v8/issues/detail?id=9319 'intl402/NumberFormat/prototype/resolvedOptions/order': [FAIL], + # crbug.com/v8/9483 + 'intl402/NumberFormat/currencyDisplay-unit': [FAIL], + # https://bugs.chromium.org/p/v8/issues/detail?id=9084 'intl402/supportedLocalesOf-consistent-with-resolvedOptions': [FAIL], 'intl402/fallback-locales-are-supported': [FAIL],