From 79a01f512281f3b3b0189c28e26ff1080d72ce31 Mon Sep 17 00:00:00 2001 From: Frank Yung-Fong Tang <41213225+FrankYFTang@users.noreply.github.com> Date: Tue, 8 Oct 2019 11:48:46 -0700 Subject: [PATCH] Add tests for 'numberingSystem' and 'calendar' options (#2383) * Add tests for 'numberingSystem' option * add constructor-numberingSystem-order.js * correct esid * initial actual * add let * add constructor-calendar-numberingSystem-order.js --- ...structor-calendar-numberingSystem-order.js | 48 +++++++++++++++++++ .../constructor-numberingSystem-order.js | 43 +++++++++++++++++ .../constructor-options-throwing-getters.js | 1 + 3 files changed, 92 insertions(+) create mode 100644 test/intl402/DateTimeFormat/constructor-calendar-numberingSystem-order.js create mode 100644 test/intl402/NumberFormat/constructor-numberingSystem-order.js diff --git a/test/intl402/DateTimeFormat/constructor-calendar-numberingSystem-order.js b/test/intl402/DateTimeFormat/constructor-calendar-numberingSystem-order.js new file mode 100644 index 0000000000..e1d217ae6d --- /dev/null +++ b/test/intl402/DateTimeFormat/constructor-calendar-numberingSystem-order.js @@ -0,0 +1,48 @@ +// Copyright 2019 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializedatetimeformat +description: Checks the order of getting "calendar" and "numberingSystem" options in the + DateTimeFormat is between "localeMatcher" and "hour12" options. +info: | + 4. Let _matcher_ be ? GetOption(_options_, `"localeMatcher"`, `"string"`, « `"lookup"`, `"best fit"` », `"best fit"`). + ... + 6. Let _calendar_ be ? GetOption(_options_, `"calendar"`, `"string"`, *undefined*, *undefined*). + ... + 9. Let _numberingSystem_ be ? GetOption(_options_, `"numberingSystem"`, `"string"`, *undefined*, *undefined*). + ... + 12. Let _hour12_ be ? GetOption(_options_, `"hour12"`, `"boolean"`, *undefined*, *undefined*). +includes: [compareArray.js] +---*/ + +const actual = []; + +const options = { + get localeMatcher() { + actual.push("localeMatcher"); + return undefined; + }, + get calendar() { + actual.push("calendar"); + return undefined; + }, + get numberingSystem() { + actual.push("numberingSystem"); + return undefined; + }, + get hour12() { + actual.push("hour12"); + return undefined; + }, +}; + +const expected = [ + "localeMatcher", + "calendar", + "numberingSystem", + "hour12" +]; + +let df = new Intl.DateTimeFormat(undefined, options); +assert.compareArray(actual, expected); diff --git a/test/intl402/NumberFormat/constructor-numberingSystem-order.js b/test/intl402/NumberFormat/constructor-numberingSystem-order.js new file mode 100644 index 0000000000..bf3b244a4e --- /dev/null +++ b/test/intl402/NumberFormat/constructor-numberingSystem-order.js @@ -0,0 +1,43 @@ +// Copyright 2019 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializenumberformat +description: Checks the order of getting "numberingSystem" option in the + NumberFormat is between "localeMatcher" and "style" options. +info: | + InitializeNumberFormat ( _numberFormat_, _locales_, _options_ ) + 5. Let _matcher_ be ? GetOption(_options_, `"localeMatcher"`, `"string"`, « `"lookup"`, `"best fit"` », `"best fit"`). + ... + 7. Let _numberingSystem_ be ? GetOption(_options_, `"numberingSystem"`, `"string"`, *undefined*, *undefined*). + ... + 17. Let _style_ be ? GetOption(_options_, `"style"`, `"string"`, « `"decimal"`, `"percent"`, `"currency"` », `"decimal"`). + +includes: [compareArray.js] +---*/ + +var actual = []; + +const options = { + get localeMatcher() { + actual.push("localeMatcher"); + return undefined; + }, + get numberingSystem() { + actual.push("numberingSystem"); + return undefined; + }, + get style() { + actual.push("style"); + return undefined; + }, +}; + +const expected = [ + "localeMatcher", + "numberingSystem", + "style" +]; + +let nf = new Intl.NumberFormat(undefined, options); +assert.compareArray(actual, expected); diff --git a/test/intl402/NumberFormat/constructor-options-throwing-getters.js b/test/intl402/NumberFormat/constructor-options-throwing-getters.js index 8453e83e47..2fa894b5e6 100644 --- a/test/intl402/NumberFormat/constructor-options-throwing-getters.js +++ b/test/intl402/NumberFormat/constructor-options-throwing-getters.js @@ -10,6 +10,7 @@ function CustomError() {} const options = [ "localeMatcher", + "numberingSystem", "style", "currency", "currencyDisplay",