Port tests for PlainTime.

This commit is contained in:
Ms2ger 2022-02-16 15:57:55 +01:00 committed by Rick Waldron
parent 18ce639a4c
commit 2f592de0aa
32 changed files with 1181 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.from
description: Number argument is converted to string
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const result = Temporal.PlainTime.from(1523);
TemporalHelpers.assertPlainTime(result, 15, 23, 0, 0, 0, 0);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.from
description: Object argument handles leap seconds according to the overflow option.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
for (const options of [undefined, {}, { overflow: "constrain" }]) {
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 23, minute: 59, second: 60 }, options),
23, 59, 59, 0, 0, 0);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 12, minute: 30, second: 60 }, options),
12, 30, 59, 0, 0, 0);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 23, minute: 59, second: 60, millisecond: 170 }, options),
23, 59, 59, 170, 0, 0);
}
const options = { overflow: "reject" };
assert.throws(RangeError, () => Temporal.PlainTime.from({ hour: 23, minute: 59, second: 60 }, options));
assert.throws(RangeError, () => Temporal.PlainTime.from({ hour: 12, minute: 30, second: 60 }, options));
assert.throws(RangeError, () => Temporal.PlainTime.from({ hour: 23, minute: 59, second: 60, millisecond: 170 }, options));

View File

@ -0,0 +1,21 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.from
description: Plain object argument is supported and ignores plural properties
includes: [temporalHelpers.js]
features: [Temporal]
---*/
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 15, minute: 23 }),
15, 23, 0, 0, 0, 0);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ minute: 30, microsecond: 555 }),
0, 30, 0, 0, 555, 0);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ year: 2019, month: 10, day: 1, hour: 14, minute: 20, second: 36 }),
14, 20, 36, 0, 0, 0);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hours: 2, minute: 30, microsecond: 555 }),
0, 30, 0, 0, 555, 0);
assert.throws(TypeError, () => Temporal.PlainTime.from({}));
assert.throws(TypeError, () => Temporal.PlainTime.from({ minutes: 12 }));

View File

@ -0,0 +1,18 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.from
description: Leap second is replaced by :59 in ISO strings.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
for (const options of [undefined, {}, { overflow: "constrain" }, { overflow: "reject" }]) {
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("23:59:60", options),
23, 59, 59, 0, 0, 0);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("12:30:60", options),
12, 30, 59, 0, 0, 0);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("23:59:60.170", options),
23, 59, 59, 170, 0, 0);
}

View File

@ -0,0 +1,14 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.from
description: constrain value for overflow option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 26 }, { overflow: "constrain" }),
23, 0, 0, 0, 0, 0);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 22 }, { overflow: "constrain" }),
22, 0, 0, 0, 0, 0);

View File

@ -0,0 +1,13 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.from
description: reject value for overflow option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
assert.throws(RangeError, () => Temporal.PlainTime.from({ hour: 26 }, { overflow: "reject" }));
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 22 }, { overflow: "reject" }),
22, 0, 0, 0, 0, 0);

View File

@ -0,0 +1,12 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime
description: Negative zero arguments are treated as zero.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(-0, -0, -0, -0, -0, -0);
TemporalHelpers.assertPlainTime(plainTime, 0, 0, 0, 0, 0, 0);

View File

@ -0,0 +1,14 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.add
description: Duration arguments are supported.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(15, 23, 30, 123, 456, 789);
const duration = Temporal.Duration.from("PT16H");
TemporalHelpers.assertPlainTime(plainTime.add(duration),
7, 23, 30, 123, 456, 789);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.add
description: Higher units are ignored.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(15, 23, 30, 123, 456, 789);
const values = [
new Temporal.Duration(0, 0, 0, 1),
new Temporal.Duration(0, 0, 1),
new Temporal.Duration(0, 1),
new Temporal.Duration(1),
{ days: 1 },
{ weeks: 1 },
{ months: 1 },
{ years: 1 },
"P1D",
"P1W",
"P1M",
"P1Y",
];
for (const value of values) {
TemporalHelpers.assertPlainTime(plainTime.add(value),
15, 23, 30, 123, 456, 789);
}

