mirror of
https://github.com/tc39/test262.git
synced 2025-11-17 12:19:49 +01:00
Edits Temporal tests to account for changes in https://github.com/tc39/proposal-temporal/pull/2574. This PR stops coercing non-string primitive inputs to strings in Temporal methods, to avoid cases where numbers are coerced to syntactically valid but often unexpected string results.
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
esid: sec-temporal.zoneddatetime.from
|
|
description: Property bag with offset property is rejected if offset is in the wrong format
|
|
features: [Temporal]
|
|
---*/
|
|
|
|
const timeZone = new Temporal.TimeZone("UTC");
|
|
|
|
const offsetOptions = ['use', 'prefer', 'ignore', 'reject'];
|
|
|
|
const badOffsets = [
|
|
"00:00", // missing sign
|
|
"+0", // too short
|
|
"-000:00", // too long
|
|
0, // must be a string
|
|
null, // must be a string
|
|
true, // must be a string
|
|
1000n, // must be a string
|
|
];
|
|
offsetOptions.forEach((offsetOption) => {
|
|
badOffsets.forEach((offset) => {
|
|
const arg = { year: 2021, month: 10, day: 28, offset, timeZone };
|
|
assert.throws(
|
|
typeof(offset) === 'string' ? RangeError : TypeError,
|
|
() => Temporal.ZonedDateTime.from(arg, { offset: offsetOption }),
|
|
`"${offset} is not a valid offset string (with offset option ${offsetOption})`
|
|
);
|
|
});
|
|
});
|