Commit Graph

430 Commits

Author SHA1 Message Date
Philip Chimento ae52931aae Temporal: Add TemporalHelpers.calendarObserver
Similar to the previous commits with property bags and time zones, there
are also some existing tests that use a Proxy to test the order of
observable operations which involve user code
passed in as part of a Temporal.TimeZone object. I am going to write
several more tests that do this, as well. This seems like a good thing to
put into TemporalHelpers, where it can be implemented consistently so that
we don't get discrepancies in which operations are tracked, or bugs due to
a Symbol-valued property.

Updates existing tests to use this helper.
2022-10-05 16:53:52 +02:00
Philip Chimento 12f919e45d Temporal: Add TemporalHelpers.timeZoneObserver
Similar to the previous commit with property bags, many existing tests use
a Proxy to test the order of observable operations which involve user code
passed in as part of a Temporal.TimeZone object. I am going to write
several more tests that do this, as well. This seems like a good thing to
put into TemporalHelpers, where it can be implemented consistently so that
we don't get discrepancies in which operations are tracked.

Updates existing tests to use this helper.
2022-10-05 16:53:52 +02:00
Philip Chimento 534b94eb63 Temporal: Add tests for calendar validation normative change
This adds tests for the normative change in tc39/proposal-temporal#2265,
which adds validation steps to certain abstract operations that call
Temporal.Calendar methods.

These had some duplication with some existing tests named
calendar-returns-infinity.js. Remove these, because the new tests are more
complete in testing what values are accepted.
2022-10-05 15:53:24 +02:00
Philip Chimento b83af50771 Temporal: Adapt existing custom calendar getter tests, and expand
The existing tests would fail after making the normative change from
tc39/proposal-temporal#2265 because they rely on the getter directly
returning whatever value the calendar method returned. This is no longer
the case, because the value returned by the calendar is validated, so
adjust the assertions in these tests.

Also, no longer any need to return a value from the calendar method that
needs to be converted; we'll add separate tests for that.

Expand these tests to cover all of the PlainDate, PlainDateTime,
PlainMonthDay, PlainYearMonth, and ZonedDateTime property getters that
delegate to the calendar methods.
2022-10-05 15:53:24 +02:00
Philip Chimento 89116e95dd Temporal: Add some assertion messages to help with debugging 2022-10-03 15:58:21 -07:00
André Bargull e292fb80de Import SpiderMonkey Temporal tests
Temporal tests written for the SpiderMonkey implementation. Mostly
covers edge cases around mathematical operations and regression tests
for reported spec bugs.
2022-10-03 15:58:21 -07:00
Philip Chimento c44b6e3e76 Temporal: Add assertion messages to PlainTime/p/{add,subtract}/argument-object.js
This made debugging these tests easier.
2022-09-28 16:41:39 +02:00
André Bargull eaf85892fb Import SpiderMonkey Temporal tests
Temporal tests written for the SpiderMonkey implementation. Mostly
covers edge cases around mathematical operations and regression tests
for reported spec bugs.
2022-09-28 16:41:39 +02:00
Philip Chimento 8565eea8be Temporal: Test tiebreaker rounding modes more thoroughly
The "half___" modes all round to the nearest increment except when there
is a tie. The previous tests didn't test rounding in the case of any ties
(except for .toString()) so here we use some different numbers in which
there is a tie, in order to make tests where the "half___" modes are more
thoroughly tested.

See https://github.com/tc39/proposal-temporal/pull/2262 which added new
rounding modes from NumberFormat V3.
2022-09-21 11:48:28 +02:00
Philip Chimento c84e5701cd Temporal: Add tests for new rounding modes
See https://github.com/tc39/proposal-temporal/pull/2262 which added new
rounding modes from NumberFormat V3.

These tests use the same format as the previous ones. The tests for the
"half" rounding modes aren't very good yet, as they don't show any of the
differences between the tiebreaking schemes; there aren't any ties in the
data to be broken. (Except in .toString().) A subsequent commit will
correct this.
2022-09-21 11:48:28 +02:00
Philip Chimento 4155842c37 Temporal: Regularize and expand tests for round() rounding modes
Take all the existing tests for round() calculations using different
rounding modes and standardize them. Add tests for Duration, Instant and
ZonedDateTime, which were still in the old format in staging.
2022-09-21 11:48:28 +02:00
Philip Chimento a788188c2f Temporal: Regularize and expand tests for difference rounding modes
Take all the existing tests for since/until calculations using different
rounding modes and standardize them. Add tests for Instant and
ZonedDateTime, which were still in the old format in staging.
2022-09-21 11:48:28 +02:00
Philip Chimento 9c4aed29b7 Temporal: Remove now-valid rounding modes from roundingmode-invalid-string tests
See https://github.com/tc39/proposal-temporal/pull/2262, which reached
consensus in the July 2022 TC39 meeting. This change added several
rounding modes from the NumberFormat V3 proposal, some of which were
listed as invalid in the roundingmode-invalid-string tests. Remove these
items from the list of invalid modes, since they are no longer invalid.
2022-09-21 11:48:28 +02:00
Philip Chimento ef59ea225a Temporal: Add TemporalHelpers.propertyBagObserver()
Many existing tests use a Proxy to test the order of observable operations
on a property bag argument that gets passed in to a Temporal API. I am
going to write several more tests that do this, as well. This seems like a
good thing to put into TemporalHelpers, where it can be implemented
consistently so that we don't get discrepancies in which operations are
tracked. (For example, we had some tests which didn't test for an ownKeys
operation that was supposed to be there.)

Updates existing tests to use this helper.
2022-09-21 10:41:14 +02:00
Philip Chimento 8b5dc0b1ef Temporal: Consistently test that calendar is copied in X.from()
We did this inconsistently in PlainDate and ZonedDateTime, and not in the
other calendar-carrying types. Additionally, we don't have to create the
calendar explicitly in PlainDate.
2022-09-21 10:41:14 +02:00
Frank Yung-Fong Tang e17d44db65
Split withCalendar/calendar-case-insensitive.js to intl402 (#3670) 2022-09-20 10:24:48 +02:00
Philip Chimento 58a9cdc426 Temporal: Test new limits for user code return from getOffsetNanosecondsFor
This tests the normative change from
https://github.com/tc39/proposal-temporal/pull/2260
which achieved consensus in the July 2022 TC39 meeting.

The return value from a userland getOffsetNanosecondsFor method is no
longer allowed to be exactly one 24-hour day.
2022-09-16 13:41:08 +02:00
Philip Chimento 31ad95d34e Temporal: Add more getOffsetNanosecondsFor validation tests
This adds tests that validate a user-callable getOffsetNanosecondsFor to
several APIs that didn't test this yet: ZonedDateTime.since/until, and
Calendar.era/eraYear.
2022-09-16 13:41:08 +02:00
Philip Chimento 65b51e0769 Temporal: Override getPossibleInstantsFor to narrow down exception
In order for some tests to ensure that they are testing the right
exception, we need to make sure we are in the path where there are no
possible instants for a particular date-time. Override this method in some
tests.
2022-09-16 13:41:08 +02:00
Philip Chimento ce2061eccd Temporal: Adjust order of operations in Calendar.___fromFields
This implements the normative change in
https://github.com/tc39/proposal-temporal/pull/2377 which reached
consensus at the September 2022 TC39 meeting.

It changes the order in which observable operations are performed on the
values passed to the ___fromFields methods of Calendar.
2022-09-15 11:04:37 +02:00
Philip Chimento e391176717 Apply suggestions from code review 2022-09-13 11:32:16 -07:00
Aditi c6b62110f9 Added intl tests for timezone and calendar case insensitivity 2022-09-13 11:32:16 -07:00
Aditi d7181a5866 Add timezone case insensitive tests 2022-09-13 11:32:16 -07:00
Aditi cf51de578f Add calendar case insensitive tests 2022-09-13 11:32:16 -07:00
Philip Chimento 051631f58b Temporal: Start moving collections of valid/invalid strings into TemporalHelpers
This adds an object, TemporalHelpers.ISO, which has methods that return
arrays of various ISO strings. The idea is to deduplicate more string
tests into methods on this object.
2022-08-31 08:59:33 -07:00
Philip Chimento ddef61a106 Temporal: Deduplicate strings-with-calendar from strings-without-calendar
The strings with calendar annotations in these tests don't need to be
listed separately, they can be derived from the original strings.
2022-08-31 08:59:33 -07:00
Philip Chimento 409d6dc71a Temporal: Add tests for PlainTime string disambiguation with calendar
This implements the normative change in
https://github.com/tc39/proposal-temporal/pull/2287 which reached
consensus at the July 2022 TC39 meeting.

It adds tests that ensure that PlainTime strings which require a T
designator for disambiguation, are not disambiguated by adding a calendar
annotation.
2022-08-31 08:59:33 -07:00
Philip Chimento d8e8529e8d Temporal: Add tests for PlainTime string disambiguation with time zone
This implements the normative change in
https://github.com/tc39/proposal-temporal/pull/2284 which reached
consensus at the July 2022 TC39 meeting.

It adds tests that ensure strings like HHMM-UU[TZ] and HHMMSS[TZ] do not
require a disambiguating T separator, even if HHMM-UU and HHMMSS would by
themselves.
2022-08-31 08:59:33 -07:00
Aditi 8dcc0e1955 Add calendar strings to instant string tests 2022-08-25 10:14:30 -07:00
Philip Chimento c4daf3ef74 Temporal: Add test for rounding Duration relative to Feb 1 in a leap year
This implements the normative change in
https://github.com/tc39/proposal-temporal/pull/2344 which reached
consensus at the July 2022 TC39 meeting.

It adds a test that catches a corner case in Duration.prototype.round().
2022-08-11 12:57:37 -07:00
Aditi e9f424b6fc Remove duplicate timezone tests 2022-08-04 11:03:46 +02:00
Philip Chimento 10a5c4f784 Temporal: Adjust and expand tests for observable calls to ToString(calendar)
This implements the normative change in
https://github.com/tc39/proposal-temporal/pull/2269 which reached
consensus at the July 2022 TC39 meeting.

There was already a test for PlainDate for this topic, which needs to be
adjusted to accommodate the normative change. Tests for PlainDateTime and
ZonedDateTime did not yet exist, so add new ones based on the PlainDate
test.
2022-08-03 14:23:40 +02:00
André Bargull 5d3d39ee16 Remove tests which use negative day lengths
There are already tests to reject negative day lengths, so we can simply
remove these other tests.

Also remove a misleading comment ("Test negative divisor"), because the
test following the comment actually uses a positive divisor.
2022-08-01 14:13:30 -07:00
André Bargull 30091032c1 Import SpiderMonkey Temporal tests
Temporal tests written for the SpiderMonkey implementation. Mostly
covers edge cases around mathematical operations and regression tests
for reported spec bugs.
2022-08-01 14:13:30 -07:00
Philip Chimento 6685c6c81c Temporal: Add tests for casting a calendar ID string to a Temporal.Calendar
This adds tests to every entry point where a Temporal.Calendar is
accepted, making sure that a calendar ID string is also accepted.
2022-08-01 13:48:11 -07:00
Philip Chimento bc0e006de4 Temporal: Add tests for casting a time zone ID string to a Temporal.TimeZone
This adds tests to every entry point where a Temporal.TimeZone is
accepted, making sure that a time zone ID string is also accepted.
2022-08-01 13:48:11 -07:00
Philip Chimento 6b5297a142 Temporal: Add tests for invalid strings as values of 'offset' property
(...in property bags; the 'offset' option in an options object already has
tests)
2022-08-01 13:48:11 -07:00
Aditi f932f079b3 Add test for Temporal.Duration.prototype.total 2022-08-01 09:59:27 -07:00
Aditi b37d74191a Add tests for wrong argument type in Temporal.TimeZone 2022-08-01 09:56:22 -07:00
Philip Chimento e48df0b964 Temporal: Adjust tests for non-integer/out-of-range values of fractionalSecondDigits
This implements the normative change in
https://github.com/tc39/proposal-temporal/pull/2297 which reached
consensus at the July 2022 TC39 meeting.

Values given as the fractionalSecondDigits option are now truncated to
integers before they are compared to the allowable range.
2022-07-29 15:05:41 -07:00
Aditi 6fa1bb89a3 Added tests for an empty or a function options object 2022-07-28 11:59:50 -07:00
André Bargull bea421c1dc Update tests which used negative day lengths
Negative day lengths are no longer valid after
<https://github.com/tc39/proposal-temporal/pull/2261>.
2022-07-27 08:48:49 -07:00
Philip Chimento 75c877e5ca Temporal: test for out-of-range in Temporal.PlainMonthDay constructor
The refISOYear argument in the Temporal.PlainMonthDay constructor can
cause a RangeError if it is outside the supported range for PlainDate.

This is part of a normative PR that reached consensus at the July 2022
TC39 plenary:
https://github.com/tc39/proposal-temporal/pull/2266
2022-07-25 13:34:08 -07:00
Aditi dadf18f416 Add tests for temporalDurationLike argument and improve existing tests 2022-07-25 13:30:46 -07:00
André Bargull a3040a5047 Import SpiderMonkey Temporal tests
Temporal tests written for the SpiderMonkey implementation. Mostly
covers edge cases around mathematical operations and regression tests
for reported spec bugs.
2022-07-19 11:30:43 -07:00
Ms2ger b8d4c12698 Temporal: Add test for custom fields in PlainDate.from. 2022-07-11 13:40:24 -07:00
Aditi caaeb2bc90 Replace %%%conversion_target%%% with PlainDate 2022-07-11 15:32:23 +02:00
Ms2ger 3ddfa0cd13 Temporal: Test that Calendar#dateAdd is called with the correct arguments. 2022-07-04 11:30:02 -06:00
Philip Chimento 704c9cea9c Temporal: Test validation of overflow option for conversion fast paths
A normative change that reached consensus at the June 2022 TC39 meeting
was this small change to throw on an invalid value for the overflow option
in PlainDate.from() and PlainDateTime.from(), in the case of a fast-path
conversion.

See https://github.com/tc39/proposal-temporal/pull/2225
2022-07-01 10:29:18 +02:00
Philip Chimento f6179a6eb6 Temporal: Test observable calendar.mergeFields() calls with null-prototype objects
As of https://github.com/tc39/proposal-temporal/pull/2219 the arguments to
the calendar.mergeFields() methods should be null-prototype objects when
called from with() and toPlainDate() methods. This adds tests for that
behaviour.
2022-06-27 13:51:58 +02:00
Philip Chimento f314ecb9f4 Temporal: Test observable calls on fields object from PrepareTemporalFields
As of https://github.com/tc39/proposal-temporal/pull/2219 the object
returned from the PrepareTemporalFields abstract operation should be a
null-prototype object. There are a number of places where this is
observable in one of the calendar's ...FromFields() methods. This adds
tests for this behaviour everywhere it is observable.
2022-06-27 13:51:58 +02:00
Philip Chimento ca74e801b2 Temporal: Test observable calendar.yearMonthFromFields() calls with null-prototype options
As of https://github.com/tc39/proposal-temporal/pull/2219 PlainYearMonth's
add() and subtract() methods should be calling the calendar's
yearMonthFromFields() method with a null-prototype object as the options
parameter, due to the change in
AddDurationToOrSubtractDurationFromPlainYearMonth. This adds a test for
this behaviour.
2022-06-27 13:51:58 +02:00
Philip Chimento 0c33b09337 Temporal: Test observable calendar.dateUntil() calls with null-prototype options
As of https://github.com/tc39/proposal-temporal/pull/2219 since() and
until() methods should be calling the calendar's dateUntil() method with a
null-prototype object as the options parameter, due to the change in
MergeLargestUnitOption. This adds a test for this behaviour.
2022-06-27 13:51:58 +02:00
Ms2ger 5e564b96e7 Temporal: Fix typo in description. 2022-06-25 19:56:03 +02:00
Ms2ger 079a7eac7a Temporal: Fix typo in ZonedDateTime/from/offset-wrong-type.js. 2022-06-25 19:55:37 +02:00
Ms2ger 8123e8fc34 Temporal: Add missing Number checks in overflow-wrong-type.js. 2022-06-25 19:54:57 +02:00
Philip Chimento babd46c40a Add tests for Temporal.Instant strings at the edge of the range
This adds tests for a normative change which reached consensus in the June
2022 TC39 meeting, ensuring that the representable range of
Temporal.Instant is always the same regardless of which time zone offset
is used when converting from a string.

See: https://github.com/tc39/proposal-temporal/pull/2189
2022-06-22 09:28:14 +02:00
Ms2ger 81836ba124
Temporal: Test PlainDate#{add,subtract} with custom calendar. 2022-06-21 16:26:58 +02:00
Ms2ger b1020c50b7
Temporal: Extend PlainDate#toPlainDateTime coverage. (#3582) 2022-06-20 07:33:59 -07:00
Ms2ger 65e75e4eed
Temporal: Extend PlainDate#{since,until} coverage. (#3581) 2022-06-20 06:47:09 -07:00
Ms2ger d5b2c706cf Update test/built-ins/Temporal/PlainDate/prototype/with/custom.js 2022-06-20 15:30:02 +02:00
Ms2ger 8eadab4d0b Update test/built-ins/Temporal/PlainDate/prototype/with/custom.js 2022-06-20 15:30:02 +02:00
Ms2ger bdd4bfa619 Update test/built-ins/Temporal/PlainDate/prototype/with/calendar-invalid-return.js
Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
2022-06-20 15:30:02 +02:00
Ms2ger 1a9f64cda3 Temporal: Extend PlainDate#with coverage. 2022-06-20 15:30:02 +02:00
Ms2ger 9762bc991f Temporal: Make branding tests more robust. 2022-06-20 13:14:35 +02:00
Ms2ger 080e893e21 Temporal: Standardize branding tests. 2022-06-20 13:14:35 +02:00
Ross Kirsling a3f09ea074 Temporal: Add missing feature flag for prototype.constructor tests. 2022-06-17 09:15:47 +02:00
André Bargull f169ba6ec7 Add tests for TemporalInstantString with bracketed time zone annotation 2022-06-16 15:03:30 +02:00
Ms2ger b1f49b5c46 Update test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime.js
Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
2022-06-14 16:45:56 +02:00
Ms2ger 820461ef4b Temporal: Extend tests for PlainDate.compare. 2022-06-14 16:45:56 +02:00
Philip Chimento ee7055121d Temporal: Add tests for invalid Temporal.Instant strings
This adds tests to all entry points where an ISO string is converted to a
Temporal.Instant. The tests exercise various invalid ISO strings to make
sure that they throw a RangeError.
2022-06-14 15:56:06 +02:00
Philip Chimento 0e86baf6f3
Temporal: Add tests for order of observable operations in *FromFields methods (#3568)
This adds tests for https://github.com/tc39/proposal-temporal/pull/2203
which was a normative change that reached consensus in the June 2022 TC39
plenary meeting.

Co-authored-by: Ms2ger <Ms2ger@gmail.com>
2022-06-14 15:46:16 +02:00
Ms2ger 697784363f Temporal: Add toZonedDateTime tests. 2022-06-13 17:57:54 +02:00
Ms2ger 6f2e6872fb
Temporal: Extend tests for getISOFields. (#3560) 2022-06-13 08:55:55 -07:00
Ms2ger 98b76ef533 Temporal: Extend tests for PlainDate#toPlainMonthDay. 2022-06-13 17:52:34 +02:00
Ms2ger e6b7323614 Temporal: Extend tests for PlainDate#toPlainYearMonth. 2022-06-13 17:51:29 +02:00
Ms2ger 3812a1fe92 Temporal: Extend tests for PlainDate#toString. 2022-06-13 16:47:22 +02:00
Ms2ger 194f7426f9 Temporal: Add basic test for PlainDate#toJSON. 2022-06-13 16:45:42 +02:00
Ms2ger f9a5a8b29c Temporal: Extend test for withCalendar. 2022-06-13 16:38:07 +02:00
Ms2ger 56ed1a0f82 Temporal: Test custom calendar operations. 2022-06-13 16:37:06 +02:00
Ms2ger da19e0a50c Temporal: Add some Instant string tests. 2022-06-13 16:29:52 +02:00
Ms2ger 267aab37c2 Temporal: Add missing valueOf tests. 2022-06-13 16:27:28 +02:00
Ms2ger bb926a1796 Temporal: Extend tests for daysInMonth. 2022-06-13 16:26:08 +02:00
Ms2ger 3343e15083 Temporal: Test daysInWeek when the week spans across years. 2022-06-13 16:24:44 +02:00
André Bargull b2f7dc1194 Expect precise result for negative fractional units
Fixes #3544
2022-06-08 17:04:45 +02:00
André Bargull c61a04fd88 AddDurationToOrSubtractDurationFromPlainYearMonth doesn't add "month" to calendar fields
Fixes #3546
2022-06-08 17:02:33 +02:00
Ms2ger 53d6cd6d46 Temporal: Add tests for converting a ZonedDateTime to a PlainDate. 2022-06-02 08:50:05 +02:00
Iban Eguia Moraza 53df4bc69a
Fixed #3545 2022-05-31 16:28:31 +02:00
Ms2ger f7b626133d Temporal: Add tests for prototype.constructor. 2022-05-26 10:34:10 +02:00
Ms2ger ed5ada3e13 Temporal: Improve coverage for PlainDate constructor and from(). 2022-05-25 11:39:05 -07:00
Ms2ger 1aeed72ab5 Temporal: Add arguments to constructor tests. 2022-05-25 11:35:10 -07:00
Ms2ger 6573cf954b Temporal: Add tests that subclass constructors work. 2022-05-25 11:23:22 -07:00
Ms2ger 2c8e4c061b Temporal: Cleanup some tests.
The options-invalid.js tests were also covered by options-wrong-type.js.

The tests for add/subtract without an options argument were also covered by options-undefined.js.
2022-05-25 11:10:04 -07:00
Ms2ger 63cf9ba7b5 Temporal: Extend tests for daysInYear and inLeapYear. 2022-05-24 10:56:45 -07:00
Philip Chimento 579268ab79 Temporal: Add tests for variant time separators
ISO strings may separate the time from the date with a case-insensitive T,
or a space. This adds tests to all entry points that take ISO strings, to
ensure that they accept an uppercase T, lowercase T, or space as the time
separator.

These tests are based on the one test for Temporal.PlainDateTime.from that
was already present.
2022-05-23 11:47:56 +02:00
Ms2ger 7fca6637e9 Temporal: Extend toJSON/toString tests. 2022-05-20 09:32:52 -07:00
Ms2ger 2de2fe3084 Temporal: Ensure PlainTime branding tests fail if needed. 2022-05-20 14:20:43 +02:00
Ms2ger 7960d616cf Temporal: Add a test for PlainTime#toZonedDateTime. 2022-05-19 12:55:27 -07:00
Ms2ger a1a5c91543 Temporal: Add a test for PlainTime#calendar. 2022-05-19 12:54:14 -07:00
Ms2ger b8ab7063b0 Temporal: Add tests for PlainTime#{toJSON/toString}. 2022-05-19 12:23:43 -07:00
Ms2ger 912559f683 Temporal: Test @@toStringTag properties. 2022-05-19 12:20:15 -07:00
Ms2ger 494b678cc5 Temporal: Add tests for ZonedDateTime to PlainDate conversion.
Also rename leap second tests for consistency.
2022-05-18 12:35:07 -07:00
Philip Chimento 2a03068b84 Fix Temporal.PlainDateTime.withPlainDate tests
I suggested in #3517 that these lines should be removed but didn't realize
they must be present because TemporalHelpers.assertPlainDateTime is going
to check the 'era' and 'eraYear' properties.
2022-05-05 09:51:01 +02:00
Philip Chimento a44a97a09a Add reference ISO days to PlainYearMonth assertions
I missed adding these in 27f0104bc6
2022-05-04 10:15:19 +02:00
Frank Yung-Fong Tang 06fafd794b
Move testing of era/eraYear under intl402 (#3517)
* Move testing of era/eraYear under intl402

* remove era/eraYear from built-in tests.
2022-05-03 11:11:20 -07:00
Ms2ger 7099acc882 Temporal: Add some tests for Duration#round.
Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
2022-05-03 08:15:56 -07:00
Ms2ger 69fd39b463 Temporal: Add some Duration#{add,subtract} tests. 2022-05-03 08:15:56 -07:00
Philip Chimento 8e0e2592d3 Expand Duration.compare test
This adds coverage for the situation where we get a different answer from
Temporal.Duration.compare depending on whether relativeTo resolves to a
PlainDate or ZonedDateTime.

See discussion in
https://github.com/tc39/test262/pull/3505#discussion_r859994610
2022-05-03 08:18:02 +02:00
Philip Chimento 65a7ace1cb Regularize year zero tests
Some of these strings wouldn't have been valid even with a valid year in
them (e.g. strings ending in +01:00[UTC]) so fix up the strings that we
test. While touching these tests, I took the opportunity to regularize
them, and add some missing ones for ISO strings that convert to Calendar
and TimeZone.
2022-05-03 08:18:02 +02:00
Philip Chimento 020faf5c7a Temporal: fix property bag order
No big deal, this was just bothering me that I wrote timeZone before
calendar in most of the tests, and vice versa in only a few.
2022-05-03 08:18:02 +02:00
Philip Chimento 88a4cf4af7 Temporal: Use some constructors directly
Be consistent about creating Temporal objects for use in tests with direct
constructor calls, instead of relying on string coercions. This reduces
coupling in the tests.
2022-05-03 08:18:02 +02:00
Philip Chimento 078f3e22a4 Regularize leap second tests
Everywhere an ISO string is accepted in Temporal, a seconds value of :60
should always be coerced to :59, because of how leap seconds are handled
in ISO strings.

In property bags, a 'seconds: 60' property is not subject to that rule: it
should be handled according to the overflow option if there is one.

These tests existed already for some types; regularize them and add the
ones that didn't exist yet.
2022-05-03 08:18:02 +02:00
Philip Chimento 27f0104bc6 Regularize Temporal.*.from() object cloning tests
Each from() method except Calendar and TimeZone should test that when you
pass an instance of that type, the return value is a clone of that
instance, and a distinct object.

These tests existed already for some types; regularize them and add the
ones that didn't exist yet.

In order to test the referenceISODay of a PlainYearMonth we add an
argument to TemporalHelpers.assertPlainYearMonth.
2022-05-03 08:18:02 +02:00
Ms2ger b649e6b22a Temporal: Port some Duration.compare tests. 2022-04-29 10:58:05 -07:00
Jesse Alama dcd25e616d Temporal: Port Demitasse tests for `PlainDateTime`'s `toString` 2022-04-28 12:20:22 +02:00
Ms2ger 7f2668f807 Temporal: Port a few tests for Duration#{add,subtract}. 2022-04-27 09:31:33 +02:00
Jesse Alama d156a5a63f Temporal: Port `PlainDateTime`'s Demitasse `withCalendar` tests
Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
2022-04-26 10:11:11 +02:00
Ms2ger 8f5c7aed09 Temporal: Fix bug in PlainDateTime/prototype/toZonedDateTime/basic.js. 2022-04-25 11:36:56 -04:00
Jesse Alama 1b71018adb Temporal: `PlainDateTime`: Port Demitasse tests for bounds 2022-04-25 12:22:49 +02:00
Jesse Alama cba02351f8 Temporal: Port Demitasse tests for PlainDateTime toZonedDateTime 2022-04-25 12:16:46 +02:00
Ms2ger efcac4c05a Temporal: Port some Duration tests. 2022-04-25 11:07:11 +02:00
Philip Chimento 78c6ec7f1c Test wrong types in conversions to Temporal types
These tests cover, for every API entry point where a Temporal object is
expected, what happens when a value of a different type is passed in that
can't be converted.

Most entry points can convert a string to the expected Temporal type, and
will do ToString on any non-Object argument, and throw RangeError if the
result isn't a string that's convertible to that Temporal type. ToString
will throw TypeError on a Symbol.

Most entry points also take a property bag, and will throw TypeError if
the property bag doesn't have the required properties.

We also have to test for TimeZone and Calendar what happens if the wrong
type is provided as the value of a 'timeZone' or 'calendar' property in
another property bag, up to one level of nested properties.
2022-04-21 12:14:10 -07:00
Philip Chimento afce1b3fde Test conversion of Number to Temporal objects
Adds tests for conversion of a Number whose corresponding toString() value
is a valid ISO string. For some Temporal types this is possible, with a
number like 20220418.

Especially for Temporal.Calendar, we have to take into account the case
where the number is provided as the value for the 'calendar' property in a
property bag, and the case of up to one level of nested property bag as
well.

Regularizes and expands existing tests for this case.
2022-04-21 12:14:10 -07:00
Philip Chimento a38d3f3b67 Add missing test for Temporal.ZonedDateTime constructor
The test for a TimeZone created from an ISO string with multiple offsets
was missing from the Temporal.ZonedDateTime constructor, whereas it was
present for several other APIs. Add it.
2022-04-21 12:14:10 -07:00
Philip Chimento 7b3c176629 Add missing tests for PlainTime property bag with no time units
We already had similar tests to these for other methods, such as
Temporal.PlainTime.prototype.equals(). since() and until() should have
these tests too.

Update assertion messages in all of the existing tests as well, as per
Ms2ger's review comment.
2022-04-21 12:14:10 -07:00
Philip Chimento 15ed94c891 Test conversion of object to string in Temporal.Instant context
An object may be given in any context where a Temporal.Instant is expected
(see ToTemporalInstant). There is no conversion from a property bag to an
Instant, unlike with other Temporal types. Instead the object is converted
to a string, and if its toString() method yields a valid ISO string, the
conversion succeeds. (An object with the default Object.prototype.toString
will not.)
2022-04-21 12:14:10 -07:00
Philip Chimento d28ca991cb Test conversion of Temporal.Instant strings with sub-minute UTC offsets 2022-04-21 12:14:10 -07:00
Philip Chimento 9cd27beb12 Test basic functionality of Temporal.Instant.from 2022-04-21 12:14:10 -07:00
Philip Chimento 4fdb4ee52f Fix invocations of some Temporal methods
We should make sure that we are providing the correct arguments to these
methods even if they are supposed to throw; they should throw for the
reason we expect, and not because we provided the wrong arguments.
2022-04-21 12:14:10 -07:00
Philip Chimento c82e2782e6 Regularize some quotes
Some of the similar tests to these use double quotes, some use single.
2022-04-21 12:14:10 -07:00
Jesse Alama 089c74ce59 Temporal: Port `PlainDateTime`'s `from` tests 2022-04-19 11:13:01 -07:00
Jesse Alama 33a5433d1b Temporal: PlainDateTime: Port Demitasse `until` and `since` tests
Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
2022-04-15 10:49:18 -07:00
Ms2ger ff5af6fccf Temporal: Consolidate tests for invalid string argument to round(). 2022-04-15 10:12:19 -07:00
Ms2ger 4dafd2158b Temporal: Remove some stray arguments to TemporalHelpers.assertDuration. 2022-04-13 09:37:35 -07:00
Ms2ger c35ae2099d
Temporal: Some more tests for PlainDateTime#with. (#3481) 2022-04-13 09:31:57 -07:00
Philip Chimento d9616ed91f 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.
2022-04-13 10:46:20 +02:00
Philip Chimento 3905c0c80a 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.
2022-04-13 10:46:20 +02:00
Philip Chimento 4ac16c2589 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.
2022-04-13 10:46:20 +02:00
Philip Chimento 9b2c98c02b 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.
2022-04-13 10:46:20 +02:00
Philip Chimento b4c0aeda20 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.
2022-04-13 10:46:20 +02:00
Ms2ger 2c880bf5c1 Temporal: Some more tests for PlainDateTime.compare. 2022-04-12 10:33:20 -07:00
Ms2ger a226601d12 Temporal: Some more tests for PlainDateTime#withPlainDate. 2022-04-12 10:10:04 -07:00
Ms2ger 7823be3e96 Temporal: Move test with typo in name. 2022-04-12 10:10:04 -07:00
Ms2ger 62e0130447
Temporal: Some more tests for PlainDateTime#equals. (#3479) 2022-04-12 10:02:53 -07:00
Jesse Alama 5f1aba63ee
Temporal: Port Demitasse PlainDateTime `round` tests (#3478)
Co-authored-by: Ms2ger <Ms2ger@gmail.com>
2022-04-12 17:36:03 +02:00
Philip Chimento 833a784f20 Tests for computing PlainYearMonth addition and subtraction in correct calendar space
https://github.com/tc39/proposal-temporal/pull/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.
2022-04-04 16:58:09 -04:00
Philip Chimento da507a703e Tests for Temporal formatting the year appropriately as 4 or 6 digits
https://github.com/tc39/proposal-temporal/pull/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.
2022-04-04 16:36:03 -04:00
Frank Tang cdcf2a3f09 Add tests for Temporal.Calendar.p*.inLeapYear
(Philip, March 2022: This was originally Frank's PR #3056. I did some
reformatting, removed duplicate tests, and combined with some existing
tests.)
2022-04-04 16:34:01 -04:00
Frank Tang 16aefcc6cf Add tests for Temporal.Calendar.p*.mergeFields
(Philip, March 2022: This was originally Frank's PR #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.)
2022-04-04 16:34:01 -04:00
Frank Tang 6bae30c1b2 Add tests for Temporal.Calendar.p*.monthDayFromFields
(Philip, March 2022: This was originally Frank's PR #3058. I did some
reformatting, removed duplicate tests, and combined with some existing
tests.)
2022-04-04 16:34:01 -04:00