View File

@ -0,0 +1,37 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.add
description: Plain object arguments are supported.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.add({ hours: 16 }),
7, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.add({ minutes: 45 }),
16, 8, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.add({ seconds: 800 }),
15, 36, 50, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.add({ milliseconds: 800 }),
15, 23, 30, 923, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.add({ microseconds: 800 }),
15, 23, 30, 124, 256, 789);
TemporalHelpers.assertPlainTime(plainTime.add({ nanoseconds: 300 }),
15, 23, 30, 123, 457, 89);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("07:23:30.123456789").add({ hours: -16 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("16:08:30.123456789").add({ minutes: -45 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("15:36:50.123456789").add({ seconds: -800 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("15:23:30.923456789").add({ milliseconds: -800 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("15:23:30.124256789").add({ microseconds: -800 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("15:23:30.123457089").add({ nanoseconds: -300 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.add({ minute: 1, hours: 1 }),
16, 23, 30, 123, 456, 789);

View File

@ -0,0 +1,14 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.round
description: Rounding can cross midnight
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = Temporal.PlainTime.from("23:59:59.999999999");
for (const smallestUnit of ["hour", "minute", "second", "millisecond", "microsecond"]) {
TemporalHelpers.assertPlainTime(plainTime.round({ smallestUnit }), 0, 0, 0, 0, 0, 0);
}

View File

@ -0,0 +1,33 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.round
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(3, 34, 56, 987, 654, 321);
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "hours", roundingIncrement: 1 }),
4, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "hours", roundingIncrement: 2 }),
4, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "hours", roundingIncrement: 3 }),
3, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "hours", roundingIncrement: 4 }),
4, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "hours", roundingIncrement: 6 }),
6, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "hours", roundingIncrement: 8 }),
0, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "hours", roundingIncrement: 12 }),
0, 0, 0, 0, 0, 0, "hours");

View File

@ -0,0 +1,57 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.round
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(3, 34, 56, 987, 654, 321);
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 1 }),
3, 34, 56, 987, 654, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 2 }),
3, 34, 56, 987, 654, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 4 }),
3, 34, 56, 987, 656, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 5 }),
3, 34, 56, 987, 655, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 8 }),
3, 34, 56, 987, 656, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 10 }),
3, 34, 56, 987, 650, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 20 }),
3, 34, 56, 987, 660, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 25 }),
3, 34, 56, 987, 650, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 40 }),
3, 34, 56, 987, 640, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 50 }),
3, 34, 56, 987, 650, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 100 }),
3, 34, 56, 987, 700, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 125 }),
3, 34, 56, 987, 625, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 200 }),
3, 34, 56, 987, 600, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 250 }),
3, 34, 56, 987, 750, 0, "microseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 500 }),
3, 34, 56, 987, 500, 0, "microseconds");

View File

@ -0,0 +1,57 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.round
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(3, 34, 56, 987, 654, 321);
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 1 }),
3, 34, 56, 988, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 2 }),
3, 34, 56, 988, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 4 }),
3, 34, 56, 988, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 5 }),
3, 34, 56, 990, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 8 }),
3, 34, 56, 984, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 10 }),
3, 34, 56, 990, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 20 }),
3, 34, 56, 980, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 25 }),
3, 34, 57, 0, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 40 }),
3, 34, 57, 0, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 50 }),
3, 34, 57, 0, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 100 }),
3, 34, 57, 0, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 125 }),
3, 34, 57, 0, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 200 }),
3, 34, 57, 0, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 250 }),
3, 34, 57, 0, 0, 0, "milliseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 500 }),
3, 34, 57, 0, 0, 0, "milliseconds");

View File

