Commit Graph

159 Commits

Author SHA1 Message Date
Philip Chimento 55fdf60820 Remove calendar slot from Temporal.PlainTime
Has several effects on existing tests:
- Remove PlainTime from various tests that extract a Temporal.Calendar
  instance from another Temporal object.
- Remove Temporal.PlainTime.prototype.calendar property.
- Remove calendar property from object returned from
  Temporal.PlainTime.prototype.getISOFields().
- Ignore calendar annotation when converting ISO string to PlainTime.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Philip Chimento 8ad7d04afa Temporal: Test copying options object in since() and until()
In since() and until() methods, we copy the options object with
CopyDataProperties. Previously, its properties could be read in more than
one place (the method itself, and the calendar method), triggering user
code each time. Now, we pass around null-prototype objects with only data
properties.

See https://github.com/tc39/proposal-temporal/pull/2447
2023-02-14 09:45:43 -08:00
Aditi 1c47728a20 Remove failing tests for CalendarFields and CalendarMergeFields 2023-02-10 17:43:47 -08:00
Philip Chimento e7364ea7dc Temporal: Tests for upper limit on rounding increments
Previously in a few cases (calendar units in Duration) the value for the
roundingIncrement option had no upper limit, other than having to be
finite. These tests cover a normative change limiting it to 1e9.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2480
2023-02-01 11:50:44 -08:00
Philip Chimento 8aeab83c98 Temporal: Adjustments to order-of-operations tests
The with() methods, as well as PlainYearMonth's since() and until(), were
adjusted to read the receiver's fields before the fields of any objects
provided as arguments. This change is observable, so affects several tests
that test the observed order of operations.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2478
2023-02-01 10:32:07 -08:00
Philip Chimento a157570ddc Regularize some of the "calendar-temporal-object" tests
I used a script to "unroll" some of the calls to
TemporalHelpers.checkToTemporalCalendarFastPath(), and rewrite it slightly
not to use a specific Calendar instance. This is in preparation for a
future refactor, but also allows testing the PlainTime path which was not
previously covered.

(I didn't unroll all the calls and remove the helper yet, because the
remaining calls have custom assertions that I haven't gotten the script to
work with yet. For the same reason, I didn't yet convert these to use the
test generation facility. These will follow in a future PR.)
2023-02-01 10:50:12 +01:00
Philip Chimento 374aac475d Regularize "calendar-case-insensitive" tests
For each entry point where a string calendar name is accepted, we should
have a test that ensures the calendar name is case-insensitive. These
tests existed but several were incomplete as they didn't take nested
properties into account, and several entry points were missing this test.

Fix a minor copy-paste issue with double semicolons.
2023-02-01 10:50:12 +01:00
Richard Gibson f9a62a4eb1 Temporal: Update custom Calendar/TimeZone tests to cover rejection of invalid output
Ref https://github.com/tc39/proposal-temporal/issues/2443
2023-01-31 17:17:28 -08:00
Aditi e1048d0aff Update Temporal test262 as per the normative changes 2023-01-04 10:56:25 -08:00
Philip Chimento 8f752acdaa Temporal: Test order of property accesses
This contains tests for the normative PR
https://github.com/tc39/proposal-temporal/pull/2437, which is to be
presented for consensus to TC39 in the upcoming plenary meeting. That PR
changes the observable order of property accesses to be alphabetical where
possible.
2022-12-01 11:35:04 -08:00
Philip Chimento 6e4f412d65 Temporal: Tests for normative changes around date-only strings
As per the discussion in
https://github.com/tc39/proposal-temporal/issues/2379#issuecomment-1248557100
and the PR https://github.com/tc39/proposal-temporal/pull/2398, which is
to be presented for consensus to TC39 in the upcoming plenary meeting, UTC
offsets and the Z designator should be disallowed after any date-only
strings (YYYY-MM-DD, YYYY-MM, and MM-DD). They should only be allowed to
follow a time component. Z remains disallowed in any string being parsed
into a Plain type.

