-
Notifications
You must be signed in to change notification settings - Fork 495
Temporal: Reorganize calendar and wrong-type tests #4415
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
Merged
ptomato
merged 42 commits into
tc39:main
from
brageh01:merge-and-extract-calendar-number-and-wrong-type-tests
Apr 23, 2025
Merged
Changes from 11 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
6cc037e
Reorganize calendar and wrong-type tests
1c79535
Merged number.js tests into wrong-type.js tests, and extracted the st…
e39813f
Merged and extracted argument-* tests in PlainDate/from
cd49862
Merge branch 'main' into merge-and-extract-calendar-number-and-wrong-…
brageh01 b3d0e46
added newline to argument-*-invalid-iso-string.js, due to an error-co…
ef15474
Merged and extracted argument-* tests for PlainYearMonth
9f83e49
Merge and extract argument-* tests in ZonedDateTime/from
9dfd5ad
Merge and extract argument-* tests in PlainDateTime/from
60112c0
Merge and extract argument-* tests in PlainMonthDay/from
b0e8885
Corrected a type-error which occured in creation of a file
2e56fc1
Corrected a type-error which occured when renaming a file
47df386
Merge branch 'main' into merge-and-extract-calendar-number-and-wrong-…
brageh01 8d23556
Merge and extract operation for files found in /compare for the tempo…
3ca6287
Fixed syntax issues regarding /compare files for some temporal types
6e4e4b9
Merge and extract for tests in PlainDate/prototype
588a588
Merge and extract for PlainDateTime/prototype equals and since
3b39021
Merge and extract for PlainDateTime/prototype until
2d6491a
Merge and extract for PlainDateTime/prototype withCalendar
b1ad5ef
Merge branch 'main' into merge-and-extract-calendar-number-and-wrong-…
4529ce2
Merge and extract for PlainMonthDay/prototype equals
0bc5d9b
Merge and extract for PlainYearMonth/prototype equals
d513a09
Fixed an error in the header for wrong-type.js in equals
25a6e8e
Merge and extract for PlainYearMonth/prototype since
614260d
Merge and extract for PlainYearMonth/prototype until
brageh01 e289ffa
Merge and extract for ZonedDateTime/prototype equals
brageh01 d668596
Merge and extract for ZonedDateTime/prototype since
brageh01 53caaec
Merge and extract for ZonedDateTime/prototype until
brageh01 a98d02f
Merge and extract for ZonedDateTime/prototype withCalendar
brageh01 b6863aa
Gone over altered files to correct some header mistakes and adjust in…
brageh01 6479588
Update copyright header in Temporal tests
53ffbc6
Merge branch 'main' into merge-and-extract-calendar-number-and-wrong-…
brageh01 7965082
Corrected mistake for invalid-iso-string for withCalendar in PlainDat…
b95e900
Added a missing 'calendar' for a invalid-iso-string.js file
29cc2d7
Merge and extract for Duration/prototype round
1f79b75
Merged lists of types tested as calander ID into one array for PlainDate
06de7c6
Merge branch 'main' into merge-and-extract-calendar-number-and-wrong-…
brageh01 960c5f1
Merged lists of types tested as calandar ID into one array for PlainD…
c9e1b85
Merged lists of types tested as calandar ID into one array for PlainM…
9fc22ca
Merged lists of types tested as calendar ID into one array for PlainY…
brageh01 e84c9cc
Merge branch 'main' into merge-and-extract-calendar-number-and-wrong-…
brageh01 f250834
Merged lists of types tested as calendar ID into one array for ZonedD…
7c39679
Merged lists of types tested as calendar ID into one array for Durati…
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
This file contains hidden or 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
17 changes: 7 additions & 10 deletions
17
...relativeto-propertybag-calendar-number.js → ...ativeto-propertybag-invalid-iso-string.js
This file contains hidden or 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 |
---|---|---|
@@ -1,26 +1,23 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.duration.prototype.total | ||
description: A number as calendar in relativeTo property bag is invalid | ||
description: Various invalid ISO string values for relativeTo.calendar | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.Duration(1, 0, 0, 0, 24); | ||
|
||
const numbers = [ | ||
1, | ||
19970327, | ||
-19970327, | ||
1234567890, | ||
const invalidStrings = [ | ||
["", "empty string"], | ||
]; | ||
|
||
for (const calendar of numbers) { | ||
for (const [calendar, description] of invalidStrings) { | ||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar }; | ||
assert.throws( | ||
TypeError, | ||
RangeError, | ||
() => instance.total({ unit: "days", relativeTo }), | ||
`A number (${calendar}) is not a valid ISO string for relativeTo.calendar` | ||
`${description} is not a valid calendar ID` | ||
); | ||
} |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/PlainDate/calendar-invalid-iso-string.js
This file contains hidden or 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) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plaindate.constructor | ||
description: Various invalid ISO string values for calendar | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
["", "empty string"], | ||
["1997-12-04[u-ca=iso8601]", "ISO string with calendar annotation"], | ||
]; | ||
|
||
for (const [arg, description] of invalidStrings) { | ||
assert.throws( | ||
RangeError, | ||
() => new Temporal.PlainDate(2000, 5, 2, arg), | ||
`${description} is not a valid calendar ID` | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-invalid-iso-string.js
This file contains hidden or 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) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plaindate.from | ||
description: Various invalid ISO string values for calendar in a property bag | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
["", "empty string"], | ||
]; | ||
|
||
for (const [calendar, description] of invalidStrings) { | ||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; | ||
assert.throws( | ||
RangeError, | ||
() => Temporal.PlainDate.from(arg), | ||
`${description} is not a valid calendar ID` | ||
); | ||
} |
24 changes: 0 additions & 24 deletions
24
test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-number.js
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/PlainDateTime/calendar-invalid-iso-string.js
This file contains hidden or 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) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plaindatetime.constructor | ||
description: Various invalid ISO string values for calendar | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
["", "empty string"], | ||
["1997-12-04[u-ca=iso8601]", "ISO string with calendar annotation"], | ||
]; | ||
|
||
for (const [arg, description] of invalidStrings) { | ||
assert.throws( | ||
RangeError, | ||
() => new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg), | ||
`${description} is not a valid calendar ID` | ||
); | ||
} |
14 changes: 0 additions & 14 deletions
14
test/built-ins/Temporal/PlainDateTime/calendar-iso-string.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
21 changes: 21 additions & 0 deletions
21
...built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-invalid-iso-string.js
This file contains hidden or 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) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plaindatetime.from | ||
description: Various invalid ISO string values for calendar in a property bag | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
["", "empty string"], | ||
]; | ||
|
||
for (const [calendar, description] of invalidStrings) { | ||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; | ||
assert.throws( | ||
RangeError, | ||
() => Temporal.PlainDateTime.from(arg), | ||
`${description} is not a valid calendar ID` | ||
); | ||
} |
24 changes: 0 additions & 24 deletions
24
test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-number.js
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/PlainMonthDay/calendar-invalid-iso-string.js
This file contains hidden or 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) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plainmonthday.constructor | ||
description: Various invalid ISO string values for calendar | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
["", "empty string"], | ||
["1997-12-04[u-ca=iso8601]", "ISO string with calendar annotation"], | ||
]; | ||
|
||
for (const [arg, description] of invalidStrings) { | ||
assert.throws( | ||
RangeError, | ||
() => new Temporal.PlainMonthDay(12, 15, arg, 1972), | ||
`${description} is not a valid calendar ID` | ||
); | ||
} |
Oops, something went wrong.
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.
Optional: you could consider adding more cases in tests such as this one. For example: strings that are neither ISO strings nor valid calendar identifiers. (If you decide this is out of scope for this PR, that would be fine, but I'd appreciate if you could open a follow up issue on GitHub in that case.)
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 now see that I have not done the merge and extract for
round
in the same file location which I will do. In regards of your suggestion of adding more cases in tests "such as this one", do you imply only for the relativeto-propertybag files, or all of the calendar-invalid-iso-string files in general?I believe it will be more transparent to create a new issue for this, but I can both create a new issue and start a PR after knowing more specificly which files that are relevant.
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 meant for the calendar-invalid-iso-string files in general. Every file where the only test case is
["", "empty string"]
. I agree, it's fine to create a new issue.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 found an already open issue that covers this topic, I think: #3896