basic.js (1321B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 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.plaindatetime.compare 7 description: Checking a typical case (nothing undefined, no NaNs, does not throw, etc.) 8 features: [Temporal] 9 ---*/ 10 11 const dt1 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); 12 const dt2 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102); 13 const dt3 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102); 14 const dt4 = new Temporal.PlainDateTime(2019, 10, 29, 15, 23, 30, 123, 456, 789); 15 const dt5 = new Temporal.PlainDateTime(1976, 11, 18, 10, 46, 38, 271, 986, 102); 16 17 assert.sameValue(Temporal.PlainDateTime.compare(dt1, dt1), 0, "equal"); 18 assert.sameValue(Temporal.PlainDateTime.compare(dt1, dt2), -1, "smaller/larger"); 19 assert.sameValue(Temporal.PlainDateTime.compare(dt2, dt1), 1, "larger/smaller"); 20 assert.sameValue(Temporal.PlainDateTime.compare(dt2, dt3), 0, "equal different object"); 21 assert.sameValue(Temporal.PlainDateTime.compare(dt3, dt4), -1, "same date, earlier time"); 22 assert.sameValue(Temporal.PlainDateTime.compare(dt3, dt5), 1, "same time, later date"); 23 24 25 reportCompare(0, 0);