mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Temporal: Exhaustive coverage for compare() methods
This adds coverage for each possible outcome of compare(), where each unit is greater, lesser, or equal.
This commit is contained in:
parent
1f0fc4e0ad
commit
96bc38f5d9
513
test/built-ins/Temporal/Duration/compare/exhaustive.js
Normal file
513
test/built-ins/Temporal/Duration/compare/exhaustive.js
Normal file
@ -0,0 +1,513 @@
|
|||||||
|
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.duration.compare
|
||||||
|
description: Tests for compare() with each possible outcome
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const plainDate = new Temporal.PlainDate(2000, 1, 1);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(6),
|
||||||
|
new Temporal.Duration(5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"years >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(3),
|
||||||
|
new Temporal.Duration(4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"years <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 6),
|
||||||
|
new Temporal.Duration(2, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"months >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 3),
|
||||||
|
new Temporal.Duration(4, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"months <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 6),
|
||||||
|
new Temporal.Duration(2, 1, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"weeks >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 3),
|
||||||
|
new Temporal.Duration(4, 7, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"weeks <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"days >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"days <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"hours >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"hours <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"minutes >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"minutes <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"seconds >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"seconds <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"milliseconds >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"milliseconds <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 222, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 222, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"microseconds >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"microseconds <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 222, 444, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 222, 444, 5),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"nanoseconds >, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 777, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 777, 4),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"nanoseconds <, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 777, 111),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 777, 111),
|
||||||
|
{ relativeTo: plainDate }
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
"equal, relativeTo PlainDate"
|
||||||
|
);
|
||||||
|
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(0n, "UTC");
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(6),
|
||||||
|
new Temporal.Duration(5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"years >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(3),
|
||||||
|
new Temporal.Duration(4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"years <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 6),
|
||||||
|
new Temporal.Duration(2, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"months >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 3),
|
||||||
|
new Temporal.Duration(4, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"months <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 6),
|
||||||
|
new Temporal.Duration(2, 1, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"weeks >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 3),
|
||||||
|
new Temporal.Duration(4, 7, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"weeks <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"days >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"days <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"hours >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"hours <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"minutes >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"minutes <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"seconds >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"seconds <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"milliseconds >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"milliseconds <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 222, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 222, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"microseconds >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"microseconds <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 222, 444, 6),
|
||||||
|
new Temporal.Duration(2, 1, 3, 12, 6, 30, 15, 222, 444, 5),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"nanoseconds >, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 777, 3),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 777, 4),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"nanoseconds <, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 777, 111),
|
||||||
|
new Temporal.Duration(4, 7, 2, 40, 12, 15, 45, 333, 777, 111),
|
||||||
|
{ relativeTo: zonedDateTime }
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
"equal, relativeTo ZonedDateTime"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 6),
|
||||||
|
new Temporal.Duration(0, 0, 0, 5)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"days >, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 3),
|
||||||
|
new Temporal.Duration(0, 0, 0, 4)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"days <, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6),
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 5)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"hours >, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 3),
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 4)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"hours <, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 6),
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 5)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"minutes >, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 3),
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 4)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"minutes <, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 30, 6),
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 30, 5)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"seconds >, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 3),
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 4)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"seconds <, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 30, 15, 6),
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 30, 15, 5)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"milliseconds >, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 45, 3),
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 45, 4)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"milliseconds <, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 30, 15, 222, 6),
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 30, 15, 222, 5)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"microseconds >, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 45, 333, 3),
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 45, 333, 4)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"microseconds <, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 30, 15, 222, 444, 6),
|
||||||
|
new Temporal.Duration(0, 0, 0, 12, 6, 30, 15, 222, 444, 5)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"nanoseconds >, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 45, 333, 777, 3),
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 45, 333, 777, 4)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"nanoseconds <, relativeTo nothing"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Duration.compare(
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 45, 333, 777, 111),
|
||||||
|
new Temporal.Duration(0, 0, 0, 40, 12, 15, 45, 333, 777, 111)
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
"equal, relativeTo nothing"
|
||||||
|
);
|
24
test/built-ins/Temporal/Instant/compare/exhaustive.js
Normal file
24
test/built-ins/Temporal/Instant/compare/exhaustive.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.instant.compare
|
||||||
|
description: Tests for compare() with each possible outcome
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Instant.compare(new Temporal.Instant(1_000_000_000_000_000_000n), new Temporal.Instant(500_000_000_000_000_000n)),
|
||||||
|
1,
|
||||||
|
">"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Instant.compare(new Temporal.Instant(-1000n), new Temporal.Instant(1000n)),
|
||||||
|
-1,
|
||||||
|
"<"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.Instant.compare(new Temporal.Instant(123_456_789n), new Temporal.Instant(123_456_789n)),
|
||||||
|
0,
|
||||||
|
"="
|
||||||
|
);
|
68
test/built-ins/Temporal/PlainDate/compare/exhaustive.js
Normal file
68
test/built-ins/Temporal/PlainDate/compare/exhaustive.js
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.plaindate.compare
|
||||||
|
description: Tests for compare() with each possible outcome
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const cal1 = "iso8601";
|
||||||
|
const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601");
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDate.compare(
|
||||||
|
new Temporal.PlainDate(2000, 5, 31, cal1),
|
||||||
|
new Temporal.PlainDate(1987, 5, 31, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"year >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDate.compare(
|
||||||
|
new Temporal.PlainDate(1981, 12, 15, cal1),
|
||||||
|
new Temporal.PlainDate(2048, 12, 15, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"year <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDate.compare(
|
||||||
|
new Temporal.PlainDate(2000, 5, 31, cal1),
|
||||||
|
new Temporal.PlainDate(2000, 3, 31, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"month >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDate.compare(
|
||||||
|
new Temporal.PlainDate(1981, 4, 15, cal1),
|
||||||
|
new Temporal.PlainDate(1981, 12, 15, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"month <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDate.compare(
|
||||||
|
new Temporal.PlainDate(2000, 5, 31, cal1),
|
||||||
|
new Temporal.PlainDate(2000, 5, 14, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"day >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDate.compare(
|
||||||
|
new Temporal.PlainDate(1981, 4, 15, cal1),
|
||||||
|
new Temporal.PlainDate(1981, 4, 21, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"day <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDate.compare(
|
||||||
|
new Temporal.PlainDate(2000, 5, 31, cal1),
|
||||||
|
new Temporal.PlainDate(2000, 5, 31, cal2)
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
"="
|
||||||
|
);
|
164
test/built-ins/Temporal/PlainDateTime/compare/exhaustive.js
Normal file
164
test/built-ins/Temporal/PlainDateTime/compare/exhaustive.js
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.plaindatetime.compare
|
||||||
|
description: Tests for compare() with each possible outcome
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const cal1 = "iso8601";
|
||||||
|
const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601");
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(1987, 5, 31, 12, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"year >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 12, 15, 6, 30, 15, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainDateTime(2048, 12, 15, 6, 30, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"year <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 3, 31, 12, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"month >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainDateTime(1981, 12, 15, 6, 30, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"month <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 14, 12, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"day >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 21, 6, 30, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"day <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 6, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"hour >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 22, 30, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"hour <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 22, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"minute >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 57, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"minute <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 6, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 5, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"second >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 3, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 4, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"second <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 6, 777, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 5, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"millisecond >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 3, 444, 6, cal1),
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 4, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"millisecond <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 6, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 5, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"microsecond >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 3, 6, cal1),
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 4, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"microsecond <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 999, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"nanosecond >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 0, cal1),
|
||||||
|
new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"nanosecond <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainDateTime.compare(
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
"="
|
||||||
|
);
|
116
test/built-ins/Temporal/PlainTime/compare/exhaustive.js
Normal file
116
test/built-ins/Temporal/PlainTime/compare/exhaustive.js
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.plaintime.compare
|
||||||
|
description: Tests for compare() with each possible outcome
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const cal1 = "iso8601";
|
||||||
|
const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601");
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainTime(6, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"hour >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(6, 30, 15, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainTime(22, 30, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"hour <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(12, 45, 15, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainTime(12, 15, 22, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"minute >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(6, 30, 15, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainTime(6, 57, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"minute <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(12, 15, 6, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainTime(12, 15, 5, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"second >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(6, 30, 3, 222, 444, 6, cal1),
|
||||||
|
new Temporal.PlainTime(6, 30, 4, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"second <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 6, 777, 111, cal1),
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 5, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"millisecond >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(6, 30, 15, 3, 444, 6, cal1),
|
||||||
|
new Temporal.PlainTime(6, 30, 15, 4, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"millisecond <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 333, 6, 111, cal1),
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 333, 5, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"microsecond >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(6, 30, 15, 222, 3, 6, cal1),
|
||||||
|
new Temporal.PlainTime(6, 30, 15, 222, 4, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"microsecond <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 333, 777, 999, cal1),
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
"nanosecond >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(6, 30, 15, 222, 444, 0, cal1),
|
||||||
|
new Temporal.PlainTime(6, 30, 15, 222, 444, 6, cal2)
|
||||||
|
),
|
||||||
|
-1,
|
||||||
|
"nanosecond <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainTime.compare(
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 333, 777, 111, cal1),
|
||||||
|
new Temporal.PlainTime(12, 15, 45, 333, 777, 111, cal2)
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
"="
|
||||||
|
);
|
47
test/built-ins/Temporal/PlainYearMonth/compare/exhaustive.js
Normal file
47
test/built-ins/Temporal/PlainYearMonth/compare/exhaustive.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.plainyearmonth.compare
|
||||||
|
description: Tests for compare() with each possible outcome
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const cal1 = "iso8601";
|
||||||
|
const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601");
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(1987, 5, cal2)),
|
||||||
|
1,
|
||||||
|
"year >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 12, cal1), new Temporal.PlainYearMonth(2048, 12, cal2)),
|
||||||
|
-1,
|
||||||
|
"year <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(2000, 3, cal2)),
|
||||||
|
1,
|
||||||
|
"month >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 4, cal1), new Temporal.PlainYearMonth(1981, 12, cal2)),
|
||||||
|
-1,
|
||||||
|
"month <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1, 30), new Temporal.PlainYearMonth(2000, 5, cal2, 14)),
|
||||||
|
1,
|
||||||
|
"reference day >"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 4, cal1, 1), new Temporal.PlainYearMonth(1981, 4, cal2, 12)),
|
||||||
|
-1,
|
||||||
|
"reference day <"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(2000, 5, cal2)),
|
||||||
|
0,
|
||||||
|
"="
|
||||||
|
);
|
29
test/built-ins/Temporal/ZonedDateTime/compare/exhaustive.js
Normal file
29
test/built-ins/Temporal/ZonedDateTime/compare/exhaustive.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.zoneddatetime.compare
|
||||||
|
description: Tests for compare() with each possible outcome
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const tz1 = "UTC";
|
||||||
|
const tz2 = "-00:30";
|
||||||
|
const cal1 = "iso8601";
|
||||||
|
const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601");
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, tz1, cal1), new Temporal.ZonedDateTime(500_000_000_000_000_000n, tz2, cal2)),
|
||||||
|
1,
|
||||||
|
">"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(-1000n, tz1, cal1), new Temporal.ZonedDateTime(1000n, tz2, cal2)),
|
||||||
|
-1,
|
||||||
|
"<"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(123_456_789n, tz1, cal1), new Temporal.ZonedDateTime(123_456_789n, tz2, cal2)),
|
||||||
|
0,
|
||||||
|
"="
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user