-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add getISOFields() method to calendar-dependent types
Closes: #354
- Loading branch information
Showing
28 changed files
with
536 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
const getISOFields = Temporal.Date.prototype.getISOFields; | ||
|
||
assert.sameValue(typeof getISOFields, "function"); | ||
|
||
assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => getISOFields.call(null), "null"); | ||
assert.throws(TypeError, () => getISOFields.call(true), "true"); | ||
assert.throws(TypeError, () => getISOFields.call(""), "empty string"); | ||
assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => getISOFields.call(1), "1"); | ||
assert.throws(TypeError, () => getISOFields.call({}), "plain object"); | ||
assert.throws(TypeError, () => getISOFields.call(Temporal.Date), "Temporal.Date"); | ||
assert.throws(TypeError, () => getISOFields.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.getISOFields, | ||
"function", | ||
"`typeof Date.prototype.getISOFields` is `function`" | ||
); | ||
|
||
verifyProperty(Temporal.Date.prototype, "getISOFields", { | ||
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,31 @@ | ||
// 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.getisofields | ||
includes: [compareArray.js] | ||
---*/ | ||
|
||
let called = 0; | ||
|
||
const constructorArguments = [ | ||
[2000, 5, 2] | ||
]; | ||
|
||
class MyDate extends Temporal.Date { | ||
constructor(year, month, day) { | ||
assert.compareArray([year, month, day], constructorArguments.shift(), "constructor arguments"); | ||
++called; | ||
super(year, month, day); | ||
} | ||
} | ||
|
||
const instance = MyDate.from("2000-05-02"); | ||
assert.sameValue(called, 1); | ||
|
||
const result = instance.getISOFields(); | ||
assert.sameValue(result.year, 2000, "year result"); | ||
assert.sameValue(result.month, 5, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(called, 1); | ||
assert.sameValue(Object.getPrototypeOf(result), Object.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,16 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
const getISOFields = Temporal.DateTime.prototype.getISOFields; | ||
|
||
assert.sameValue(typeof getISOFields, "function"); | ||
|
||
assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => getISOFields.call(null), "null"); | ||
assert.throws(TypeError, () => getISOFields.call(true), "true"); | ||
assert.throws(TypeError, () => getISOFields.call(""), "empty string"); | ||
assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => getISOFields.call(1), "1"); | ||
assert.throws(TypeError, () => getISOFields.call({}), "plain object"); | ||
assert.throws(TypeError, () => getISOFields.call(Temporal.DateTime), "Temporal.DateTime"); | ||
assert.throws(TypeError, () => getISOFields.call(Temporal.DateTime.prototype), "Temporal.DateTime.prototype"); |
18 changes: 18 additions & 0 deletions
18
polyfill/test/DateTime/prototype/getISOFields/prop-desc.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,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.DateTime.prototype.getISOFields, | ||
"function", | ||
"`typeof DateTime.prototype.getISOFields` is `function`" | ||
); | ||
|
||
verifyProperty(Temporal.DateTime.prototype, "getISOFields", { | ||
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,37 @@ | ||
// 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.datetime.prototype.getisofields | ||
includes: [compareArray.js] | ||
---*/ | ||
|
||
let called = 0; | ||
|
||
const constructorArguments = [ | ||
[2000, 5, 2, 12, 34, 56, 987, 654, 321] | ||
]; | ||
|
||
class MyDateTime extends Temporal.DateTime { | ||
constructor(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond) { | ||
assert.compareArray([year, month, day, hour, minute, second, millisecond, microsecond, nanosecond], constructorArguments.shift(), "constructor arguments"); | ||
++called; | ||
super(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond); | ||
} | ||
} | ||
|
||
const instance = MyDateTime.from("2000-05-02T12:34:56.987654321"); | ||
assert.sameValue(called, 1); | ||
|
||
const result = instance.getISOFields(); | ||
assert.sameValue(result.year, 2000, "year result"); | ||
assert.sameValue(result.month, 5, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(result.hour, 12, "hour result"); | ||
assert.sameValue(result.minute, 34, "minute result"); | ||
assert.sameValue(result.second, 56, "second result"); | ||
assert.sameValue(result.millisecond, 987, "millisecond result"); | ||
assert.sameValue(result.microsecond, 654, "microsecond result"); | ||
assert.sameValue(result.nanosecond, 321, "nanosecond result"); | ||
assert.sameValue(called, 1); | ||
assert.sameValue(Object.getPrototypeOf(result), Object.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,16 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
const getISOFields = Temporal.MonthDay.prototype.getISOFields; | ||
|
||
assert.sameValue(typeof getISOFields, "function"); | ||
|
||
assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => getISOFields.call(null), "null"); | ||
assert.throws(TypeError, () => getISOFields.call(true), "true"); | ||
assert.throws(TypeError, () => getISOFields.call(""), "empty string"); | ||
assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => getISOFields.call(1), "1"); | ||
assert.throws(TypeError, () => getISOFields.call({}), "plain object"); | ||
assert.throws(TypeError, () => getISOFields.call(Temporal.MonthDay), "Temporal.MonthDay"); | ||
assert.throws(TypeError, () => getISOFields.call(Temporal.MonthDay.prototype), "Temporal.MonthDay.prototype"); |
18 changes: 18 additions & 0 deletions
18
polyfill/test/MonthDay/prototype/getISOFields/prop-desc.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,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.MonthDay.prototype.getISOFields, | ||
"function", | ||
"`typeof MonthDay.prototype.getISOFields` is `function`" | ||
); | ||
|
||
verifyProperty(Temporal.MonthDay.prototype, "getISOFields", { | ||
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,30 @@ | ||
// 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.monthday.prototype.getisofields | ||
includes: [compareArray.js] | ||
---*/ | ||
|
||
let called = 0; | ||
|
||
const constructorArguments = [ | ||
[5, 2] | ||
]; | ||
|
||
class MyMonthDay extends Temporal.MonthDay { | ||
constructor(month, day) { | ||
assert.compareArray([month, day], constructorArguments.shift(), "constructor arguments"); | ||
++called; | ||
super(month, day); | ||
} | ||
} | ||
|
||
const instance = MyMonthDay.from("05-02"); | ||
assert.sameValue(called, 1); | ||
|
||
const result = instance.getISOFields(); | ||
assert.sameValue(result.month, 5, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(called, 1); | ||
assert.sameValue(Object.getPrototypeOf(result), Object.prototype); |
16 changes: 16 additions & 0 deletions
16
polyfill/test/YearMonth/prototype/getISOFields/branding.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,16 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
const getISOFields = Temporal.YearMonth.prototype.getISOFields; | ||
|
||
assert.sameValue(typeof getISOFields, "function"); | ||
|
||
assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => getISOFields.call(null), "null"); | ||
assert.throws(TypeError, () => getISOFields.call(true), "true"); | ||
assert.throws(TypeError, () => getISOFields.call(""), "empty string"); | ||
assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => getISOFields.call(1), "1"); | ||
assert.throws(TypeError, () => getISOFields.call({}), "plain object"); | ||
assert.throws(TypeError, () => getISOFields.call(Temporal.YearMonth), "Temporal.YearMonth"); | ||
assert.throws(TypeError, () => getISOFields.call(Temporal.YearMonth.prototype), "Temporal.YearMonth.prototype"); |
18 changes: 18 additions & 0 deletions
18
polyfill/test/YearMonth/prototype/getISOFields/prop-desc.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,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.YearMonth.prototype.getISOFields, | ||
"function", | ||
"`typeof YearMonth.prototype.getISOFields` is `function`" | ||
); | ||
|
||
verifyProperty(Temporal.YearMonth.prototype, "getISOFields", { | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
Oops, something went wrong.