diff --git a/test/built-ins/Temporal/PlainTime/from/argument-number.js b/test/built-ins/Temporal/PlainTime/from/argument-number.js new file mode 100644 index 0000000000..6f215a4e4a --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-number.js @@ -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); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-object-leap-second.js b/test/built-ins/Temporal/PlainTime/from/argument-object-leap-second.js new file mode 100644 index 0000000000..de580b2331 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-object-leap-second.js @@ -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)); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-object.js b/test/built-ins/Temporal/PlainTime/from/argument-object.js new file mode 100644 index 0000000000..59a69c8806 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-object.js @@ -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 })); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-string-leap-second.js b/test/built-ins/Temporal/PlainTime/from/argument-string-leap-second.js new file mode 100644 index 0000000000..cb960920ee --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-string-leap-second.js @@ -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); +} diff --git a/test/built-ins/Temporal/PlainTime/from/overflow-constrain.js b/test/built-ins/Temporal/PlainTime/from/overflow-constrain.js new file mode 100644 index 0000000000..9048d1b7a0 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/overflow-constrain.js @@ -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); diff --git a/test/built-ins/Temporal/PlainTime/from/overflow-reject.js b/test/built-ins/Temporal/PlainTime/from/overflow-reject.js new file mode 100644 index 0000000000..7f76deab50 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/overflow-reject.js @@ -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); diff --git a/test/built-ins/Temporal/PlainTime/negative-zero.js b/test/built-ins/Temporal/PlainTime/negative-zero.js new file mode 100644 index 0000000000..4959e4323d --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/negative-zero.js @@ -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); diff --git a/test/built-ins/Temporal/PlainTime/prototype/add/argument-duration.js b/test/built-ins/Temporal/PlainTime/prototype/add/argument-duration.js new file mode 100644 index 0000000000..0a4e1070f3 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/add/argument-duration.js @@ -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); diff --git a/test/built-ins/Temporal/PlainTime/prototype/add/argument-higher-units.js b/test/built-ins/Temporal/PlainTime/prototype/add/argument-higher-units.js new file mode 100644 index 0000000000..af4913e217 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/add/argument-higher-units.js @@ -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); +} diff --git a/test/built-ins/Temporal/PlainTime/prototype/add/argument-object.js b/test/built-ins/Temporal/PlainTime/prototype/add/argument-object.js new file mode 100644 index 0000000000..4f0bdaa2b5 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/add/argument-object.js @@ -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); diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/rounding-cross-midnight.js b/test/built-ins/Temporal/PlainTime/prototype/round/rounding-cross-midnight.js new file mode 100644 index 0000000000..9b28178314 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/rounding-cross-midnight.js @@ -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); +} diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-hours.js b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-hours.js new file mode 100644 index 0000000000..666fd223d0 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-hours.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-microseconds.js b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-microseconds.js new file mode 100644 index 0000000000..6eb685312a --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-microseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-milliseconds.js b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-milliseconds.js new file mode 100644 index 0000000000..a33615f4d1 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-milliseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-minutes.js b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-minutes.js new file mode 100644 index 0000000000..297407eb17 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-minutes.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-nanoseconds.js b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-nanoseconds.js new file mode 100644 index 0000000000..0992ce73a2 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-nanoseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-seconds.js b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-seconds.js new file mode 100644 index 0000000000..11bbb6a7a6 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/roundingincrement-seconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-hours.js b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-hours.js new file mode 100644 index 0000000000..dc57609720 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-hours.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-microseconds.js b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-microseconds.js new file mode 100644 index 0000000000..ded0e0d908 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-microseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-milliseconds.js b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-milliseconds.js new file mode 100644 index 0000000000..4a6c867dde --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-milliseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-minutes.js b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-minutes.js new file mode 100644 index 0000000000..05a62d4269 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-minutes.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-nanoseconds.js b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-nanoseconds.js new file mode 100644 index 0000000000..cc43a8e3e9 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-nanoseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-seconds.js b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-seconds.js new file mode 100644 index 0000000000..ac24ee8ce8 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/roundingincrement-seconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-duration.js b/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-duration.js new file mode 100644 index 0000000000..eff64119bc --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-duration.js @@ -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); diff --git a/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-higher-units.js b/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-higher-units.js new file mode 100644 index 0000000000..8e64720573 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-higher-units.js @@ -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); +} diff --git a/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-object.js b/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-object.js new file mode 100644 index 0000000000..a981492bdf --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/subtract/argument-object.js @@ -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); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-hours.js b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-hours.js new file mode 100644 index 0000000000..9245498b40 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-hours.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-microseconds.js b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-microseconds.js new file mode 100644 index 0000000000..2bde9cd4af --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-microseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-milliseconds.js b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-milliseconds.js new file mode 100644 index 0000000000..2eade031db --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-milliseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-minutes.js b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-minutes.js new file mode 100644 index 0000000000..371d8fcb83 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-minutes.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-nanoseconds.js b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-nanoseconds.js new file mode 100644 index 0000000000..7ec306ff7a --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-nanoseconds.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-seconds.js b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-seconds.js new file mode 100644 index 0000000000..eb5edd775a --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/roundingincrement-seconds.js @@ -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");