-
Notifications
You must be signed in to change notification settings - Fork 472
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*.inLeapYear #3056
Conversation
assert.sameValue(false, cal.inLeapYear("2025-01-01T00:00:00Z")); | ||
assert.sameValue(false, cal.inLeapYear("2026-03-18T13:00:00Z")); | ||
|
||
assert.sameValue(false, cal.inLeapYear("2019-03")); |
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 block isn't correct - these strings will fail ToTemporalDate.
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.
hum... interesting... so cal.inLeapYear will take PlainYearMonth but not year-month string....
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.
PTAL
description: Temporal.Calendar.prototype.inLeapYear throw RangeError while ISO8601 string is not a date. | ||
and return true or false that year is leap year. | ||
and return Array of the same content. |
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.
@FrankYFTang Looks like some copy pasta?
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'd recommend using the appropriate yaml block format to avoid breaking compatibility of Test262 with many runners using it.
description: Temporal.Calendar.prototype.inLeapYear throw RangeError while ISO8601 string is not a date. | |
and return true or false that year is leap year. | |
and return Array of the same content. | |
description: > | |
Temporal.Calendar.prototype.inLeapYear throw RangeError while ISO8601 string is not a date. | |
and return true or false that year is leap year. | |
and return Array of the same content. |
Even thou, this test is only testing one thing here so the text can be improved too.
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then | ||
a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). | ||
5. Return ! IsISOLeapYear(temporalDateLike.[[ISOYear]]). |
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 test could add the text that throws the RangeError:
ParseTemporalDateString ( isoString )
1. Assert: Type(isoString) is String.
2. If isoString does not satisfy the syntax of a TemporalDateString (see 13.33), then
a. Throw a RangeError exception.
And also the relations to the iso8601 could be valuable here
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 can be shortened by saying there is no syntax produced in the iso8601 grammar section for these format variations that otherwise look like regular dates.
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 is missing coverage beyond superficial API tests. The tests are generally ok other than formating. I don't have specific preference to address everything in a single PR, but early merging this should not consider the coverage as done for the method.
There are many of the spec parts missing here, like testing 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
and all the ends from ToTemporalDate
.
One suggestion, ToTemporalDate
is reused in many parts of Temporal, so I'd suggest having a utility helper in the harness folder that can be reused, maybe as a factory for checking all the points the abstraction might be called by each api.
---*/ | ||
let cal = new Temporal.Calendar("iso8601"); | ||
|
||
assert.sameValue(false, cal.inLeapYear(new Temporal.PlainDateTime(1995, 8, 23, 5, 30, 13))); |
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.
these tests are only touching the surface of inLeapYear and there is so much that could be done with the date validations. One thing that is interesting is verifying some edgy variations of the year, like years that are not the common 4 digit (0, 1, or "0000", "0001" for parsed strings), etc.
There is also so many different types accepted as argument. This should include things such as a new Date
, a regular object, with valid and invalid (true and false returns), and abrupt completions (toPrimitive operations, symbols), and just weird args such as an integer, undefined, null, etc.
This would help guarantee the cross compatibility and avoid surprises.
There is a lot of tests that should also be imported from Temporal. I'm not sure how much they are up to date, but the files give a good base for the necessary coverage too. |
It will be nice if whoever is working on that move import them to test262 ASAP. |
I outlined the plan for moving them over in #3002 (comment) |
(Philip, March 2022: This was originally Frank's PR tc39#3056. I did some reformatting, removed duplicate tests, and combined with some existing tests.)
(Philip, March 2022: This was originally Frank's PR #3056. I did some reformatting, removed duplicate tests, and combined with some existing tests.)
(Philip, March 2022: This was originally Frank's PR tc39#3056. I did some reformatting, removed duplicate tests, and combined with some existing tests.)
(Philip, March 2022: This was originally Frank's PR tc39#3056. I did some reformatting, removed duplicate tests, and combined with some existing tests.)
commit 1c19242 Author: Shu-yu Guo <syg@chromium.org> Date: Wed Apr 13 14:06:45 2022 -0700 Remove check for per-iteration detach check in TypedArray.prototype.set Note that this test currently unintentionally passes, because a TypeError is thrown for failing to convert the undefined returned from the getter to a BigInt. But since this test was intended to test detaching, it's no longer valid and should still be removed. See tc39#3465 (comment) commit 4dafd21 Author: Ms2ger <Ms2ger@gmail.com> Date: Wed Apr 13 15:02:27 2022 +0200 Temporal: Remove some stray arguments to TemporalHelpers.assertDuration. commit c35ae20 Author: Ms2ger <Ms2ger@gmail.com> Date: Wed Apr 13 18:31:57 2022 +0200 Temporal: Some more tests for PlainDateTime#with. (tc39#3481) commit d9616ed Author: Philip Chimento <pchimento@igalia.com> Date: Fri Apr 8 16:30:39 2022 -0700 Add tests for direction of rounding functionality The round() and toString() methods of Temporal.Instant, PlainDateTime, and ZonedDateTime can round up or down. However, the instance must not be treated as "negative" even when the time is before 1 BCE (years are negative) or before the Unix epoch (epoch nanoseconds are negative). That is, rounding down is always towards the Big Bang, and rounding up is always away from it. Add tests that verify this. commit 3905c0c Author: Philip Chimento <pchimento@igalia.com> Date: Fri Apr 8 11:39:40 2022 -0700 Expand toString() rounding tests from PlainTime to cover other types This takes the tests of the rounding functionality of Temporal.PlainTime.p.toString() and adds similar tests covering the equivalent functionality to Duration, Instant, PlainDateTime, and ZonedDateTime: all the types that have rounding and precision controls for how they output their subsecond values. It also takes the opportunity to improve the existing PlainTime tests: - fractionalseconddigits-auto.js: More descriptive variable names. Added assertion messages. - fractionalseconddigits-number.js: Ditto. - rounding-cross-midnight.js: Use constructor directly to remove coupling with from(). - roundingmode-*.js: Add additional tests for specifying the precision using fractionalSecondDigits. - smallestunit-fractionalseconddigits.js: Add assertion messages. commit 4ac16c2 Author: Philip Chimento <pchimento@igalia.com> Date: Fri Apr 8 10:52:39 2022 -0700 Add tests for Temporal options bags being of the wrong type This consolidates the few existing tests for options bags in Temporal being of the wrong type, and adds them for every entry point in Temporal that accepts an options bag. These are mostly identical tests, but there is a variation for methods like round() where either an options bag or string is accepted. commit 9f30311 Author: Philip Chimento <pchimento@igalia.com> Date: Thu Apr 7 18:32:15 2022 -0700 Repeat Instant.p.toString() test with timeZone parameter for IANA time zones This adds to the intl402/ tree a copy of built-ins/Temporal/Instant/prototype/toString/timezone-offset.js but which uses IANA time zones. commit 9b2c98c Author: Philip Chimento <pchimento@igalia.com> Date: Thu Apr 7 18:27:47 2022 -0700 Bring existing "invalid string" tests for smallestUnit and largestUnit in sync Add a consistent set of invalid strings for all of the smallestunit-invalid-string.js and largestunit-invalid-string.js tests: - "era" and "eraYear" in singular and plural - all of the units that are disallowed for that particular method call, in singular and plural - an allowed unit with \0 at the end - an allowed unit with an "i" replaced by a dotless i - an allowed unit but with all-caps - an unrelated string. commit b4c0aed Author: Philip Chimento <pchimento@igalia.com> Date: Thu Apr 7 16:54:51 2022 -0700 Bring existing toString options tests in sync with each other Of the toString() methods that have options for printing a time with seconds and fractional seconds, PlainTime seems to have the most comprehensive set of tests. Bring all the others (Duration, Instant, PlainDateTime, and ZonedDateTime) in sync with PlainTime, and edit the PlainTime ones where necessary to include improvements from the others. Tests: - fractionalseconddigits-invalid-string.js: copy and expand on PlainTime's more comprehensive set of invalid strings. Add assertion message. Fix front matter. - fractionalseconddigits-non-integer.js: Fix front matter. - fractionalseconddigits-out-of-range.js: make sure infinity is tested. Add assertion messages. Fix front matter. - fractionalseconddigits-undefined.js: copy PlainTime's more comprehensive test with whole minutes, whole seconds, and subseconds. Copy PlainTime's test of an empty function object. Add more descriptive variable names and assertion messages. Fix front matter. - fractionalseconddigits-wrong-type.js: inline and delete TemporalHelper used here; it was only good for this test anyway. Improve assertion messages. - smallestunit-valid-units.js: copy PlainTime's test with a second value with zero seconds even. Refactor repetitive tests into a loop. Copy the invalid unit "era" from the Instant test. Add assertion messages. commit 2c880bf Author: Ms2ger <Ms2ger@gmail.com> Date: Tue Apr 12 11:34:57 2022 +0200 Temporal: Some more tests for PlainDateTime.compare. commit a226601 Author: Ms2ger <Ms2ger@gmail.com> Date: Tue Apr 12 17:32:18 2022 +0200 Temporal: Some more tests for PlainDateTime#withPlainDate. commit 7823be3 Author: Ms2ger <Ms2ger@gmail.com> Date: Tue Apr 12 17:21:24 2022 +0200 Temporal: Move test with typo in name. commit 62e0130 Author: Ms2ger <Ms2ger@gmail.com> Date: Tue Apr 12 19:02:53 2022 +0200 Temporal: Some more tests for PlainDateTime#equals. (tc39#3479) commit 5f1aba6 Author: Jesse Alama <jessealama@users.noreply.github.com> Date: Tue Apr 12 17:36:03 2022 +0200 Temporal: Port Demitasse PlainDateTime `round` tests (tc39#3478) Co-authored-by: Ms2ger <Ms2ger@gmail.com> commit 9055521 Author: rwaldron <waldron.rick@gmail.com> Date: Mon Apr 11 13:08:37 2022 -0400 ShadowRealm: fix for incorrect test commit d4ede37 Author: Mike Pennisi <mike@mikepennisi.com> Date: Fri Apr 8 20:37:17 2022 -0400 Add assertions for functions with infinite length A prior version of ECMA262 described invalid mathematical operations with infinite values [1]. Update the test metadata to reflect the corrected specification text, and add two assertions for the obsolete conditions. [1] ".bind on a function with infinite length has imprecise spec and engine divergences" tc39/ecma262#2170 commit 24e4eb0 Author: rwaldron <waldron.rick@gmail.com> Date: Mon Apr 11 10:16:36 2022 -0400 ShadowRealm: add more tests for globalThis ordinary object conformance commit d7c0a20 Author: Shu-yu Guo <syg@chromium.org> Date: Mon Apr 4 16:36:56 2022 -0700 Remove check for per-comparator call detach check in TypedArray.prototype.sort This updates tests in line with the normative change in tc39/ecma262#2723 commit 3ac6b73 Author: Shu-yu Guo <syg@chromium.org> Date: Mon Apr 4 16:42:58 2022 -0700 Add test that TypedArray.prototype.set doesn't throw if a getter for an element detaches commit 8b29141 Author: Shu-yu Guo <syg@chromium.org> Date: Mon Apr 4 15:44:22 2022 -0700 Remove check for per-iteration detach check in TypedArray.prototype.set This updates tests in line with the normative change in tc39/ecma262#2646 commit f60d7cf Author: rwaldron <waldron.rick@gmail.com> Date: Tue Apr 5 11:18:45 2022 -0400 fixup! Fix false negative in for-in test commit 384a4e1 Author: rwaldron <waldron.rick@gmail.com> Date: Tue Apr 5 11:18:10 2022 -0400 Fix false negative in for-in test As originally written, this test would spuriously pass when the deleted property was incorrectly visited by enumation but correctly removed from the object. In such cases, the accumulator string would take the form "aa1baundefinedca3" And satisfy all conditions intended to highlight implementation errors. Refactor the test to avoid false negative by using an object with a null prototype and verifying the exact contents of the accumulator string. commit 3c88e9b Author: Mike Pennisi <mike@mikepennisi.com> Date: Fri Apr 1 18:16:06 2022 -0400 Fix false negative in for-in test As originally written, this test would spuriously pass when the deleted property was incorrectly visited by enumation but correctly removed from the object. In such cases, the accumulator string would take the form "aa1baundefinedca3" And satisfy all conditions intended to highlight implementation errors. Refactor the test to avoid false negative by using an object with a null prototype and verifying the exact contents of the accumulator string. commit 833a784 Author: Philip Chimento <pchimento@igalia.com> Date: Thu Mar 31 18:16:17 2022 -0700 Tests for computing PlainYearMonth addition and subtraction in correct calendar space tc39/proposal-temporal#2003 is a normative change that reached consensus at the March 2022 TC39 plenary meeting. This adds tests that verify the new spec text is implemented correctly, performing arithmetic on a PlainYearMonth instance that would previously have thrown an error if it was implemented as written. commit c58ac69 Author: Richard Gibson <richard.gibson@gmail.com> Date: Fri Mar 25 08:35:50 2022 -0400 Test that "infinity" is not recognized as numeric commit c572588 Author: Richard Gibson <richard.gibson@gmail.com> Date: Thu Mar 24 16:52:05 2022 -0400 Test that "INFINITY" is not recognized as numeric Fixes tc39#3442 commit 51822ff Author: Shu-yu Guo <syg@chromium.org> Date: Thu Mar 31 16:37:06 2022 -0700 Update Symbol.species tests for TypedArray constructor This updates tests in line with tc39/ecma262#2719 commit da507a7 Author: Philip Chimento <pchimento@igalia.com> Date: Thu Mar 31 12:36:06 2022 -0700 Tests for Temporal formatting the year appropriately as 4 or 6 digits tc39/proposal-temporal#2090 is a normative change that reached consensus at the March 2022 TC39 plenary meeting. This adds tests that verify the change made to the formatting of years between 0 and 999 inclusive in all toString and toJSON methods of Temporal types that can output an ISO year number in their return value. commit cdcf2a3 Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 11:50:58 2021 -0700 Add tests for Temporal.Calendar.p*.inLeapYear (Philip, March 2022: This was originally Frank's PR tc39#3056. I did some reformatting, removed duplicate tests, and combined with some existing tests.) commit 16aefcc Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 12:08:18 2021 -0700 Add tests for Temporal.Calendar.p*.mergeFields (Philip, March 2022: This was originally Frank's PR tc39#3057. I did some reformatting, removed duplicate tests, addressed the review comments that I left the first time around, and added some cases that I felt were not yet complete.) commit 6bae30c Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 13:31:55 2021 -0700 Add tests for Temporal.Calendar.p*.monthDayFromFields (Philip, March 2022: This was originally Frank's PR tc39#3058. I did some reformatting, removed duplicate tests, and combined with some existing tests.) commit c22b8ab Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 13:45:21 2021 -0700 Add tests for Temporal.Calendar.p*.monthsInYear (Philip, March 2022: This was originally Frank's PR tc39#3059. I did some reformatting, removed duplicate tests, and combined with some existing tests.) commit b064eb6 Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 14:00:42 2021 -0700 Add tests for Temporal.Calendar.p*.weekOfYear (Philip, March 2022: This was originally Frank's PR tc39#3060. I did some reformatting, removed a test that didn't exercise the whole feature, and combined some duplicate tests with some existing tests.) commit ac19506 Author: Philip Chimento <pchimento@igalia.com> Date: Tue Feb 1 15:38:24 2022 -0800 Add tests ensuring that observable calls are made with options === undefined Where possible, observable calls originating from within Temporal, that require an options argument, should pass `undefined` as that options argument, rather than `{}` or `Object.create(null)`. See tc39/proposal-temporal#1685. commit 16ad841 Author: Philip Chimento <pchimento@igalia.com> Date: Wed Feb 2 16:42:53 2022 -0800 Fix arithmetic in TemporalHelpers.oneShiftTimeZone I made a mistake with one of the signs in one of the time zones that we use for verifying DST handling. Luckily this didn't affect any previously existing tests, but it affected some new tests that I'm going to add in the next commit. How do I know that _this_ arithmetic is correct? I feel reasonably confident with the added test. commit 276e79d Author: Mike Pennisi <mike@mikepennisi.com> Date: Fri Mar 25 19:47:14 2022 -0400 Deprecate some property helpers Document the preference for `verifyProperty` over the various other property-related helper functions. commit 5eb7dfb Author: jugglinmike <mike@mikepennisi.com> Date: Mon Apr 4 11:27:22 2022 -0400 Remove configuration file for third-party tool (tc39#3450) The `.jshintrc` file configures the JavaScript "linting" tool named JSHint. Test262 does not depend on that tool, making the file's purpose and validity ambiguous and potentially distracting. commit 926b096 Author: Romulo Cintra <romulocintra@users.noreply.github.com> Date: Thu Mar 31 23:53:20 2022 +0200 update nfv3 test for roundingIncrement (tc39#3441) commit 4c7c246 Author: Jesse Alama <jessealama@users.noreply.github.com> Date: Wed Mar 30 17:33:52 2022 +0200 Check a variety of offset Etc/GMT timezones (tc39#3403) Tests for normative change tc39/proposal-temporal#2050 commit fe40aea Author: Jesse Alama <jesse@serverracket.com> Date: Mon Feb 21 14:14:44 2022 +0100 Emit fallback day 1 commit 9aaa22c Author: Jesse Alama <jesse@serverracket.com> Date: Mon Feb 21 14:06:52 2022 +0100 Ensure fallback years values are present commit ee1f962 Author: Jesse Alama <jesse@serverracket.com> Date: Fri Feb 4 08:50:10 2022 +0100 Ensure reference data is emitted when calendarName = 'always' References: + tc39/proposal-temporal#1971 commit 76b0baf Author: Jesse Alama <jessealama@users.noreply.github.com> Date: Fri Feb 11 09:21:10 2022 +0100 Update test/built-ins/Temporal/Duration/compare/twenty-five-hour-day.js Co-authored-by: Philip Chimento <philip.chimento@gmail.com> commit 2aa754b Author: Jesse Alama <jesse@serverracket.com> Date: Thu Feb 3 11:54:45 2022 +0100 Add test for DST balancing References: + tc39/proposal-temporal#1791 Thanks @ptomato for the suggestion to use `springForwardFallBackTimeZone`. commit 3ab8adc Author: Richard Gibson <richard.gibson@gmail.com> Date: Wed Mar 23 00:17:23 2022 -0400 Require String.prototype.localeCompare to check for canonical equivalence commit 3eea1a7 Author: Philip Chimento <pchimento@igalia.com> Date: Thu Mar 24 16:37:19 2022 -0700 Add tests for various invalid ISO strings for PlainDate These tests check API entry points that convert strings to Temporal.PlainDate, with a list of various strings that are all not valid for that context according to ISO 8601. commit ad74a4e Author: Philip Chimento <pchimento@igalia.com> Date: Thu Mar 24 16:32:06 2022 -0700 Rename some "argument-string" tests to be more specific I'd like to add basic functionality tests for string arguments, and these tests are testing something more specific: that a Get of the "overflow" property on the passed-in options object is observable. Rename accordingly. commit 52af2b6 Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 14:26:11 2021 -0700 Add tests for Temporal.Calendar.p*.yearMonthFromFields (Philip, March 2022: This was originally Frank's PR tc39#3061. I did some reformatting, removed duplicate tests, and combined with some existing tests.) commit 0bad719 Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 14:50:02 2021 -0700 Add test for Temporal.Duration.p*.abs (Philip, March 2022: This was originally Frank's PR tc39#3062. I did some reformatting and removed duplicate tests) commit f23602f Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 14:59:43 2021 -0700 Add test for Temporal.Duration.p*.negated (Philip, March 2022: This was originally Frank's PR tc39#3063. I did some reformatting and removed duplicate tests) commit b8af7ff Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 15:10:08 2021 -0700 Add test for Temporal.Duration.p*.toJSON (Philip, March 2022: This was originally Frank's PR tc39#3064. I did some reformatting and removed duplicate tests) commit 2c8b69f Author: Frank Tang <ftang@chromium.org> Date: Mon Jul 19 15:32:37 2021 -0700 Add tests for Temporal.Duration.p*.with (Philip, March 2022: This was originally Frank's PR tc39#3065. I did some reformatting, removed duplicate tests, and combined with some existing tests.) commit f59bafa Author: Iban Eguia Moraza <razican@protonmail.ch> Date: Mon Mar 28 21:22:05 2022 +0200 Fixed YAML in some new test metadata commit 99b2a70 Author: Jesse Alama <jessealama@users.noreply.github.com> Date: Sat Mar 26 01:13:17 2022 +0100 Use ECMAScript version 11 (tc39#3448) We use BigInt syntax in a bunch of tests. This change registers that fact with linters that use `.jshintrc`. commit f964584 Author: Ms2ger <Ms2ger@gmail.com> Date: Fri Mar 25 13:25:54 2022 +0100 Expand overflow-invalid-string.js tests.
(Philip, March 2022: This was originally Frank's PR tc39#3056. I did some reformatting, removed duplicate tests, and combined with some existing tests.)
#3002 @jugglinmike @ryzokuken @Ms2ger