Skip to content

Commit

Permalink
Tests for multiple calendar annotations with at least one critical
Browse files Browse the repository at this point in the history
As per IETF review, an IXDTF string (ISO 8601 with annotations) is no
longer valid if it contains more than one u-ca annotation and at least one
of the annotations is marked critical.

Removes tests where such a string was assumed to be valid, and adds new
ones with a few variations on invalid strings.
  • Loading branch information
ptomato committed May 24, 2023
1 parent 88a2f0d commit 3e858ef
Show file tree
Hide file tree
Showing 128 changed files with 1,835 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.dateadd
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.dateAdd(arg, new Temporal.Duration()),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.dateuntil
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)),
`reject more than one calendar annotation if any critical: ${arg} (first argument)`
);
assert.throws(
RangeError,
() => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg),
`reject more than one calendar annotation if any critical: ${arg} (second argument)`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.day
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.day(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.dayofweek
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.dayOfWeek(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.dayofyear
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.dayOfYear(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.daysinmonth
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.daysInMonth(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.daysinweek
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.daysInWeek(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.daysinyear
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.daysInYear(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.inleapyear
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.inLeapYear(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.month
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/

const invalidStrings = [
"1970-01-01[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.month(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tests = [
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"],
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"],
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"],
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"],
];

const instance = new Temporal.Calendar("iso8601");
Expand Down
Loading

0 comments on commit 3e858ef

Please sign in to comment.