@@ -0,0 +1,24 @@
// 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 propagation of exceptions from the options for the DateTimeFormat constructor.
features: [Intl.DateTimeFormat-dayPeriod]
---*/

function CustomError() {}

const options = [
"dayPeriod",
];

for (const option of options) {
assert.throws(CustomError, () => {
new Intl.DateTimeFormat("en", {
get [option]() {
throw new CustomError();
}
});
}, `Exception from ${option} getter should be propagated`);
}
@@ -0,0 +1,24 @@
// 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 propagation of exceptions from the options for the DateTimeFormat constructor.
features: [Intl.DateTimeFormat-fractionalSecondDigits]
---*/

function CustomError() {}

const options = [
"fractionalSecondDigits",
];

for (const option of options) {
assert.throws(CustomError, () => {
new Intl.DateTimeFormat("en", {
get [option]() {
throw new CustomError();
}
});
}, `Exception from ${option} getter should be propagated`);
}
@@ -0,0 +1,24 @@
// 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 propagation of exceptions from the options for the DateTimeFormat constructor.
features: [Intl.DateTimeFormat-quarter]
---*/

function CustomError() {}

const options = [
"quarter",
];

for (const option of options) {
assert.throws(CustomError, () => {
new Intl.DateTimeFormat("en", {
get [option]() {
throw new CustomError();
}
});
}, `Exception from ${option} getter should be propagated`);
}
@@ -0,0 +1,29 @@
// Copyright 2019 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.datetimeformat.prototype.resolvedoptions
description: Verifies the property order for the object returned by resolvedOptions().
includes: [compareArray.js]
features: [Intl.DateTimeFormat-dayPeriod]
---*/

const options = new Intl.DateTimeFormat([], {
"dayPeriod": "short",
"hour": "numeric",
"minute": "numeric",
}).resolvedOptions();

const expected = [
"locale",
"calendar",
"numberingSystem",
"timeZone",
"hourCycle",
"hour12",
"dayPeriod",
"hour",
"minute",
];

assert.compareArray(Object.getOwnPropertyNames(options), expected);
@@ -0,0 +1,27 @@
// Copyright 2019 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.datetimeformat.prototype.resolvedoptions
description: Verifies the property order for the object returned by resolvedOptions().
includes: [compareArray.js]
features: [Intl.DateTimeFormat-fractionalSecondDigits]
---*/

const options = new Intl.DateTimeFormat([], {
"fractionalSecondDigits": 3,
"minute": "numeric",
"second": "numeric",
}).resolvedOptions();

const expected = [
"locale",
"calendar",
"numberingSystem",
"timeZone",
"minute",
"second",
"fractionalSecondDigits",
];

assert.compareArray(Object.getOwnPropertyNames(options), expected);
@@ -0,0 +1,29 @@
// Copyright 2019 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.datetimeformat.prototype.resolvedoptions
description: Verifies the property order for the object returned by resolvedOptions().
includes: [compareArray.js]
features: [Intl.DateTimeFormat-quarter]
---*/

const options = new Intl.DateTimeFormat([], {
"year": "numeric",
"quarter": "short",
"month": "numeric",
"day": "numeric",
}).resolvedOptions();

const expected = [
"locale",
"calendar",
"numberingSystem",
"timeZone",
"year",
"quarter",
"month",
"day",
];

assert.compareArray(Object.getOwnPropertyNames(options), expected);
@@ -0,0 +1,16 @@
// Copyright 2019 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: 12.1.1_22
description: >
Tests that the behavior of a Record is not affected by
adversarial changes to Object.prototype.
includes: [testIntl.js]
features: [Intl.DateTimeFormat-dayPeriod]
---*/

taintProperties(["dayPeriod"]);

var locale = new Intl.DateTimeFormat(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale;
assert(isCanonicalizedStructurallyValidLanguageTag(locale), "DateTimeFormat returns invalid locale " + locale + ".");
@@ -0,0 +1,16 @@
// Copyright 2019 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: 12.1.1_22
description: >
Tests that the behavior of a Record is not affected by
adversarial changes to Object.prototype.
includes: [testIntl.js]
features: [Intl.DateTimeFormat-fractionalSecondDigits]
---*/

taintProperties(["fractionalSecondDigits"]);

var locale = new Intl.DateTimeFormat(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale;
assert(isCanonicalizedStructurallyValidLanguageTag(locale), "DateTimeFormat returns invalid locale " + locale + ".");
@@ -0,0 +1,16 @@
// Copyright 2019 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: 12.1.1_22
description: >
Tests that the behavior of a Record is not affected by
adversarial changes to Object.prototype.
includes: [testIntl.js]
features: [Intl.DateTimeFormat-quarter]
---*/

taintProperties(["quarter"]);

var locale = new Intl.DateTimeFormat(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale;
assert(isCanonicalizedStructurallyValidLanguageTag(locale), "DateTimeFormat returns invalid locale " + locale + ".");