mirror of https://github.com/tc39/test262.git
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:
parent
409d6dc71a
commit
ddef61a106
|
@ -16,32 +16,28 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.toPlainDateTime(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.toPlainDateTime(arg);
|
||||
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,
|
||||
() => instance.toPlainDateTime(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.toPlainDateTime(arg);
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.toPlainDateTime(arg),
|
||||
"space is not accepted as a substitute for T prefix"
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
|
@ -16,32 +16,28 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" });
|
||||
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,
|
||||
() => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" });
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }),
|
||||
"space is not accepted as a substitute for T prefix"
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
|
@ -16,32 +16,28 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.withPlainTime(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.withPlainTime(arg);
|
||||
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,
|
||||
() => instance.withPlainTime(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.withPlainTime(arg);
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.withPlainTime(arg),
|
||||
"space is not accepted as a substitute for T prefix"
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
|
@ -16,43 +16,39 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainTime.compare(arg, midnight),
|
||||
`${string} is ambiguous and requires T prefix (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainTime.compare(midnight, arg),
|
||||
`${string} is ambiguous and requires T prefix (second argument)`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
Temporal.PlainTime.compare(arg, midnight);
|
||||
Temporal.PlainTime.compare(midnight, arg);
|
||||
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,
|
||||
() => Temporal.PlainTime.compare(arg, midnight),
|
||||
`${string} is ambiguous and requires T prefix (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainTime.compare(midnight, arg),
|
||||
`${string} is ambiguous and requires T prefix (second argument)`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
Temporal.PlainTime.compare(arg, midnight);
|
||||
Temporal.PlainTime.compare(midnight, arg);
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainTime.compare(arg, midnight),
|
||||
'space is not accepted as a substitute for T prefix (first argument)'
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainTime.compare(midnight, arg),
|
||||
'space is not accepted as a substitute for T prefix (second argument)'
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainTime.compare(arg, midnight),
|
||||
'space is not accepted as a substitute for T prefix (first argument)'
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
|
@ -14,32 +14,28 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainTime.from(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
Temporal.PlainTime.from(arg);
|
||||
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,
|
||||
() => Temporal.PlainTime.from(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
Temporal.PlainTime.from(arg);
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainTime.from(arg),
|
||||
"space is not accepted as a substitute for T prefix"
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
|
@ -16,32 +16,28 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.equals(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.equals(arg);
|
||||
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,
|
||||
() => instance.equals(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.equals(arg);
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.equals(arg),
|
||||
"space is not accepted as a substitute for T prefix"
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
|
@ -16,32 +16,28 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.since(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.since(arg);
|
||||
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,
|
||||
() => instance.since(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.since(arg);
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.since(arg),
|
||||
"space is not accepted as a substitute for T prefix"
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
|
@ -16,32 +16,28 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.until(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.until(arg);
|
||||
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,
|
||||
() => instance.until(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.until(arg);
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.until(arg),
|
||||
"space is not accepted as a substitute for T prefix"
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
|
@ -16,32 +16,28 @@ 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) => {
|
||||
let arg = string;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.withPlainTime(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.withPlainTime(arg);
|
||||
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,
|
||||
() => instance.withPlainTime(arg),
|
||||
`${string} is ambiguous and requires T prefix`
|
||||
);
|
||||
// The same string with a T prefix should not throw:
|
||||
arg = `T${string}`;
|
||||
instance.withPlainTime(arg);
|
||||
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.withPlainTime(arg),
|
||||
"space is not accepted as a substitute for T prefix"
|
||||
);
|
||||
arg = ` ${string}`;
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => 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:
|
||||
|
|
Loading…
Reference in New Issue