@ -0,0 +1,45 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.round
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(3, 34, 56, 987, 654, 321);
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 1 }),
3, 35, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 2 }),
3, 34, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 3 }),
3, 36, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 4 }),
3, 36, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 5 }),
3, 35, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 6 }),
3, 36, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 10 }),
3, 30, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 12 }),
3, 36, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 15 }),
3, 30, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 20 }),
3, 40, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 30 }),
3, 30, 0, 0, 0, 0, "minutes");

View File

@ -0,0 +1,57 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.round
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(3, 34, 56, 987, 654, 321);
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 1 }),
3, 34, 56, 987, 654, 321, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 2 }),
3, 34, 56, 987, 654, 322, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 4 }),
3, 34, 56, 987, 654, 320, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 5 }),
3, 34, 56, 987, 654, 320, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 8 }),
3, 34, 56, 987, 654, 320, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 10 }),
3, 34, 56, 987, 654, 320, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 20 }),
3, 34, 56, 987, 654, 320, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 25 }),
3, 34, 56, 987, 654, 325, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 40 }),
3, 34, 56, 987, 654, 320, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 50 }),
3, 34, 56, 987, 654, 300, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 100 }),
3, 34, 56, 987, 654, 300, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 125 }),
3, 34, 56, 987, 654, 375, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 200 }),
3, 34, 56, 987, 654, 400, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 250 }),
3, 34, 56, 987, 654, 250, "nanoseconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 500 }),
3, 34, 56, 987, 654, 500, "nanoseconds");

View File

@ -0,0 +1,45 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.round
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(3, 34, 56, 987, 654, 321);
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 1 }),
3, 34, 57, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 2 }),
3, 34, 56, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 3 }),
3, 34, 57, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 4 }),
3, 34, 56, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 5 }),
3, 34, 55, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 6 }),
3, 34, 54, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 10 }),
3, 35, 0, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 12 }),
3, 35, 0, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 15 }),
3, 35, 0, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 20 }),
3, 35, 0, 0, 0, 0, "seconds");
TemporalHelpers.assertPlainTime(
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 30 }),
3, 35, 0, 0, 0, 0, "seconds");

View File

@ -0,0 +1,34 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.since
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "hours", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "hours", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "hours", roundingIncrement: 3 }),
0, 0, 0, 0, 9, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "hours", roundingIncrement: 4 }),
0, 0, 0, 0, 8, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "hours", roundingIncrement: 6 }),
0, 0, 0, 0, 6, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "hours", roundingIncrement: 8 }),
0, 0, 0, 0, 8, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "hours", roundingIncrement: 12 }),
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "hours");

View File

@ -0,0 +1,58 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.since
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 35, 23, 865, 196, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 23, 865, 195, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 8 }),
0, 0, 0, 0, 10, 35, 23, 865, 192, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 35, 23, 865, 190, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 35, 23, 865, 180, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 25 }),
0, 0, 0, 0, 10, 35, 23, 865, 175, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 40 }),
0, 0, 0, 0, 10, 35, 23, 865, 160, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 50 }),
0, 0, 0, 0, 10, 35, 23, 865, 150, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 100 }),
0, 0, 0, 0, 10, 35, 23, 865, 100, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 125 }),
0, 0, 0, 0, 10, 35, 23, 865, 125, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 200 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 250 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "microseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "microseconds", roundingIncrement: 500 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "microseconds");

View File

@ -0,0 +1,58 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.since
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 35, 23, 864, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 35, 23, 864, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 8 }),
0, 0, 0, 0, 10, 35, 23, 864, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 35, 23, 860, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 35, 23, 860, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 25 }),
0, 0, 0, 0, 10, 35, 23, 850, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 40 }),
0, 0, 0, 0, 10, 35, 23, 840, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 50 }),
0, 0, 0, 0, 10, 35, 23, 850, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 100 }),
0, 0, 0, 0, 10, 35, 23, 800, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 125 }),
0, 0, 0, 0, 10, 35, 23, 750, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 200 }),
0, 0, 0, 0, 10, 35, 23, 800, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 250 }),
0, 0, 0, 0, 10, 35, 23, 750, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "milliseconds", roundingIncrement: 500 }),
0, 0, 0, 0, 10, 35, 23, 500, 0, 0, "milliseconds");

