Temporal: Deduplicate strings-with-calendar from strings-without-calendar

The strings with calendar annotations in these tests don't need to be
listed separately, they can be derived from the original strings.
This commit is contained in:
Philip Chimento 2022-08-17 12:34:48 -07:00 committed by Philip Chimento
parent 409d6dc71a
commit ddef61a106
9 changed files with 191 additions and 227 deletions

View File

@ -16,16 +16,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -42,6 +37,7 @@ ambiguousStrings.forEach((string) => {
() => instance.toPlainDateTime(arg),
"space is not accepted as a substitute for T prefix"
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings:

View File

@ -16,16 +16,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -42,6 +37,7 @@ ambiguousStrings.forEach((string) => {
() => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }),
"space is not accepted as a substitute for T prefix"
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings:

View File

@ -16,16 +16,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -42,6 +37,7 @@ ambiguousStrings.forEach((string) => {
() => instance.withPlainTime(arg),
"space is not accepted as a substitute for T prefix"
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings:

View File

@ -16,16 +16,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -53,6 +48,7 @@ ambiguousStrings.forEach((string) => {
() => Temporal.PlainTime.compare(midnight, arg),
'space is not accepted as a substitute for T prefix (second argument)'
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings:

View File

@ -14,16 +14,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -40,6 +35,7 @@ ambiguousStrings.forEach((string) => {
() => Temporal.PlainTime.from(arg),
"space is not accepted as a substitute for T prefix"
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings:

View File

@ -16,16 +16,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -42,6 +37,7 @@ ambiguousStrings.forEach((string) => {
() => instance.equals(arg),
"space is not accepted as a substitute for T prefix"
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings:

View File

@ -16,16 +16,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -42,6 +37,7 @@ ambiguousStrings.forEach((string) => {
() => instance.since(arg),
"space is not accepted as a substitute for T prefix"
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings:

View File

@ -16,16 +16,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -42,6 +37,7 @@ ambiguousStrings.forEach((string) => {
() => instance.until(arg),
"space is not accepted as a substitute for T prefix"
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings:

View File

@ -16,16 +16,11 @@ const ambiguousStrings = [
"1130", // ditto, including DD that doesn't occur in every month
"12-14", // ambiguity between MM-DD and HH-UU
"202112", // ambiguity between YYYYMM and HHMMSS
// same strings as above but with a calendar annotation, which must not cause
// disambiguation in favour of time
"2021-12[u-ca=iso8601]",
"1214[u-ca=iso8601]",
"0229[u-ca=iso8601]",
"1130[u-ca=iso8601]",
"12-14[u-ca=iso8601]",
"202112[u-ca=iso8601]",
];
ambiguousStrings.forEach((string) => {
ambiguousStrings.forEach((stringWithoutCalendar) => {
// calendar annotation must not cause disambiguation in favour of time
const stringWithCalendar = stringWithoutCalendar + '[u-ca=iso8601]';
[stringWithoutCalendar, stringWithCalendar].forEach((string) => {
let arg = string;
assert.throws(
RangeError,
@ -42,6 +37,7 @@ ambiguousStrings.forEach((string) => {
() => instance.withPlainTime(arg),
"space is not accepted as a substitute for T prefix"
);
});
});
// None of these should throw without a T prefix, because they are unambiguously time strings: