| 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.plainyearmonth.compare |
| 7 |
description: UTC offset not valid with format that does not include a time |
| 8 |
features: [Temporal] |
| 9 |
---*/ |
| 10 |
|
| 11 |
const validStrings = [ |
| 12 |
"2019-12[Africa/Abidjan]", |
| 13 |
"2019-12[!Africa/Abidjan]", |
| 14 |
"2019-12[u-ca=iso8601]", |
| 15 |
"2019-12[Africa/Abidjan][u-ca=iso8601]", |
| 16 |
"2019-12-15T00+00:00", |
| 17 |
"2019-12-15T00+00:00[UTC]", |
| 18 |
"2019-12-15T00+00:00[!UTC]", |
| 19 |
"2019-12-15T00-02:30[America/St_Johns]", |
| 20 |
]; |
| 21 |
|
| 22 |
for (const arg of validStrings) { |
| 23 |
const result = Temporal.PlainYearMonth.compare(arg, arg); |
| 24 |
|
| 25 |
assert.sameValue( |
| 26 |
result, |
| 27 |
0, |
| 28 |
`"${arg}" is a valid UTC offset with time for PlainYearMonth` |
| 29 |
); |
| 30 |
} |
| 31 |
|
| 32 |
const invalidStrings = [ |
| 33 |
"2022-09[u-ca=hebrew]", |
| 34 |
"2022-09Z", |
| 35 |
"2022-09+01:00", |
| 36 |
"2022-09-15Z", |
| 37 |
"2022-09-15Z[UTC]", |
| 38 |
"2022-09-15Z[Europe/Vienna]", |
| 39 |
"2022-09-15+00:00", |
| 40 |
"2022-09-15+00:00[UTC]", |
| 41 |
"2022-09-15-02:30", |
| 42 |
"2022-09-15-02:30[America/St_Johns]", |
| 43 |
]; |
| 44 |
|
| 45 |
for (const arg of invalidStrings) { |
| 46 |
assert.throws( |
| 47 |
RangeError, |
| 48 |
() => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)), |
| 49 |
`"${arg}" UTC offset without time is not valid for PlainYearMonth (first argument)` |
| 50 |
); |
| 51 |
assert.throws( |
| 52 |
RangeError, |
| 53 |
() => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg), |
| 54 |
`"${arg}" UTC offset without time is not valid for PlainYearMonth (second argument)` |
| 55 |
); |
| 56 |
} |
| 57 |
|
| 58 |
reportCompare(0, 0); |