Annotations become allowed after any ISO string, even YYYY-MM and MM-DD
where they were previously disallowed.
2022-11-30 10:11:10 -08:00
Philip Chimento 338063f80f Temporal: Test throwing on time-zone-to-calendar conversion and vice versa
This contains tests for the normative PR
https://github.com/tc39/proposal-temporal/pull/2433, which is to be
presented for consensus to TC39 in the upcoming plenary meeting. That PR
changes ToTemporalCalendar to throw when it encounters a Temporal.TimeZone
instance, and ToTemporalTimeZone to throw when it encounters a
Temporal.Calendar instance.
2022-11-30 10:01:45 -08:00
Philip Chimento 1e9dc7f38e Temporal: Clean up existing uses of foo.splice(0, foo.length)
The second parameter isn't needed if the intention is to empty the array.
Additionally clearing it at the end of the test isn't needed.
2022-11-29 11:53:40 +01:00
Philip Chimento 47b9e32dc3 Temporal: Add some more order-of-operations tests
This adds order-of-operations tests that cover all of the Temporal entry
points that accept options bags, that were not already covered. We'll be
using these tests in the future to verify
https://github.com/tc39/proposal-temporal/issues/2254
However, the tests in this commit reflect the current state of the
proposal, not the potential normative change.
2022-11-29 11:53:40 +01:00
Philip Chimento f2e17efaf8 Temporal: Expand order-of-operations tests to cover calendar methods
Some of the existing order-of-operations tests didn't observe the calendar
operations. Add a TemporalHelpers.calendarObserver() calendar to the
invocations of these methods in the order-of-operations tests.
2022-11-29 11:53:40 +01:00
Philip Chimento ed32b59bba Temporal: Expand order-of-operations tests to cover options bags
Some of the existing order-of-operations tests didn't pass an options bag:
primarily from(), with(), add() and subtract(). (since() and until() were
covered in a previous commit.)

Add a TemporalHelpers.propertyBagObserver() options bag to the invocations
of these methods in the order-of-operations tests.
2022-11-29 11:53:40 +01:00
Philip Chimento ec752ebaab Temporal: Expand PlainYearMonth and PlainMonthDay strings tests
Use the new collections of strings in TemporalHelpers.ISO to add more
tests for ISO strings in API entry points that convert an ISO string to
Temporal.PlainYearMonth or Temporal.PlainMonthDay.
2022-11-16 16:32:42 -08:00
Philip Chimento d1b16d7d0e Temporal: Move more collections of valid/invalid strings into TemporalHelpers
The idea is to deduplicate more string tests into methods on this object,
that return collections of valid and invalid strings. This adds
collections of valid and invalid PlainYearMonth and PlainMonthDay strings.
2022-11-16 16:32:42 -08:00
Philip Chimento 99bc91e0f5 Temporal: Test change from MergeLargestUnitOption to CopyDataProperties
This tests some of the normative changes in
https://github.com/tc39/proposal-temporal/pull/2245, which achieved
consensus in the July 2022 TC39 meeting, specifically as they apply to
places where the MergeLargestUnitOperation was called.

Due to the use of the pre-existing spec operation CopyDataProperties, the
order of observable property operations has changed from a batch of
[[GetOwnProperty]] followed by a batch of [[Get]], to a series of
interleaved [[GetOwnProperty]]/[[Get]] pairs. This previously wasn't
tested because TemporalHelpers.propertyBagObserver didn't track
[[GetOwnProperty]] operations, but now it does.
2022-10-20 17:33:36 +02:00
Philip Chimento 34805283d9 Temporal: Add tests for fast path in ToTemporalCalendar
Normally, a plain object passed into an API that takes a Temporal.Calendar
has its 'calendar' property checked (observably) with a Has operation
followed by a Get operation if the property is present. In the normative
change https://github.com/tc39/proposal-temporal/pull/2392 which reached
consensus at the September 2022 TC39 meeting, this was changed so that
this check is skipped for objects which have the Temporal.Calendar
internal slots.

