-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds an equal() method to Absolute, Date, DateTime, MonthDay, Time, and YearMonth. Currently `a.equal(b)` is equivalent to `Temporal.X.compare(a, b) === 0`, but after calendars are added, equal() should additionally return false if the calendars in the two objects are different. Duration doesn't have an equal() method at this time because, does `{ minutes: 1, seconds: 30 }` equal `{ seconds: 90 }`? TimeZone doesn't have one either because it's simple enough to compare the .name property.
- Loading branch information
Showing
43 changed files
with
751 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
polyfill/test/Absolute/prototype/equal/argument-wrong-type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.absolute.prototype.equal | ||
features: [Symbol] | ||
---*/ | ||
|
||
const instance = Temporal.Absolute.fromEpochSeconds(0); | ||
|
||
assert.throws(TypeError, () => instance.equal(undefined), "undefined"); | ||
assert.throws(TypeError, () => instance.equal(null), "null"); | ||
assert.throws(TypeError, () => instance.equal(true), "true"); | ||
assert.throws(TypeError, () => instance.equal(""), "empty string"); | ||
assert.throws(TypeError, () => instance.equal(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => instance.equal(1), "1"); | ||
assert.throws(TypeError, () => instance.equal({}), "plain object"); | ||
assert.throws(TypeError, () => instance.equal(Temporal.Absolute), "Temporal.Absolute"); | ||
assert.throws(TypeError, () => instance.equal(Temporal.Absolute.prototype), "Temporal.Absolute.prototype"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.absolute.prototype.equal | ||
features: [Symbol] | ||
---*/ | ||
|
||
const equal = Temporal.Absolute.prototype.equal; | ||
|
||
assert.sameValue(typeof equal, "function"); | ||
|
||
assert.throws(TypeError, () => equal.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => equal.call(null), "null"); | ||
assert.throws(TypeError, () => equal.call(true), "true"); | ||
assert.throws(TypeError, () => equal.call(""), "empty string"); | ||
assert.throws(TypeError, () => equal.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => equal.call(1), "1"); | ||
assert.throws(TypeError, () => equal.call({}), "plain object"); | ||
assert.throws(TypeError, () => equal.call(Temporal.Absolute), "Temporal.Absolute"); | ||
assert.throws(TypeError, () => equal.call(Temporal.Absolute.prototype), "Temporal.Absolute.prototype"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
includes: [propertyHelper.js] | ||
---*/ | ||
|
||
const { Absolute } = Temporal; | ||
assert.sameValue( | ||
typeof Absolute.prototype.equal, | ||
"function", | ||
"`typeof Absolute.prototype.equal` is `function`" | ||
); | ||
|
||
verifyProperty(Absolute.prototype, "equal", { | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.date.prototype.equal | ||
features: [Symbol] | ||
---*/ | ||
|
||
const instance = Temporal.Date.from({ year: 2000, month: 5, day: 2 }); | ||
|
||
assert.throws(TypeError, () => instance.equal(undefined), "undefined"); | ||
assert.throws(TypeError, () => instance.equal(null), "null"); | ||
assert.throws(TypeError, () => instance.equal(true), "true"); | ||
assert.throws(TypeError, () => instance.equal(""), "empty string"); | ||
assert.throws(TypeError, () => instance.equal(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => instance.equal(1), "1"); | ||
assert.throws(TypeError, () => instance.equal({}), "plain object"); | ||
assert.throws(TypeError, () => instance.equal(Temporal.Date), "Temporal.Date"); | ||
assert.throws(TypeError, () => instance.equal(Temporal.Date.prototype), "Temporal.Date.prototype"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.date.prototype.equal | ||
features: [Symbol] | ||
---*/ | ||
|
||
const equal = Temporal.Date.prototype.equal; | ||
|
||
assert.sameValue(typeof equal, "function"); | ||
|
||
assert.throws(TypeError, () => equal.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => equal.call(null), "null"); | ||
assert.throws(TypeError, () => equal.call(true), "true"); | ||
assert.throws(TypeError, () => equal.call(""), "empty string"); | ||
assert.throws(TypeError, () => equal.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => equal.call(1), "1"); | ||
assert.throws(TypeError, () => equal.call({}), "plain object"); | ||
assert.throws(TypeError, () => equal.call(Temporal.Date), "Temporal.Date"); | ||
assert.throws(TypeError, () => equal.call(Temporal.Date.prototype), "Temporal.Date.prototype"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
includes: [propertyHelper.js] | ||
---*/ | ||
|
||
assert.sameValue( | ||
typeof Temporal.Date.prototype.equal, | ||
"function", | ||
"`typeof Date.prototype.equal` is `function`" | ||
); | ||
|
||
verifyProperty(Temporal.Date.prototype, "equal", { | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
Oops, something went wrong.