View File

@ -0,0 +1,46 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.since
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 34, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 3 }),
0, 0, 0, 0, 10, 33, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 32, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 6 }),
0, 0, 0, 0, 10, 30, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 30, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 12 }),
0, 0, 0, 0, 10, 24, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 15 }),
0, 0, 0, 0, 10, 30, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 20, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "minutes", roundingIncrement: 30 }),
0, 0, 0, 0, 10, 30, 0, 0, 0, 0, "minutes");

View File

@ -0,0 +1,58 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.since
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 533, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 532, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 532, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 530, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 8 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 528, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 530, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 520, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 25 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 525, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 40 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 520, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 50 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 100 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 125 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 200 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 400, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 250 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "nanoseconds", roundingIncrement: 500 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");

View File

@ -0,0 +1,46 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.since
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 23, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 35, 22, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 3 }),
0, 0, 0, 0, 10, 35, 21, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 35, 20, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 20, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 6 }),
0, 0, 0, 0, 10, 35, 18, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 35, 20, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 12 }),
0, 0, 0, 0, 10, 35, 12, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 15 }),
0, 0, 0, 0, 10, 35, 15, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 35, 20, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
later.since(earlier, { smallestUnit: "seconds", roundingIncrement: 30 }),
0, 0, 0, 0, 10, 35, 0, 0, 0, 0, "seconds");

View File

@ -0,0 +1,14 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.subtract
description: Duration arguments are supported.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(15, 23, 30, 123, 456, 789);
const duration = Temporal.Duration.from("PT16H");
TemporalHelpers.assertPlainTime(plainTime.subtract(duration),
23, 23, 30, 123, 456, 789);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.subtract
description: Higher units are ignored.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(15, 23, 30, 123, 456, 789);
const values = [
new Temporal.Duration(0, 0, 0, 1),
new Temporal.Duration(0, 0, 1),
new Temporal.Duration(0, 1),
new Temporal.Duration(1),
{ days: 1 },
{ weeks: 1 },
{ months: 1 },
{ years: 1 },
"P1D",
"P1W",
"P1M",
"P1Y",
];
for (const value of values) {
TemporalHelpers.assertPlainTime(plainTime.subtract(value),
15, 23, 30, 123, 456, 789);
}

View File

@ -0,0 +1,37 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.subtract
description: Plain object arguments are supported.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.subtract({ hours: 16 }),
23, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.subtract({ minutes: 45 }),
14, 38, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.subtract({ seconds: 45 }),
15, 22, 45, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.subtract({ milliseconds: 800 }),
15, 23, 29, 323, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.subtract({ microseconds: 800 }),
15, 23, 30, 122, 656, 789);
TemporalHelpers.assertPlainTime(plainTime.subtract({ nanoseconds: 800 }),
15, 23, 30, 123, 455, 989);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("23:23:30.123456789").subtract({ hours: -16 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("14:38:30.123456789").subtract({ minutes: -45 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("15:22:45.123456789").subtract({ seconds: -45 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("15:23:29.323456789").subtract({ milliseconds: -800 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("15:23:30.122656789").subtract({ microseconds: -800 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(Temporal.PlainTime.from("15:23:30.123455989").subtract({ nanoseconds: -800 }),
15, 23, 30, 123, 456, 789);
TemporalHelpers.assertPlainTime(plainTime.subtract({ minute: 1, hours: 1 }),
14, 23, 30, 123, 456, 789);

View File

@ -0,0 +1,34 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.until
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "hours", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "hours", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "hours", roundingIncrement: 3 }),
0, 0, 0, 0, 9, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "hours", roundingIncrement: 4 }),
0, 0, 0, 0, 8, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "hours", roundingIncrement: 6 }),
0, 0, 0, 0, 6, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "hours", roundingIncrement: 8 }),
0, 0, 0, 0, 8, 0, 0, 0, 0, 0, "hours");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "hours", roundingIncrement: 12 }),
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "hours");