This adds tests to all entry points that pass a user-supplied object to
ToTemporalCalendar, with a "poisoned" calendar object which has the
correct internal slots but a 'calendar' accessor property whose getter
throws. A correct implementation should not cause this getter to throw.
2022-10-18 14:38:38 +02:00
Philip Chimento 01f73e96ca Temporal: Add tests for avoiding observable iteration in CalendarFields
See https://github.com/tc39/proposal-temporal/pull/2316 which eliminated
an observable call to Array.prototype[Symbol.iterator]() in the case where
a calendar's 'fields' property was undefined.

The best way I've thought of to test this is to monkeypatch the
Array.prototype[Symbol.iterator]() method to make it throw. In some cases,
where we are actually expected to iterate the return value from a
Temporal.TimeZone's getPossibleInstantsFor() method, we have to provide a
custom method for that as well, that returns a non-Array iterable so we
don't call the patched Array.prototype[Symbol.iterator]().

This normative change reached consensus at the July 2022 TC39 plenary
meeting.
2022-10-11 12:23:47 +02:00
Philip Chimento c0bb28d2f3 Temporal: Add tests for calendarName: "critical" option
See https://github.com/tc39/proposal-temporal/pull/2397
This normative change adds a new accepted value for the calendarName
option in various toString() methods.
2022-10-11 12:19:49 +02:00
Philip Chimento 0c18f7045b Temporal: Expand and regularize existing calendarName option tests
Since we are going to be adding a new test for calendarName: "critical",
take the existing tests for various values of the calendarName option, and
regularize them. Previously, depending on which type's toString() method
was under test, the tests had various degrees of thoroughness, and some
were only present in staging.
2022-10-11 12:19:49 +02:00
Philip Chimento 6bfb4441d3 Temporal: Add tests for multiple time zone annotations
See https://github.com/tc39/proposal-temporal/pull/2397
Adds tests for ISO strings with more than one time zone annotation. These
are not syntactically correct according to the grammar and should be
rejected.
2022-10-11 12:19:49 +02:00
Philip Chimento 705cf94429 Temporal: Add tests for unknown annotation with critical flag
See https://github.com/tc39/proposal-temporal/pull/2397
Adds tests for ISO strings with unrecognized annotations with the critical
flag. These strings should all be rejected.
2022-10-11 12:19:49 +02:00
Philip Chimento dc11e501d6 Temporal: Add tests for unknown annotation without critical flag
See https://github.com/tc39/proposal-temporal/pull/2397
Adds tests for ISO strings with unrecognized annotations, (i.e., neither
time zone nor calendar), in various combinations with recognized
annotations.
2022-10-11 12:19:49 +02:00
Philip Chimento 9d87845bb0 Temporal: Add tests for calendar annotation with critical flag
See https://github.com/tc39/proposal-temporal/pull/2397
Adds tests for ISO strings with calendar annotations, with and without the
critical flag, and also a check that the second calendar annotation is
disregarded, as per the IETF draft.
2022-10-11 12:19:49 +02:00
Philip Chimento 2d015b700a Temporal: Add tests for time zone annotation with critical flag
See https://github.com/tc39/proposal-temporal/pull/2397
Adds tests for ISO strings with named and numeric offset time zone
annotations, with and without the critical flag, with various combinations
of Z and offset in front of the annotation.
2022-10-11 12:19:49 +02:00
Philip Chimento eb67a7689f Temporal: Add tests for observable operations in MoveRelativeDate
See https://github.com/tc39/proposal-temporal/pull/2267 which eliminated
some unnecessary lookups of the calendar's dateAdd method from the
MoveRelativeDate AO, which is called in the calendar types' since() and
until() methods, Duration.p.round(), and Duration.p.total().

This adds tests for the order of all observable operations for these 10
methods, not just the lookups of dateAdd on the calendar. (These methods
needed to have their order of observable operations tested anyway.)

They heavily use the TemporalHelpers.calendarObserver and
TemporalHelpers.timeZoneObserver added in the previous commits.

