mirror of https://github.com/tc39/test262.git
Add tests for T time designator prefix not allowing space
Here's a test I should have included in #3395. It's allowed to replace the "T" in the middle of an ISO string with a space, but not when the "T" is a time designator prefix. This assertion ensures that implementations make this distinction correctly.
This commit is contained in:
parent
131c396b6a
commit
f7fb969cc4
|
@ -27,6 +27,13 @@ ambiguousStrings.forEach((string) => {
|
||||||
// The same string with a T prefix should not throw:
|
// The same string with a T prefix should not throw:
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
instance.toPlainDateTime(arg);
|
instance.toPlainDateTime(arg);
|
||||||
|
|
||||||
|
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:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
|
@ -27,6 +27,13 @@ ambiguousStrings.forEach((string) => {
|
||||||
// The same string with a T prefix should not throw:
|
// The same string with a T prefix should not throw:
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" });
|
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'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
|
@ -27,6 +27,13 @@ ambiguousStrings.forEach((string) => {
|
||||||
// The same string with a T prefix should not throw:
|
// The same string with a T prefix should not throw:
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
instance.withPlainTime(arg);
|
instance.withPlainTime(arg);
|
||||||
|
|
||||||
|
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:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
|
@ -33,6 +33,18 @@ ambiguousStrings.forEach((string) => {
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
Temporal.PlainTime.compare(arg, midnight);
|
Temporal.PlainTime.compare(arg, midnight);
|
||||||
Temporal.PlainTime.compare(midnight, arg);
|
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)'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
|
@ -25,6 +25,13 @@ ambiguousStrings.forEach((string) => {
|
||||||
// The same string with a T prefix should not throw:
|
// The same string with a T prefix should not throw:
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
Temporal.PlainTime.from(arg);
|
Temporal.PlainTime.from(arg);
|
||||||
|
|
||||||
|
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:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
|
@ -27,6 +27,13 @@ ambiguousStrings.forEach((string) => {
|
||||||
// The same string with a T prefix should not throw:
|
// The same string with a T prefix should not throw:
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
instance.equals(arg);
|
instance.equals(arg);
|
||||||
|
|
||||||
|
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:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
|
@ -27,6 +27,13 @@ ambiguousStrings.forEach((string) => {
|
||||||
// The same string with a T prefix should not throw:
|
// The same string with a T prefix should not throw:
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
instance.since(arg);
|
instance.since(arg);
|
||||||
|
|
||||||
|
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:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
|
@ -27,6 +27,13 @@ ambiguousStrings.forEach((string) => {
|
||||||
// The same string with a T prefix should not throw:
|
// The same string with a T prefix should not throw:
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
instance.until(arg);
|
instance.until(arg);
|
||||||
|
|
||||||
|
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:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
|
@ -27,6 +27,13 @@ ambiguousStrings.forEach((string) => {
|
||||||
// The same string with a T prefix should not throw:
|
// The same string with a T prefix should not throw:
|
||||||
arg = `T${string}`;
|
arg = `T${string}`;
|
||||||
instance.withPlainTime(arg);
|
instance.withPlainTime(arg);
|
||||||
|
|
||||||
|
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:
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
||||||
|
|
Loading…
Reference in New Issue