My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Temporal: Add coverage for rounding/totaling zero duration (#4774)

authored by

Tim Chevalier and committed by
GitHub
76a9deaf 39266bc7

+65
+42
vendor/git/test262/test/built-ins/Temporal/Duration/prototype/round/zero-duration.js
··· 1 + // Copyright (C) 2025 Igalia, S.L. All rights reserved. 2 + // This code is governed by the BSD license found in the LICENSE file. 3 + 4 + /*--- 5 + esid: sec-temporal.duration.prototype.round 6 + description: Rounding zero duration returns 0 7 + includes: [temporalHelpers.js] 8 + features: [Temporal] 9 + ---*/ 10 + 11 + const zero = new Temporal.Duration(); 12 + 13 + let relativeToDates = [ 14 + new Temporal.ZonedDateTime(0n, 'UTC'), 15 + new Temporal.PlainDateTime(1970, 1, 1) 16 + ]; 17 + 18 + let units = [ 19 + { smallestUnit: 'hours', largestUnit: 'days' }, 20 + { smallestUnit: 'minutes', largestUnit: 'days' }, 21 + { smallestUnit: 'seconds', largestUnit: 'days' }, 22 + { smallestUnit: 'hours', largestUnit: 'weeks' }, 23 + { smallestUnit: 'minutes', largestUnit: 'weeks' }, 24 + { smallestUnit: 'seconds', largestUnit: 'weeks' }, 25 + { smallestUnit: 'hours', largestUnit: 'months' }, 26 + { smallestUnit: 'minutes', largestUnit: 'months' }, 27 + { smallestUnit: 'seconds', largestUnit: 'months' }, 28 + { smallestUnit: 'hours', largestUnit: 'years' }, 29 + { smallestUnit: 'minutes', largestUnit: 'years' }, 30 + { smallestUnit: 'seconds', largestUnit: 'years' } 31 + ]; 32 + 33 + for (const relativeTo of relativeToDates) { 34 + for (const unit of units) { 35 + TemporalHelpers.assertDuration(zero.round({ 36 + smallestUnit: unit.smallestUnit, 37 + largestUnit: unit.largestUnit, 38 + relativeTo 39 + }), 40 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 41 + } 42 + }
+23
vendor/git/test262/test/built-ins/Temporal/Duration/prototype/total/zero-duration.js
··· 1 + // Copyright (C) 2025 Igalia, S.L. All rights reserved. 2 + // This code is governed by the BSD license found in the LICENSE file. 3 + 4 + /*--- 5 + esid: sec-temporal.duration.prototype.total 6 + description: Totaling zero duration returns 0 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const zero = new Temporal.Duration(); 11 + 12 + let relativeToDates = [ 13 + new Temporal.ZonedDateTime(0n, 'UTC'), 14 + new Temporal.PlainDateTime(1970, 1, 1) 15 + ]; 16 + 17 + let units = [ 'days', 'weeks', 'months', 'years' ]; 18 + 19 + for (const relativeTo of relativeToDates) { 20 + for (const unit of units) { 21 + assert.sameValue(zero.total({ unit, relativeTo }), 0); 22 + } 23 + }