https://github.com/tc39/proposal-temporal/pull/2267 included changes to
several code paths, not all of which are reachable through every method
tested here; only Duration.p.round() can trigger the full set.

https://github.com/tc39/proposal-temporal/pull/2267 reached consensus at
the July 2022 TC39 plenary meeting.
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 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 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
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 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
Aditi 6fa1bb89a3 Added tests for an empty or a function options object 2022-07-28 11:59:50 -07:00
Aditi dadf18f416 Add tests for temporalDurationLike argument and improve existing tests 2022-07-25 13:30:46 -07:00
Ms2ger 3ddfa0cd13 Temporal: Test that Calendar#dateAdd is called with the correct arguments. 2022-07-04 11:30:02 -06: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 8123e8fc34 Temporal: Add missing Number checks in overflow-wrong-type.js. 2022-06-25 19:54:57 +02:00
Ms2ger 9762bc991f Temporal: Make branding tests more robust. 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
Ms2ger 6f2e6872fb
Temporal: Extend tests for getISOFields. (#3560) 2022-06-13 08:55:55 -07:00
Ms2ger bb926a1796 Temporal: Extend tests for daysInMonth. 2022-06-13 16:26:08 +02:00
André Bargull c61a04fd88 AddDurationToOrSubtractDurationFromPlainYearMonth doesn't add "month" to calendar fields
Fixes #3546
2022-06-08 17:02:33 +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 6573cf954b Temporal: Add tests that subclass constructors work. 2022-05-25 11:23:22 -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 912559f683 Temporal: Test @@toStringTag properties. 2022-05-19 12:20:15 -07: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
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 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
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 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 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
Philip Chimento ac19506a01 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.
2022-04-04 16:24:17 -04:00
Jesse Alama fe40aea50c Emit fallback day 1 2022-03-29 16:58:36 -07:00
Jesse Alama ee1f96235b Ensure reference data is emitted when calendarName = 'always'
References:

+ https://github.com/tc39/proposal-temporal/issues/1971
2022-03-29 16:58:36 -07:00
Ms2ger f964584508 Expand overflow-invalid-string.js tests. 2022-03-25 11:18:13 -07:00
Ms2ger 104e5e8fab Test more invalid values for roundingMode. 2022-03-11 09:51:57 +01:00
Ms2ger df873eed1a Port tests for PlainYearMonth#{add,subtract}. 2022-02-08 15:46:11 -05:00
Ms2ger f98a00bc69 Port tests for PlainYearMonth#{since,until}. 2022-02-08 15:44:41 -05:00
Ms2ger 8848ee91e8 Remove smallestunit-disallowed-units.js.
It is covered by smallestunit-invalid-string.js and largestunit-smallestunit-mismatch.js.
2022-02-08 15:44:41 -05:00
Jesse Alama 525313395b Add tests for with() copying defined properties of source object
https://github.com/tc39/proposal-temporal/issues/1910 found a bug in an
indentation level of a line in the Temporal proposal, which affected the
outcome of the PreparePartialTemporalFields abstract operation. This adds
tests for all entry points that use that abstract operation, to make sure
the behaviour is correct: only defined properties are copied in with()
methods.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
2022-02-08 15:43:25 -05:00
Ms2ger d71cf3a339 Reorganize tests for PlainYearMonth#{since,until} largestUnit option. 2022-02-03 12:29:16 -05:00
Philip Chimento 4f20476e0a Add tests for largestUnit/smallestUnit mismatch
These tests already existed for PlainDate. Copy them to the other types
(and use the constructor instead of from() in order to be as simple as
possible)
2022-02-01 18:02:08 -05:00
Philip Chimento 4382f17f29 Expand largestUnit and smallestUnit invalid strings tests
Some of these (in PlainDate) had already been rewritten to test more
invalid strings that are otherwise valid units. This commit takes these
improvements and brings them to all of the similar tests for other types'
since() and until() methods.
2022-02-01 18:02:08 -05:00
Jesse Alama 7d82f8ac63 Add tests for invalid extended year "-000000"
https://github.com/tc39/proposal-temporal/issues/1753 records the
consensus reached at the October 2021 TC39 meeting to disallow "-000000"
as an extended year, both in Date.parse and Temporal. This adds tests for
the Temporal part of that.
2022-02-01 17:59:02 -05:00
Ms2ger 20329ef359 Test limits in PlainYearMonth.from. 2022-02-01 17:58:30 -05:00
Ms2ger f857cf9968 Test limits in PlainYearMonth constructor. 2022-02-01 17:58:30 -05:00
Ms2ger 516f9a9083 Test PlainYearMonth.prototype.toString. 2022-02-01 17:58:30 -05:00
Ms2ger fddbb4fdf7 Test PlainYearMonth.prototype.toPlainDate. 2022-02-01 17:58:30 -05:00
Ms2ger 51d5cf9a44 Test PlainYearMonth.prototype.valueOf. 2022-02-01 17:58:30 -05:00
Ms2ger ab6fab987e Test PlainYearMonth.prototype.equals. 2022-02-01 17:58:30 -05:00
Ms2ger 405f4fac4b Test PlainYearMonth.compare. 2022-02-01 17:58:30 -05:00
Ms2ger 6ba72412ab Test PlainYearMonth.prototype.with. 2022-02-01 17:58:30 -05:00
Ms2ger 7215b9387f Remove duplicated tests for PlainYearMonth.from overflow.
This is covered in overflow-wrong-type.js.
2022-02-01 17:58:30 -05:00
Ms2ger 158d0bf35f Test PlainYearMonth constructor, from. 2022-01-28 13:17:31 -05:00
Ms2ger 543c8ee938 Pass arguments in PlainYearMonth constructor test.
The arguments are required, so this should make the test more robust.
2022-01-28 13:17:31 -05:00
James Wright e87b0048c4 Include missing semicolons in Temporal tests. 2022-01-19 13:48:03 -05:00
Ms2ger 3f88250aca Add a test for PlainYearMonth#toPlainDate(). 2022-01-04 09:26:28 -05:00
Jesse Alama 0b8319355b Test `since` for PD(T) with `largestUnit` = `year`, `month`
Nails down intended behavior of `PlainDate` and
`PlainDateTime`'s `since` that is already true in the
polyfill but which was specified in a buggy way (and hence
potentially not true in an implementation of Temporal).
Add similar tests for Instant, PlainTime, PlainYearMonth, and
ZonedDateTime.

Reference:
https://github.com/tc39/proposal-temporal/pull/1881
2021-12-14 13:39:19 -05:00
Philip Chimento 8d025ef1d6 Test that non-undefined, non-zoned relativeTo parameters are converted to PlainDate
Tests for the normative changes made to Temporal in
https://github.com/tc39/proposal-temporal/pull/1873

This adds a new Temporal helper calendar that asserts that its dateAdd()
method is always called with a PlainDate instance. This allows testing
that relativeTo parameters are always converted to PlainDate if they are
not ZonedDateTime and not undefined. Prior to the normative PR, they
would be converted to PlainDateTime instead.

Additionally and optionally, the helper calendar can also assert that its
dateAdd() method is called with a specific PlainDate instance. This allows
testing that the instance is the same PlainDate passed as the relativeTo
parameter (in the case of Duration methods) or is the receiver (in the
case of PlainDate methods). For the PlainDateTime and PlainYearMonth
methods the PlainDate instance is synthesized internally so there is no
need to assert that dateAdd() is called with a specific instance.
2021-12-14 13:39:19 -05:00
Philip Chimento 0184842b09 Test rejection of "Z" UTC designators in Plain strings
Tests for the normative changes made to Temporal in
https://github.com/tc39/proposal-temporal/pull/1874
2021-12-14 13:39:19 -05:00
Justin Grant 6c2884eb9e Verify that `Temporal.*.prototype` isn't writeable 2021-12-14 13:38:14 -05:00