Expect precise result for negative fractional units

Fixes #3544
This commit is contained in:
André Bargull 2022-06-01 16:45:30 +02:00 committed by Ms2ger
parent c61a04fd88
commit b2f7dc1194
12 changed files with 24 additions and 24 deletions

View File

@ -7,13 +7,13 @@ description: Strings with fractional duration units are treated with the correct
features: [Temporal]
---*/
const expectedHours = new Temporal.Duration(0, 0, 0, 0, -24, -34, -4, -404, -442, -799);
const expectedHours = new Temporal.Duration(0, 0, 0, 0, -24, -34, -4, -404, -442, -800);
const resultHours1 = Temporal.Duration.compare("-PT24.567890123H", expectedHours);
assert.sameValue(resultHours1, 0, "negative fractional hours (first argument)");
const resultHours2 = Temporal.Duration.compare(expectedHours, "-PT24.567890123H");
assert.sameValue(resultHours2, 0, "negative fractional hours (second argument)");
const expectedMinutes = new Temporal.Duration(0, 0, 0, 0, 0, -1440, -34, -73, -407, -379);
const expectedMinutes = new Temporal.Duration(0, 0, 0, 0, 0, -1440, -34, -73, -407, -380);
const resultMinutes1 = Temporal.Duration.compare("-PT1440.567890123M", expectedMinutes);
assert.sameValue(resultMinutes1, 0, "negative fractional minutes (first argument)");
const resultMinutes2 = Temporal.Duration.compare("-PT1440.567890123M", expectedMinutes);

View File

@ -9,7 +9,7 @@ features: [Temporal]
---*/
const resultHours = Temporal.Duration.from("-PT24.567890123H");
TemporalHelpers.assertDuration(resultHours, 0, 0, 0, 0, -24, -34, -4, -404, -442, -799, "negative fractional hours");
TemporalHelpers.assertDuration(resultHours, 0, 0, 0, 0, -24, -34, -4, -404, -442, -800, "negative fractional hours");
const resultMinutes = Temporal.Duration.from("-PT1440.567890123M");
TemporalHelpers.assertDuration(resultMinutes, 0, 0, 0, 0, 0, -1440, -34, -73, -407, -379, "negative fractional minutes");
TemporalHelpers.assertDuration(resultMinutes, 0, 0, 0, 0, 0, -1440, -34, -73, -407, -380, "negative fractional minutes");

View File

@ -11,7 +11,7 @@ features: [Temporal]
const instance = new Temporal.Duration();
const resultHours = instance.add("-PT24.567890123H");
TemporalHelpers.assertDuration(resultHours, 0, 0, 0, 0, -24, -34, -4, -404, -442, -799, "negative fractional hours");
TemporalHelpers.assertDuration(resultHours, 0, 0, 0, 0, -24, -34, -4, -404, -442, -800, "negative fractional hours");
const resultMinutes = instance.add("-PT1440.567890123M");
TemporalHelpers.assertDuration(resultMinutes, 0, 0, 0, 0, 0, -1440, -34, -73, -407, -379, "negative fractional minutes");
TemporalHelpers.assertDuration(resultMinutes, 0, 0, 0, 0, 0, -1440, -34, -73, -407, -380, "negative fractional minutes");

View File

@ -11,7 +11,7 @@ features: [Temporal]
const instance = new Temporal.Duration();
const resultHours = instance.subtract("-PT24.567890123H");
TemporalHelpers.assertDuration(resultHours, 0, 0, 0, 0, 24, 34, 4, 404, 442, 799, "negative fractional hours");
TemporalHelpers.assertDuration(resultHours, 0, 0, 0, 0, 24, 34, 4, 404, 442, 800, "negative fractional hours");
const resultMinutes = instance.subtract("-PT1440.567890123M");
TemporalHelpers.assertDuration(resultMinutes, 0, 0, 0, 0, 0, 1440, 34, 73, 407, 379, "negative fractional minutes");
TemporalHelpers.assertDuration(resultMinutes, 0, 0, 0, 0, 0, 1440, 34, 73, 407, 380, "negative fractional minutes");

View File

@ -10,7 +10,7 @@ features: [Temporal]
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
const resultHours = instance.add("-PT24.567890123H");
assert.sameValue(resultHours.epochNanoseconds, 999_911_555_595_557_201n, "negative fractional hours");
assert.sameValue(resultHours.epochNanoseconds, 999_911_555_595_557_200n, "negative fractional hours");
const resultMinutes = instance.add("-PT1440.567890123M");
assert.sameValue(resultMinutes.epochNanoseconds, 999_913_565_926_592_621n, "negative fractional minutes");
assert.sameValue(resultMinutes.epochNanoseconds, 999_913_565_926_592_620n, "negative fractional minutes");

View File

