| 1 |
// |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options |
| 2 |
// Copyright (C) 2023 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.plaindate.compare |
| 7 |
description: Tests for compare() with each possible outcome |
| 8 |
features: [Temporal] |
| 9 |
---*/ |
| 10 |
|
| 11 |
const cal1 = "iso8601"; |
| 12 |
const cal2 = "gregory"; |
| 13 |
|
| 14 |
assert.sameValue( |
| 15 |
Temporal.PlainDate.compare( |
| 16 |
new Temporal.PlainDate(2000, 5, 31, cal1), |
| 17 |
new Temporal.PlainDate(1987, 5, 31, cal2) |
| 18 |
), |
| 19 |
1, |
| 20 |
"year >" |
| 21 |
); |
| 22 |
assert.sameValue( |
| 23 |
Temporal.PlainDate.compare( |
| 24 |
new Temporal.PlainDate(1981, 12, 15, cal1), |
| 25 |
new Temporal.PlainDate(2048, 12, 15, cal2) |
| 26 |
), |
| 27 |
-1, |
| 28 |
"year <" |
| 29 |
); |
| 30 |
assert.sameValue( |
| 31 |
Temporal.PlainDate.compare( |
| 32 |
new Temporal.PlainDate(2000, 5, 31, cal1), |
| 33 |
new Temporal.PlainDate(2000, 3, 31, cal2) |
| 34 |
), |
| 35 |
1, |
| 36 |
"month >" |
| 37 |
); |
| 38 |
assert.sameValue( |
| 39 |
Temporal.PlainDate.compare( |
| 40 |
new Temporal.PlainDate(1981, 4, 15, cal1), |
| 41 |
new Temporal.PlainDate(1981, 12, 15, cal2) |
| 42 |
), |
| 43 |
-1, |
| 44 |
"month <" |
| 45 |
); |
| 46 |
assert.sameValue( |
| 47 |
Temporal.PlainDate.compare( |
| 48 |
new Temporal.PlainDate(2000, 5, 31, cal1), |
| 49 |
new Temporal.PlainDate(2000, 5, 14, cal2) |
| 50 |
), |
| 51 |
1, |
| 52 |
"day >" |
| 53 |
); |
| 54 |
assert.sameValue( |
| 55 |
Temporal.PlainDate.compare( |
| 56 |
new Temporal.PlainDate(1981, 4, 15, cal1), |
| 57 |
new Temporal.PlainDate(1981, 4, 21, cal2) |
| 58 |
), |
| 59 |
-1, |
| 60 |
"day <" |
| 61 |
); |
| 62 |
assert.sameValue( |
| 63 |
Temporal.PlainDate.compare( |
| 64 |
new Temporal.PlainDate(2000, 5, 31, cal1), |
| 65 |
new Temporal.PlainDate(2000, 5, 31, cal2) |
| 66 |
), |
| 67 |
0, |
| 68 |
"=" |
| 69 |
); |
| 70 |
|
| 71 |
reportCompare(0, 0); |