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
This commit is contained in:
Frank Yung-Fong Tang 2019-10-08 11:48:46 -07:00 committed by Leo Balter
parent b073c48b49
commit 79a01f5122
3 changed files with 92 additions and 0 deletions

View File

@ -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);

View File

@ -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);

View File

@ -10,6 +10,7 @@ function CustomError() {}
const options = [
"localeMatcher",
"numberingSystem",
"style",
"currency",
"currencyDisplay",