-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for Temporal.Calendar.p*.monthDayFromFields #3058
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-constrain.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,46 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.monthdayfromfields | ||
description: Temporal.Calendar.prototype.monthDayFromFields will return correctly with data and overflow set to 'constrain'. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(fields) is not Object, throw a TypeError exception. | ||
5. Set options to ? GetOptionsObject(options). | ||
6. Let result be ? ISOMonthDayFromFields(fields, options). | ||
7. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], calendar, result.[[ReferenceISOYear]]). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601") | ||
|
||
let opt = {overflow: "constrain"}; | ||
// Test overflow: "constrain" work properly | ||
assert.sameValue("01-31", cal.monthDayFromFields({year: 2021, month: 1, day: 133}, opt).toJSON()); | ||
assert.sameValue("02-28", cal.monthDayFromFields({year: 2021, month: 2, day: 133}, opt).toJSON()); | ||
assert.sameValue("03-31", cal.monthDayFromFields({year: 2021, month: 3, day: 9033}, opt).toJSON()); | ||
assert.sameValue("04-30", cal.monthDayFromFields({year: 2021, month: 4, day: 50}, opt).toJSON()); | ||
assert.sameValue("05-31", cal.monthDayFromFields({year: 2021, month: 5, day: 77}, opt).toJSON()); | ||
assert.sameValue("06-30", cal.monthDayFromFields({year: 2021, month: 6, day: 33}, opt).toJSON()); | ||
assert.sameValue("07-31", cal.monthDayFromFields({year: 2021, month: 7, day: 33}, opt).toJSON()); | ||
assert.sameValue("08-31", cal.monthDayFromFields({year: 2021, month: 8, day: 300}, opt).toJSON()); | ||
assert.sameValue("09-30", cal.monthDayFromFields({year: 2021, month: 9, day: 400}, opt).toJSON()); | ||
assert.sameValue("10-31", cal.monthDayFromFields({year: 2021, month: 10, day: 400}, opt).toJSON()); | ||
assert.sameValue("11-30", cal.monthDayFromFields({year: 2021, month: 11, day: 400}, opt).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, month: 12, day: 500}, opt).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, month: 13, day: 500}, opt).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, month: 999999, day: 500}, opt).toJSON()); | ||
assert.sameValue("01-31", cal.monthDayFromFields({year: 2021, monthCode: "M01", day: 133}, opt).toJSON()); | ||
assert.sameValue("02-29", cal.monthDayFromFields({year: 2021, monthCode: "M02", day: 133}, opt).toJSON()); | ||
assert.sameValue("03-31", cal.monthDayFromFields({year: 2021, monthCode: "M03", day: 9033}, opt).toJSON()); | ||
assert.sameValue("04-30", cal.monthDayFromFields({year: 2021, monthCode: "M04", day: 50}, opt).toJSON()); | ||
assert.sameValue("05-31", cal.monthDayFromFields({year: 2021, monthCode: "M05", day: 77}, opt).toJSON()); | ||
assert.sameValue("06-30", cal.monthDayFromFields({year: 2021, monthCode: "M06", day: 33}, opt).toJSON()); | ||
assert.sameValue("07-31", cal.monthDayFromFields({year: 2021, monthCode: "M07", day: 33}, opt).toJSON()); | ||
assert.sameValue("08-31", cal.monthDayFromFields({year: 2021, monthCode: "M08", day: 300}, opt).toJSON()); | ||
assert.sameValue("09-30", cal.monthDayFromFields({year: 2021, monthCode: "M09", day: 400}, opt).toJSON()); | ||
assert.sameValue("10-31", cal.monthDayFromFields({year: 2021, monthCode: "M10", day: 400}, opt).toJSON()); | ||
assert.sameValue("11-30", cal.monthDayFromFields({year: 2021, monthCode: "M11", day: 400}, opt).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, monthCode: "M12", day: 500}, opt).toJSON()); |
45 changes: 45 additions & 0 deletions
45
test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-undefined.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,45 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.monthdayfromfields | ||
description: Temporal.Calendar.prototype.monthDayFromFields will return correctly with default overflow which constrain date range. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(fields) is not Object, throw a TypeError exception. | ||
5. Set options to ? GetOptionsObject(options). | ||
6. Let result be ? ISOMonthDayFromFields(fields, options). | ||
7. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], calendar, result.[[ReferenceISOYear]]). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601") | ||
|
||
// Test default overflow (which is "constrain") work properly | ||
assert.sameValue("01-31", cal.monthDayFromFields({year: 2021, month: 1, day: 133}).toJSON()); | ||
assert.sameValue("02-28", cal.monthDayFromFields({year: 2021, month: 2, day: 133}).toJSON()); | ||
assert.sameValue("03-31", cal.monthDayFromFields({year: 2021, month: 3, day: 9033}).toJSON()); | ||
assert.sameValue("04-30", cal.monthDayFromFields({year: 2021, month: 4, day: 50}).toJSON()); | ||
assert.sameValue("05-31", cal.monthDayFromFields({year: 2021, month: 5, day: 77}).toJSON()); | ||
assert.sameValue("06-30", cal.monthDayFromFields({year: 2021, month: 6, day: 33}).toJSON()); | ||
assert.sameValue("07-31", cal.monthDayFromFields({year: 2021, month: 7, day: 33}).toJSON()); | ||
assert.sameValue("08-31", cal.monthDayFromFields({year: 2021, month: 8, day: 300}).toJSON()); | ||
assert.sameValue("09-30", cal.monthDayFromFields({year: 2021, month: 9, day: 400}).toJSON()); | ||
assert.sameValue("10-31", cal.monthDayFromFields({year: 2021, month: 10, day: 400}).toJSON()); | ||
assert.sameValue("11-30", cal.monthDayFromFields({year: 2021, month: 11, day: 400}).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, month: 12, day: 500}).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, month: 13, day: 500}).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, month: 999999, day: 500}).toJSON()); | ||
assert.sameValue("01-31", cal.monthDayFromFields({year: 2021, monthCode: "M01", day: 133}).toJSON()); | ||
assert.sameValue("02-29", cal.monthDayFromFields({year: 2021, monthCode: "M02", day: 133}).toJSON()); | ||
assert.sameValue("03-31", cal.monthDayFromFields({year: 2021, monthCode: "M03", day: 9033}).toJSON()); | ||
assert.sameValue("04-30", cal.monthDayFromFields({year: 2021, monthCode: "M04", day: 50}).toJSON()); | ||
assert.sameValue("05-31", cal.monthDayFromFields({year: 2021, monthCode: "M05", day: 77}).toJSON()); | ||
assert.sameValue("06-30", cal.monthDayFromFields({year: 2021, monthCode: "M06", day: 33}).toJSON()); | ||
assert.sameValue("07-31", cal.monthDayFromFields({year: 2021, monthCode: "M07", day: 33}).toJSON()); | ||
assert.sameValue("08-31", cal.monthDayFromFields({year: 2021, monthCode: "M08", day: 300}).toJSON()); | ||
assert.sameValue("09-30", cal.monthDayFromFields({year: 2021, monthCode: "M09", day: 400}).toJSON()); | ||
assert.sameValue("10-31", cal.monthDayFromFields({year: 2021, monthCode: "M10", day: 400}).toJSON()); | ||
assert.sameValue("11-30", cal.monthDayFromFields({year: 2021, monthCode: "M11", day: 400}).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, monthCode: "M12", day: 500}).toJSON()); |
44 changes: 44 additions & 0 deletions
44
test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/simple.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,44 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.monthdayfromfields | ||
description: Temporal.Calendar.prototype.monthDayFromFields will return correctly with valid data. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(fields) is not Object, throw a TypeError exception. | ||
5. Set options to ? GetOptionsObject(options). | ||
6. Let result be ? ISOMonthDayFromFields(fields, options). | ||
7. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], calendar, result.[[ReferenceISOYear]]). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601") | ||
|
||
assert.sameValue("07-15", cal.monthDayFromFields({year: 2021, month: 7, day: 15}).toJSON()); | ||
assert.sameValue("07-03", cal.monthDayFromFields({year: 2021, month: 7, day: 3}).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, month: 12, day: 31}).toJSON()); | ||
|
||
// with monthCode, year 2021 is not used duration regulation, but use 1972 | ||
assert.sameValue("07-15", cal.monthDayFromFields({year: 2021, monthCode: "M07", day: 15}).toJSON()); | ||
assert.sameValue("07-03", cal.monthDayFromFields({year: 2021, monthCode: "M07", day: 3}).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, monthCode: "M12", day: 31}).toJSON()); | ||
// monthDay will use 1972 which is a leap year if monthCode is defined even if | ||
// we pass in 2021 as reference year. | ||
assert.sameValue("02-29", cal.monthDayFromFields({year: 2021, monthCode: "M02", day: 29}).toJSON()); | ||
|
||
["constrain", "reject"].forEach(function(overflow) { | ||
let opt = {overflow}; | ||
assert.sameValue("07-15", cal.monthDayFromFields({year: 2021, month: 7, day: 15}, opt).toJSON()); | ||
assert.sameValue("07-03", cal.monthDayFromFields({year: 2021, month: 7, day: 3}, opt).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, month: 12, day: 31}, opt).toJSON()); | ||
|
||
// with monthCode, year 2021 is not used duration regulation, but use 1972 | ||
assert.sameValue("07-15", cal.monthDayFromFields({year: 2021, monthCode: "M07", day: 15}, opt).toJSON()); | ||
assert.sameValue("07-03", cal.monthDayFromFields({year: 2021, monthCode: "M07", day: 3}, opt).toJSON()); | ||
assert.sameValue("12-31", cal.monthDayFromFields({year: 2021, monthCode: "M12", day: 31}, opt).toJSON()); | ||
// monthDay will use 1972 which is a leap year if monthCode is defined even if | ||
// we pass in 2021 as reference year. | ||
assert.sameValue("02-29", cal.monthDayFromFields({year: 2021, monthCode: "M02", day: 29}, opt).toJSON()); | ||
}); |
121 changes: 121 additions & 0 deletions
121
test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/throw-range-error.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,121 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.monthdayfromfields | ||
description: Temporal.Calendar.prototype.monthDayFromFields will throw RangeError with data value in wrong range. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(fields) is not Object, throw a TypeError exception. | ||
5. Set options to ? GetOptionsObject(options). | ||
6. Let result be ? ISOMonthDayFromFields(fields, options). | ||
7. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], calendar, result.[[ReferenceISOYear]]). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601") | ||
|
||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, monthCode: "m1", day: 17}), | ||
"monthCode value is out of range."); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, monthCode: "M1", day: 17}), | ||
"monthCode value is out of range."); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, monthCode: "m01", day: 17}), | ||
"monthCode value is out of range."); | ||
|
||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 12, monthCode: "M11", day: 17}), | ||
"monthCode value is out of range."); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, monthCode: "M00", day: 17}), | ||
"monthCode value is out of range."); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, monthCode: "M19", day: 17}), | ||
"monthCode value is out of range."); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, monthCode: "M99", day: 17}), | ||
"monthCode value is out of range."); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, monthCode: "M13", day: 17}), | ||
"monthCode value is out of range."); | ||
|
||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: -1, day: 17}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: -Infinity, day: 17}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 7, day: -17}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 7, day: -Infinity}), | ||
"Invalid time value"); | ||
|
||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 12, day: 0}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 12, day: 32}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 1, day: 32}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 2, day: 29}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 6, day: 31}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 9, day: 31}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 0, day: 5}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields({year: 2021, month: 13, day: 5}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
|
||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, monthCode: "M12", day: 0}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, monthCode: "M12", day: 32}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, monthCode: "M01", day: 32}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
|
||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, monthCode: "M06", day: 31}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, monthCode: "M09", day: 31}, {overflow: "reject"}), | ||
"Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, monthCode: "M00", day: 5}, {overflow: "reject"}), | ||
"monthCode value is out of range."); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, monthCode: "M13", day: 5}, {overflow: "reject"}), | ||
"monthCode value is out of range."); | ||
|
||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 12, day: 0}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 0, day: 3}), "Invalid time value"); | ||
|
||
// Check throw for the second arg | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 7, day: 13}, {overflow: "invalid"}), | ||
"Value invalid out of range for Temporal.Calendar.prototype.monthDayFromFields options property overflow"); | ||
|
||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 1, day: 32}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 2, day: 29}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 3, day: 32}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 4, day: 31}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 5, day: 32}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 6, day: 31}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 7, day: 32}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 8, day: 32}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 9, day: 31}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 10, day: 32}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 11, day: 31}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 12, day: 32}, {overflow: "reject"}), "Invalid time value"); | ||
assert.throws(RangeError, () => cal.monthDayFromFields( | ||
{year: 2021, month: 13, day: 5}, {overflow: "reject"}), "Invalid time value"); |
39 changes: 39 additions & 0 deletions
39
test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/throw-type-error.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,39 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.monthdayfromfields | ||
description: Temporal.Calendar.prototype.monthDayFromFields will throw TypeError with data in wrong type. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(fields) is not Object, throw a TypeError exception. | ||
5. Set options to ? GetOptionsObject(options). | ||
6. Let result be ? ISOMonthDayFromFields(fields, options). | ||
7. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], calendar, result.[[ReferenceISOYear]]). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601") | ||
|
||
// Check throw for first arg | ||
assert.throws(TypeError, () => cal.monthDayFromFields(), | ||
"Temporal.Calendar.prototype.monthDayFromFields called on non-object"); | ||
[undefined, true, false, 123, 456n, Symbol(), "string"].forEach( | ||
function(fields) { | ||
assert.throws(TypeError, () => cal.monthDayFromFields(fields), | ||
"Temporal.Calendar.prototype.monthDayFromFields called on non-object"); | ||
assert.throws(TypeError, () => cal.monthDayFromFields(fields, undefined), | ||
"Temporal.Calendar.prototype.monthDayFromFields called on non-object"); | ||
assert.throws(TypeError, () => cal.monthDayFromFields(fields, {overflow: "constrain"}), | ||
"Temporal.Calendar.prototype.monthDayFromFields called on non-object"); | ||
assert.throws(TypeError, () => cal.monthDayFromFields(fields, {overflow: "reject"}), | ||
"Temporal.Calendar.prototype.monthDayFromFields called on non-object"); | ||
}); | ||
|
||
assert.throws(TypeError, () => cal.monthDayFromFields({month: 1, day: 17}), | ||
"invalid_argument"); | ||
assert.throws(TypeError, () => cal.monthDayFromFields({year: 2021, day: 17}), | ||
"invalid_argument"); | ||
assert.throws(TypeError, () => cal.monthDayFromFields({year: 2021, month: 12}), | ||
"invalid_argument"); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one has a naming conflict with a test already in the proposal repo which still has to be copied over here: https://github.com/tc39/proposal-temporal/blob/main/polyfill/test/Calendar/prototype/monthDayFromFields/overflow-undefined.js
Consider combining them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so... what make the tests in those places not yet move into test262 yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about I change the file name and yield the file name for those in
https://github.com/tc39/proposal-temporal/blob/main/polyfill/test/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I outlined the plan for moving them over in #3002 (comment)
It would be really inconvenient for ensuring that we correctly and completely converted the legacy test suite, if we were to move everything over now to this repo and let it start to diverge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let me just abandon this PR and wait for @ptomato and @Ms2ger to move their test from Temporal repo instead.