View File

@ -0,0 +1,58 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.until
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 35, 23, 865, 196, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 23, 865, 195, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 8 }),
0, 0, 0, 0, 10, 35, 23, 865, 192, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 35, 23, 865, 190, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 35, 23, 865, 180, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 25 }),
0, 0, 0, 0, 10, 35, 23, 865, 175, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 40 }),
0, 0, 0, 0, 10, 35, 23, 865, 160, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 50 }),
0, 0, 0, 0, 10, 35, 23, 865, 150, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 100 }),
0, 0, 0, 0, 10, 35, 23, 865, 100, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 125 }),
0, 0, 0, 0, 10, 35, 23, 865, 125, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 200 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 250 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "microseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "microseconds", roundingIncrement: 500 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "microseconds");

View File

@ -0,0 +1,58 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.until
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 35, 23, 864, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 35, 23, 864, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 23, 865, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 8 }),
0, 0, 0, 0, 10, 35, 23, 864, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 35, 23, 860, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 35, 23, 860, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 25 }),
0, 0, 0, 0, 10, 35, 23, 850, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 40 }),
0, 0, 0, 0, 10, 35, 23, 840, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 50 }),
0, 0, 0, 0, 10, 35, 23, 850, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 100 }),
0, 0, 0, 0, 10, 35, 23, 800, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 125 }),
0, 0, 0, 0, 10, 35, 23, 750, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 200 }),
0, 0, 0, 0, 10, 35, 23, 800, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 250 }),
0, 0, 0, 0, 10, 35, 23, 750, 0, 0, "milliseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "milliseconds", roundingIncrement: 500 }),
0, 0, 0, 0, 10, 35, 23, 500, 0, 0, "milliseconds");

View File

@ -0,0 +1,46 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.until
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 34, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 3 }),
0, 0, 0, 0, 10, 33, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 32, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 6 }),
0, 0, 0, 0, 10, 30, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 30, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 12 }),
0, 0, 0, 0, 10, 24, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 15 }),
0, 0, 0, 0, 10, 30, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 20, 0, 0, 0, 0, "minutes");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "minutes", roundingIncrement: 30 }),
0, 0, 0, 0, 10, 30, 0, 0, 0, 0, "minutes");

View File

@ -0,0 +1,58 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.until
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 533, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 532, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 532, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 530, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 8 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 528, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 530, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 520, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 25 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 525, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 40 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 520, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 50 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 100 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 125 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 200 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 400, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 250 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "nanoseconds", roundingIncrement: 500 }),
0, 0, 0, 0, 10, 35, 23, 865, 198, 500, "nanoseconds");

View File

@ -0,0 +1,46 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.until
description: Valid values for roundingIncrement option
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const earlier = new Temporal.PlainTime(3, 12, 34, 123, 456, 789);
const later = new Temporal.PlainTime(13, 47, 57, 988, 655, 322);
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 1 }),
0, 0, 0, 0, 10, 35, 23, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 2 }),
0, 0, 0, 0, 10, 35, 22, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 3 }),
0, 0, 0, 0, 10, 35, 21, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 4 }),
0, 0, 0, 0, 10, 35, 20, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 5 }),
0, 0, 0, 0, 10, 35, 20, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 6 }),
0, 0, 0, 0, 10, 35, 18, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 10 }),
0, 0, 0, 0, 10, 35, 20, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 12 }),
0, 0, 0, 0, 10, 35, 12, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 15 }),
0, 0, 0, 0, 10, 35, 15, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 20 }),
0, 0, 0, 0, 10, 35, 20, 0, 0, 0, "seconds");
TemporalHelpers.assertDuration(
earlier.until(later, { smallestUnit: "seconds", roundingIncrement: 30 }),
0, 0, 0, 0, 10, 35, 0, 0, 0, 0, "seconds");