@ -10,7 +10,7 @@ features: [Temporal]
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
const resultHours = instance.subtract("-PT24.567890123H");
assert.sameValue(resultHours.epochNanoseconds, 1_000_088_444_404_442_799n, "negative fractional hours");
assert.sameValue(resultHours.epochNanoseconds, 1_000_088_444_404_442_800n, "negative fractional hours");
const resultMinutes = instance.subtract("-PT1440.567890123M");
assert.sameValue(resultMinutes.epochNanoseconds, 1_000_086_434_073_407_379n, "negative fractional minutes");
assert.sameValue(resultMinutes.epochNanoseconds, 1_000_086_434_073_407_380n, "negative fractional minutes");

View File

@ -11,7 +11,7 @@ features: [Temporal]
const instance = new Temporal.PlainDateTime(2000, 5, 2);
const resultHours = instance.add("-PT24.567890123H");
TemporalHelpers.assertPlainDateTime(resultHours, 2000, 4, "M04", 30, 23, 25, 55, 595, 557, 201, "negative fractional hours");
TemporalHelpers.assertPlainDateTime(resultHours, 2000, 4, "M04", 30, 23, 25, 55, 595, 557, 200, "negative fractional hours");
const resultMinutes = instance.add("-PT1440.567890123M");
TemporalHelpers.assertPlainDateTime(resultMinutes, 2000, 4, "M04", 30, 23, 59, 25, 926, 592, 621, "negative fractional minutes");
TemporalHelpers.assertPlainDateTime(resultMinutes, 2000, 4, "M04", 30, 23, 59, 25, 926, 592, 620, "negative fractional minutes");

View File

@ -11,7 +11,7 @@ features: [Temporal]
const instance = new Temporal.PlainDateTime(2000, 5, 2);
const resultHours = instance.subtract("-PT24.567890123H");
TemporalHelpers.assertPlainDateTime(resultHours, 2000, 5, "M05", 3, 0, 34, 4, 404, 442, 799, "negative fractional hours");
TemporalHelpers.assertPlainDateTime(resultHours, 2000, 5, "M05", 3, 0, 34, 4, 404, 442, 800, "negative fractional hours");
const resultMinutes = instance.subtract("-PT1440.567890123M");
TemporalHelpers.assertPlainDateTime(resultMinutes, 2000, 5, "M05", 3, 0, 0, 34, 73, 407, 379, "negative fractional minutes");
TemporalHelpers.assertPlainDateTime(resultMinutes, 2000, 5, "M05", 3, 0, 0, 34, 73, 407, 380, "negative fractional minutes");

View File

@ -11,7 +11,7 @@ features: [Temporal]
const instance = new Temporal.PlainTime();
const resultHours = instance.add("-PT24.567890123H");
TemporalHelpers.assertPlainTime(resultHours, 23, 25, 55, 595, 557, 201, "negative fractional hours");
TemporalHelpers.assertPlainTime(resultHours, 23, 25, 55, 595, 557, 200, "negative fractional hours");
const resultMinutes = instance.add("-PT1440.567890123M");
TemporalHelpers.assertPlainTime(resultMinutes, 23, 59, 25, 926, 592, 621, "negative fractional minutes");
TemporalHelpers.assertPlainTime(resultMinutes, 23, 59, 25, 926, 592, 620, "negative fractional minutes");

View File

@ -11,7 +11,7 @@ features: [Temporal]
const instance = new Temporal.PlainTime();
const resultHours = instance.subtract("-PT24.567890123H");
TemporalHelpers.assertPlainTime(resultHours, 0, 34, 4, 404, 442, 799, "negative fractional hours");
TemporalHelpers.assertPlainTime(resultHours, 0, 34, 4, 404, 442, 800, "negative fractional hours");
const resultMinutes = instance.subtract("-PT1440.567890123M");
TemporalHelpers.assertPlainTime(resultMinutes, 0, 0, 34, 73, 407, 379, "negative fractional minutes");
TemporalHelpers.assertPlainTime(resultMinutes, 0, 0, 34, 73, 407, 380, "negative fractional minutes");

View File

@ -10,7 +10,7 @@ features: [Temporal]
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
const resultHours = instance.add("-PT24.567890123H");
assert.sameValue(resultHours.epochNanoseconds, 999_911_555_595_557_201n, "negative fractional hours");
assert.sameValue(resultHours.epochNanoseconds, 999_911_555_595_557_200n, "negative fractional hours");
const resultMinutes = instance.add("-PT1440.567890123M");
assert.sameValue(resultMinutes.epochNanoseconds, 999_913_565_926_592_621n, "negative fractional minutes");
assert.sameValue(resultMinutes.epochNanoseconds, 999_913_565_926_592_620n, "negative fractional minutes");

View File

@ -10,7 +10,7 @@ features: [Temporal]
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
const resultHours = instance.subtract("-PT24.567890123H");
assert.sameValue(resultHours.epochNanoseconds, 1_000_088_444_404_442_799n, "negative fractional hours");
assert.sameValue(resultHours.epochNanoseconds, 1_000_088_444_404_442_800n, "negative fractional hours");
const resultMinutes = instance.subtract("-PT1440.567890123M");
assert.sameValue(resultMinutes.epochNanoseconds, 1_000_086_434_073_407_379n, "negative fractional minutes");
assert.sameValue(resultMinutes.epochNanoseconds, 1_000_086_434_073_407_380n, "negative fractional minutes");