-
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 equals() method to Absolute, Date, DateTime, MonthDay, Time, and YearMonth. For types with a compare() method, `a.equals(b)` is equivalent to `Temporal.X.compare(a, b) === 0` Duration doesn't have an equals() 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
754 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/equals/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.equals | ||
features: [Symbol] | ||
---*/ | ||
|
||
const instance = Temporal.Absolute.fromEpochSeconds(0); | ||
|
||
assert.throws(TypeError, () => instance.equals(undefined), "undefined"); | ||
assert.throws(TypeError, () => instance.equals(null), "null"); | ||
assert.throws(TypeError, () => instance.equals(true), "true"); | ||
assert.throws(TypeError, () => instance.equals(""), "empty string"); | ||
assert.throws(TypeError, () => instance.equals(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => instance.equals(1), "1"); | ||
assert.throws(TypeError, () => instance.equals({}), "plain object"); | ||
assert.throws(TypeError, () => instance.equals(Temporal.Absolute), "Temporal.Absolute"); | ||
assert.throws(TypeError, () => instance.equals(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.equals | ||
features: [Symbol] | ||
---*/ | ||
|
||
const equals = Temporal.Absolute.prototype.equals; | ||
|
||
assert.sameValue(typeof equals, "function"); | ||
|
||
assert.throws(TypeError, () => equals.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => equals.call(null), "null"); | ||
assert.throws(TypeError, () => equals.call(true), "true"); | ||
assert.throws(TypeError, () => equals.call(""), "empty string"); | ||
assert.throws(TypeError, () => equals.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => equals.call(1), "1"); | ||
assert.throws(TypeError, () => equals.call({}), "plain object"); | ||
assert.throws(TypeError, () => equals.call(Temporal.Absolute), "Temporal.Absolute"); | ||
assert.throws(TypeError, () => equals.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.equals, | ||
"function", | ||
"`typeof Absolute.prototype.equals` is `function`" | ||
); | ||
|
||
verifyProperty(Absolute.prototype, "equals", { | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
19 changes: 19 additions & 0 deletions
19
polyfill/test/Date/prototype/equals/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.date.prototype.equals | ||
features: [Symbol] | ||
---*/ | ||
|
||
const instance = Temporal.Date.from({ year: 2000, month: 5, day: 2 }); | ||
|
||
assert.throws(TypeError, () => instance.equals(undefined), "undefined"); | ||
assert.throws(TypeError, () => instance.equals(null), "null"); | ||
assert.throws(TypeError, () => instance.equals(true), "true"); | ||
assert.throws(TypeError, () => instance.equals(""), "empty string"); | ||
assert.throws(TypeError, () => instance.equals(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => instance.equals(1), "1"); | ||
assert.throws(TypeError, () => instance.equals({}), "plain object"); | ||
assert.throws(TypeError, () => instance.equals(Temporal.Date), "Temporal.Date"); | ||
assert.throws(TypeError, () => instance.equals(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.equals | ||
features: [Symbol] | ||
---*/ | ||
|
||
const equals = Temporal.Date.prototype.equals; | ||
|
||
assert.sameValue(typeof equals, "function"); | ||
|
||
assert.throws(TypeError, () => equals.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => equals.call(null), "null"); | ||
assert.throws(TypeError, () => equals.call(true), "true"); | ||
assert.throws(TypeError, () => equals.call(""), "empty string"); | ||
assert.throws(TypeError, () => equals.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => equals.call(1), "1"); | ||
assert.throws(TypeError, () => equals.call({}), "plain object"); | ||
assert.throws(TypeError, () => equals.call(Temporal.Date), "Temporal.Date"); | ||
assert.throws(TypeError, () => equals.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.equals, | ||
"function", | ||
"`typeof Date.prototype.equals` is `function`" | ||
); | ||
|
||
verifyProperty(Temporal.Date.prototype, "equals", { | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
Oops, something went wrong.