| 1 |
// |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options |
| 2 |
// Copyright (C) 2022 Igalia, S.L. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-temporal.zoneddatetime.compare |
| 7 |
description: Object must contain at least the required properties. |
| 8 |
features: [Temporal] |
| 9 |
---*/ |
| 10 |
|
| 11 |
/* |
| 12 |
const zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123456789+01:00[+01:00]"); |
| 13 |
const zdt2 = Temporal.ZonedDateTime.from("2019-10-29T10:46:38.271986102+01:00[+01:00]"); |
| 14 |
*/ |
| 15 |
const zdt1 = new Temporal.ZonedDateTime(217175010123456789n, "+01:00"); |
| 16 |
const zdt2 = new Temporal.ZonedDateTime(1572342398271986102n, "+01:00"); |
| 17 |
|
| 18 |
// object must contain at least the required properties |
| 19 |
assert.sameValue(Temporal.ZonedDateTime.compare({ |
| 20 |
year: 1976, |
| 21 |
month: 11, |
| 22 |
day: 18, |
| 23 |
timeZone: "+01:00" |
| 24 |
}, zdt2), -1); |
| 25 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare({ |
| 26 |
month: 11, |
| 27 |
day: 18, |
| 28 |
timeZone: "+01:00" |
| 29 |
}, zdt2)); |
| 30 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare({ |
| 31 |
year: 1976, |
| 32 |
day: 18, |
| 33 |
timeZone: "+01:00" |
| 34 |
}, zdt2)); |
| 35 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare({ |
| 36 |
year: 1976, |
| 37 |
month: 11, |
| 38 |
timeZone: "+01:00" |
| 39 |
}, zdt2)); |
| 40 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare({ |
| 41 |
year: 1976, |
| 42 |
month: 11, |
| 43 |
day: 18 |
| 44 |
}, zdt2)); |
| 45 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare({ |
| 46 |
years: 1976, |
| 47 |
months: 11, |
| 48 |
days: 19, |
| 49 |
hours: 15, |
| 50 |
timeZone: "+01:00" |
| 51 |
}, zdt2)); |
| 52 |
assert.sameValue(Temporal.ZonedDateTime.compare(zdt1, { |
| 53 |
year: 2019, |
| 54 |
month: 10, |
| 55 |
day: 29, |
| 56 |
timeZone: "+01:00" |
| 57 |
}), -1); |
| 58 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare(zdt1, { |
| 59 |
month: 10, |
| 60 |
day: 29, |
| 61 |
timeZone: "+01:00" |
| 62 |
})); |
| 63 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare(zdt1, { |
| 64 |
year: 2019, |
| 65 |
day: 29, |
| 66 |
timeZone: "+01:00" |
| 67 |
})); |
| 68 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare(zdt1, { |
| 69 |
year: 2019, |
| 70 |
month: 10, |
| 71 |
timeZone: "+01:00" |
| 72 |
})); |
| 73 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare(zdt1, { |
| 74 |
year: 2019, |
| 75 |
month: 10, |
| 76 |
day: 29 |
| 77 |
})); |
| 78 |
assert.throws(TypeError, () => Temporal.ZonedDateTime.compare(zdt1, { |
| 79 |
years: 2019, |
| 80 |
months: 10, |
| 81 |
days: 29, |
| 82 |
hours: 10, |
| 83 |
timeZone: "+01:00" |
| 84 |
})); |
| 85 |
|
| 86 |
reportCompare(0, 0); |