mirror of https://github.com/tc39/test262.git
Temporal: Improve various assertion messages
Some of these were overlooked in a recent big refactor.
This commit is contained in:
parent
1a0b9d23f2
commit
ce92940645
|
@ -22,6 +22,6 @@ for (const relativeTo of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }),
|
||||
`Number ${relativeTo} does not convert to a valid ISO string for relativeTo`
|
||||
`A number (${relativeTo}) is not a valid ISO string for relativeTo`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@ for (const calendar of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }),
|
||||
"A number is not a valid ISO string for relativeTo.calendar"
|
||||
`A number (${calendar}) is not a valid ISO string for relativeTo.calendar`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ assert.throws(RangeError, () =>
|
|||
// Adding day to day sets largestUnit to 'day', avoids having any week/month/year components in differences
|
||||
dayDuration.add(dayDuration, {
|
||||
relativeTo: zdt,
|
||||
})
|
||||
}),
|
||||
"days < 0 and sign = 1"
|
||||
);
|
||||
|
||||
// NanosecondsToDays.20: days > 0 and sign = -1
|
||||
|
@ -87,7 +88,8 @@ assert.throws(RangeError, () =>
|
|||
// Adding day to day sets largestUnit to 'day', avoids having any week/month/year components in differences
|
||||
dayDuration.add(dayDuration, {
|
||||
relativeTo: zdt,
|
||||
})
|
||||
}),
|
||||
"days > 0 and sign = -1"
|
||||
);
|
||||
|
||||
// NanosecondsToDays.22: nanoseconds > 0 and sign = -1
|
||||
|
@ -115,5 +117,6 @@ assert.throws(RangeError, () =>
|
|||
// Adding day to day sets largestUnit to 'day', avoids having any week/month/year components in differences
|
||||
dayDuration.add(dayDuration, {
|
||||
relativeTo: zdt,
|
||||
})
|
||||
}),
|
||||
"nanoseconds > 0 and sign = -1"
|
||||
);
|
||||
|
|
|
@ -22,6 +22,6 @@ for (const relativeTo of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.round({ largestUnit: "years", relativeTo }),
|
||||
`Number ${relativeTo} does not convert to a valid ISO string for relativeTo`
|
||||
`A number (${relativeTo}) is not a valid ISO string for relativeTo`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@ for (const calendar of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.round({ largestUnit: "years", relativeTo }),
|
||||
"A number is not a valid ISO string for relativeTo.calendar"
|
||||
`A number (${calendar}) is not a valid ISO string for relativeTo.calendar`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@ for (const relativeTo of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }),
|
||||
`Number ${relativeTo} does not convert to a valid ISO string for relativeTo`
|
||||
`A number (${relativeTo}) is not a valid ISO string for relativeTo`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ for (const calendar of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }),
|
||||
"A number is not a valid ISO string for relativeTo.calendar"
|
||||
`A number (${calendar}) is not a valid ISO string for relativeTo.calendar`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@ for (const relativeTo of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.total({ unit: "days", relativeTo }),
|
||||
`Number ${relativeTo} does not convert to a valid ISO string for relativeTo`
|
||||
`A number (${relativeTo}) is not a valid ISO string for relativeTo`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@ for (const calendar of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.total({ unit: "days", relativeTo }),
|
||||
"A number is not a valid ISO string for relativeTo.calendar"
|
||||
`A number (${calendar}) is not a valid ISO string for relativeTo.calendar`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.toPlainDateTime(arg),
|
||||
"A number is not a valid ISO string for PlainTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }),
|
||||
"A number is not a valid ISO string for PlainTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)),
|
||||
"A number is not a valid ISO string for PlainDateTime (first argument)"
|
||||
`A number (${arg}) is not a valid ISO string for PlainDateTime (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg),
|
||||
"A number is not a valid ISO string for PlainDateTime (second argument)"
|
||||
`A number (${arg}) is not a valid ISO string for PlainDateTime (second argument)`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainDateTime.from(arg),
|
||||
"A number is not a valid ISO string for PlainDateTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainDateTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.equals(arg),
|
||||
"A number is not a valid ISO string for PlainDateTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainDateTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.since(arg),
|
||||
"A number is not a valid ISO string for PlainDateTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainDateTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.until(arg),
|
||||
"A number is not a valid ISO string for PlainDateTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainDateTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.withPlainTime(arg),
|
||||
"A number is not a valid ISO string for PlainTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainMonthDay.from(arg),
|
||||
"A number is not a valid ISO string for PlainMonthDay"
|
||||
`A number (${arg}) is not a valid ISO string for PlainMonthDay`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.equals(arg),
|
||||
"A number is not a valid ISO string for PlainMonthDay"
|
||||
`A number (${arg}) is not a valid ISO string for PlainMonthDay`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainTime.compare(arg, new Temporal.PlainTime(12, 34, 56, 987, 654, 321)),
|
||||
"A number is not a valid ISO string for PlainTime (first argument)"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainTime.compare(new Temporal.PlainTime(12, 34, 56, 987, 654, 321), arg),
|
||||
"A number is not a valid ISO string for PlainTime (second argument)"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime (second argument)`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainTime.from(arg),
|
||||
"A number is not a valid ISO string for PlainTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.equals(arg),
|
||||
"A number is not a valid ISO string for PlainTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.since(arg),
|
||||
"A number is not a valid ISO string for PlainTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.until(arg),
|
||||
"A number is not a valid ISO string for PlainTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)),
|
||||
"A number is not a valid ISO string for PlainYearMonth (first argument)"
|
||||
`A number (${arg}) is not a valid ISO string for PlainYearMonth (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg),
|
||||
"A number is not a valid ISO string for PlainYearMonth (first argument)"
|
||||
`A number (${arg}) is not a valid ISO string for PlainYearMonth (first argument)`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => Temporal.PlainYearMonth.from(arg),
|
||||
"A number is not a valid ISO string for PlainYearMonth"
|
||||
`A number (${arg}) is not a valid ISO string for PlainYearMonth`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.equals(arg),
|
||||
"A number is not a valid ISO string for PlainYearMonth"
|
||||
`A number (${arg}) is not a valid ISO string for PlainYearMonth`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.since(arg),
|
||||
"A number is not a valid ISO string for PlainYearMonth"
|
||||
`A number (${arg}) is not a valid ISO string for PlainYearMonth`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.until(arg),
|
||||
"A number is not a valid ISO string for PlainYearMonth"
|
||||
`A number (${arg}) is not a valid ISO string for PlainYearMonth`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.getInstantFor(arg),
|
||||
"A number is not a valid ISO string for PlainDateTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainDateTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.getPossibleInstantsFor(arg),
|
||||
"A number is not a valid ISO string for PlainDateTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainDateTime`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ features: [Temporal]
|
|||
let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]";
|
||||
|
||||
const result = Temporal.ZonedDateTime.from(str);
|
||||
assert.sameValue(result.timeZoneId, "+01:35", "Time zone determined from bracket name");
|
||||
assert.sameValue(result.timeZoneId, "+01:35", "ISO offset, sub-minute offset trailing-zeroes");
|
||||
|
||||
str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35:00.000000000]";
|
||||
assert.throws(
|
||||
|
|
|
@ -12,7 +12,7 @@ const instance = new Temporal.ZonedDateTime(0n, timeZone);
|
|||
let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]";
|
||||
|
||||
const result = instance.equals(str);
|
||||
assert.sameValue(result, false, "Time zone determined from bracket name");
|
||||
assert.sameValue(result, false, "ISO offset, sub-minute offset trailing-zeroes");
|
||||
|
||||
str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35:00.000000000]";
|
||||
assert.throws(
|
||||
|
|
|
@ -20,6 +20,6 @@ for (const arg of numbers) {
|
|||
assert.throws(
|
||||
TypeError,
|
||||
() => instance.withPlainTime(arg),
|
||||
"A number is not a valid ISO string for PlainTime"
|
||||
`A number (${arg}) is not a valid ISO string for PlainTime`
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue