test262/test/built-ins/Temporal/PlainDateTime/from/argument-string-calendar-annotation.js
Philip Chimento 9d87845bb0 Temporal: Add tests for calendar annotation with critical flag
See https://github.com/tc39/proposal-temporal/pull/2397
Adds tests for ISO strings with calendar annotations, with and without the
critical flag, and also a check that the second calendar annotation is
disregarded, as per the IETF draft.
2022-10-11 12:19:49 +02:00

29 lines
999 B
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.plaindatetime.from
description: Various forms of calendar annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1976-11-18T15:23[u-ca=iso8601]", "without time zone"],
["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"],
["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["1976-11-18T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainDateTime.from(arg);
TemporalHelpers.assertPlainDateTime(
result,
1976, 11, "M11", 18, 15, 23, 0, 0, 0, 0,
`calendar annotation (${description})`
);
});