Commit Graph

6407 Commits

Author SHA1 Message Date
Philip Chimento 801a5bb8f5 Temporal: Port toLocaleString calendar mismatch tests from staging
I wrote a similar test for Temporal.ZonedDateTime.p.toLocaleString, so
while this was fresh I decided to do the same for the other toLocaleString
calendar mismatch tests that were in staging.
2023-04-11 11:52:40 +02:00
Philip Chimento cd714a9aad Temporal: Rewrite Temporal.ZonedDateTime.p.toLocaleString tests
In https://github.com/tc39/proposal-temporal/pull/2522 which reached
consensus at the March 2023 TC39 meeting, the functionality of
Temporal.ZonedDateTime.p.toLocaleString was changed substantially, to not
directly pass the ZonedDateTime to any Intl.DateTimeFormat methods. This
adds rewrites of all existing tests for toLocaleString, as well as a few
tests to verify that Intl.DateTimeFormat methods no longer support
Temporal.ZonedDateTime arguments.

As we are rewriting the tests anyway, this also ports all of the
Temporal.ZonedDateTime.p.toLocaleString tests that were in staging, to the
correct format for the main tree.
2023-04-11 11:52:40 +02:00
Guillaume Emont da56f5e2b2 Temporal: updates tests for balancing ordering change in Temporal.Duration.prototype.round
Fixes some tests which are observing side effects of round().
2023-04-10 12:50:11 -07:00
Guillaume Emont 13778441ad Temporal: added a test reproducing tc39/proposal-temporal#2508
Before the issue is fixed, rounding a duration such as 'PT2400h' with
months as largest unit fails to balance it properly and gives a result
with days being the largest unit. The test ensures that such rounding
happens properly.
2023-04-10 12:50:11 -07:00
Philip Chimento 6d0978de60 Tweak test descriptions: "Intl time zones" → "IANA time zones"
Suggestion from Justin Grant's code review.
2023-04-10 08:36:08 -07:00
Philip Chimento 33865c5339 Validate required methods of Temporal Calendar protocol
Checking whether an object implements the Calendar protocol is now done by
means of HasProperty operations for each of the required methods unless
the object already has the Calendar brand.

Discussion:
https://github.com/tc39/proposal-temporal/issues/2104#issuecomment-1409549753

Corresponding normative PR:
https://github.com/tc39/proposal-temporal/pull/2485
2023-04-10 08:36:08 -07:00
Philip Chimento d6a24fe906 Validate required methods of Temporal TimeZone protocol
Checking whether an object implements the TimeZone protocol is now done by
means of HasProperty operations for each of the required methods unless
the object already has the TimeZone brand.

Discussion:
https://github.com/tc39/proposal-temporal/issues/2104#issuecomment-1409549753

Corresponding normative PR:
https://github.com/tc39/proposal-temporal/pull/2485
2023-04-10 08:36:08 -07:00
Philip Chimento bc979c51a5 Remove support for nested Temporal calendar property bags
Previously, "nested" calendar property bags were unwrapped up to one
level. That is, this object:
{
  calendar: {
     // ...Temporal.Calendar methods
  }
}
would not be considered to implement the Calendar protocol, but would have
its calendar property used instead, if it were passed to an API that
required a Calendar protocol object.

These nested property bags are no longer supported. Discussion:
https://github.com/tc39/proposal-temporal/issues/2104#issuecomment-1409549753

Corresponding normative PR:
https://github.com/tc39/proposal-temporal/pull/2485
2023-04-10 08:36:08 -07:00
Philip Chimento 24def913ec Remove support for nested Temporal time zone property bags
Previously, "nested" time zone property bags were unwrapped up to one
level. That is, this object:
{
  timeZone: {
     // ...Temporal.TimeZone methods
  }
}
would not be considered to implement the TimeZone protocol, but would have
its timeZone property used instead, if it were passed to an API that
required a TimeZone protocol object.

These nested property bags are no longer supported. Discussion:
https://github.com/tc39/proposal-temporal/issues/2104#issuecomment-1409549753

Corresponding normative PR:
https://github.com/tc39/proposal-temporal/pull/2485
2023-04-10 08:36:08 -07:00
André Bargull 886656756f Round epoch time getters towards negative infinity
Update tests to match <https://github.com/tc39/proposal-temporal/pull/2424>.
2023-04-10 13:20:49 +02:00
Aditi f756ff63c8
Add some Array.from async tests (#3791)
This PR adds some more tests for Array.fromAsync proposal.
It includes most of the tests defined in https://github.com/es-shims/array-from-async/blob/main/test.mjs

See:#3725
2023-04-07 16:47:19 -07:00
Philip Chimento 0178aa2114 Change Temporal.TimeZone.prototype.toJSON not to call toString
Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Philip Chimento 8c37094e1f Change Temporal.TimeZone compare semantics to use .id
Compare semantics for custom time zones that _don't_ extend
Temporal.TimeZone (and therefore don't have the internal slot) use the
value of the .id property, instead of calling toString().

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Philip Chimento 960070549b Store strings or objects in Temporal.ZonedDateTime [[TimeZone]] slot
Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Philip Chimento f2871840b8 Replace Temporal.ZonedDateTime.timeZone getter with new API
This is the replacement of the old API with the new API, .timeZoneId and
.getTimeZone(). Semantics will be corrected in the following commit.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Philip Chimento 61d84cc6bc Change Temporal.Calendar.prototype.toJSON not to call toString
Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Philip Chimento aee3a937dc Change Temporal.Calendar compare semantics to use .id
Compare semantics for custom calendars that _don't_ extend
Temporal.Calendar (and therefore don't have the internal slot) use the
value of the .id property, instead of calling toString().

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Philip Chimento 41ffc678b0 Store strings or objects in Temporal objects' [[Calendar]] slot
In several tests involving custom calendars, we need to change the
implementation of dateFromFields/monthDayFromFields/yearMonthFromFields so
that the returned object gets the receiver as its calendar after chaining
up to the builtin implementation.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Philip Chimento a1bf99771c Replace Temporal objects' .calendar getters with .calendarId/.getCalendar
This is the replacement of the old API with the new API. Semantics will be
corrected in the following commit.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
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 27d7cdad4e Replace Temporal.Now.timeZone → Temporal.Now.timeZoneId
Now.timeZoneId() returns a string so that it can be used to construct
objects that have the builtin time zone behaviour.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00
Frank Tang beb4f26eb4 Remove unit of ":" in "digital" style. 2023-04-05 16:39:20 +02:00
Frank Tang 4fda9c4c01 Split DurationFormat style tests
For better parallization and reporting
2023-04-05 16:39:20 +02:00
Philip Chimento 92500bfffb
Array.fromAsync various remaining coverage (#3809)
This contains a few more tests for Array.fromAsync, in addition to what
has already been merged and what is under review at #3791.

This covers the following items from the testing plan at #3725:

- Success cases
  - Creates promise
  - Create new array/arraylike in promise (with length = length property)
- Input
  - Invalid input values
    - nonconforming object (arraylike without length, missing keys)
  - Covered by polyfill tests
    - Result promise rejects if length access fails (non-iterable input)
    - Unaffected by globalThis.Symbol mutation (non-iterable)
- this-value
  - this-value is a constructor
  - this-value is not a constructor
  - If this is a constructor, and items doesn't have a Symbol.iterator,
    returns a new instance of this
  - Iterator closed when property creation on this fails
  - Returned promise rejects when ^
- Other tests
  - Error is thrown for all CreateDataProperty fails
  - Non-writable properties are overwritten by CreateDataProperty
  - Input with missing values

Co-authored-by: Ms2ger <Ms2ger@igalia.com>
2023-04-04 11:20:25 +02:00
Justin Grant daefac0814 Add test to validate fix to proposal-temporal#2537
The Temporal polyfill had a math bug in Calendar.p.dateUntil where
non-ISO calendars would unexpectedly throw when calculating
the number of years between two dates where the year were different,
the month codes were different, but the months were the same because
the earlier date's month was after a leap month.

This test validates the fix to this bug.
2023-04-03 17:27:34 -07:00
Justin Grant aed56d9fa6 Add test to validate fix to proposal-temporal#2383
The Temporal polyfill had an infinite loop for non-ISO calendars
when Calendar.p.dateUntil was called to calculate the duration
between two identical dates. This test validates that PT0S is returned
in that case.
2023-04-03 17:27:34 -07:00
Philip Chimento be0abd93cd Add copies of resizable ArrayBuffer species constructor tests to BigInt folders
This adds copies of the tests added in the previous commit, to the
respective BigInt folders, editing them to use the testBigIntTypedArray
helper instead of the testTypedArray helper.

See: #3723
2023-03-31 16:52:42 -07:00
Aditi 8330bd6567 Add resizable ArrayBuffer tests in %%TypedArray%% 2023-03-31 16:52:42 -07:00
Huáng Jùnliàng ff405fd0df update fixtures 2023-03-29 12:54:37 -07:00
Huáng Jùnliàng a3880a460a update decorator member expr private id test cases 2023-03-29 12:54:37 -07:00
Jordan Harband 6da1d4c82c
Merge pull request #3796 from syg/transfertofixedlength-tests
Add tests for ArrayBuffer.prototype.transferToFixedLength
2023-03-28 00:34:15 -07:00
Shu-yu Guo 4a8135e01e Fix description of new-length-excessive 2023-03-28 00:28:28 -07:00
Shu-yu Guo 6fecc44859 Add tests for ArrayBuffer.prototype.transferToFixedLength
See https://tc39.es/proposal-arraybuffer-transfer/
2023-03-28 00:28:28 -07:00
Shu-yu Guo 9964fa962a
Add V8 tests for JSON.parse with source to staging/ (#3806) 2023-03-27 17:21:29 -07:00
Shu-yu Guo e0d4ca0577 Add JSON.parse with source feature tag 2023-03-27 16:27:51 -04:00
Jordan Harband 910a2764d8 Object.prototype.toString: avoid over-DRYness, and add preconditions 2023-03-27 11:21:34 +02:00
José Julián Espina 4a6439e4a7
Add `Array.prototype.includes` and `exponentiation` features (#3799) 2023-03-23 10:51:08 +01:00
Ms2ger 9704d7f22f
Add tests for the asyncItems argument to Array.fromAsync. (#3754)
Co-authored-by: Philip Chimento <pchimento@igalia.com>
2023-03-10 11:46:59 +01:00
Aditi 53e5ef817e Add Temporal era/eraYear tests 2023-03-07 16:00:10 -08:00
Philip Chimento c4d8f01d3d Array.fromAsync: Tests for mapfn and thisArg arguments
- normal case with synchronous and asynchronous mapfn
- a non-callable value is passed as mapfn
- behaviour of various values of thisArg in strict and sloppy mode
- mapfn result is awaited once per iteration
- iterator is closed when mapfn throws
2023-03-07 11:13:00 +01:00
Philip Chimento ba1e51c8e7 Fix function-valued properties in propertyBagObserver
A property in the property bag we want to observe may be a function, in
which case we don't want to treat it as a primitive and create a
toPrimitiveObserver for it.

(Also handle the null case, in which we should fall through to return a
toPrimitiveObserver.)
2023-03-07 11:13:00 +01:00
Richard Gibson 4f5eb40ee0 Temporal: Test updates for mergeFields output property order
Normative PR: https://github.com/tc39/proposal-temporal/pull/2505
2023-03-06 14:30:35 -08:00
Philip Chimento 5ea8322b08 Clarify feature flags are per proposal
As per discussion in https://github.com/tc39/test262/pull/3773
2023-03-06 17:31:20 +01:00
Philip Chimento 6bfcab1063 Remove unused "Intl.DateTimeFormat-quarter" feature flag
This was a needs-consensus PR that didn't reach consensus. The
corresponding tests were already removed in f7e6656c.

(Note, the link in the removed comment is wrong; it should point to
https://github.com/tc39/ecma402/issues/374)
2023-03-06 17:31:20 +01:00
Philip Chimento 7a5210deaf Clean up feature flags for proposals in published standard
This moves feature flags to the bottom section, for proposals that have
been included in a published revision of the standard (through ES 2022).
2023-03-06 17:31:20 +01:00
Philip Chimento a58ae41ea7 linter: Fix parsing features.txt
Previously, split() would split on whitespace, then the if-condition would
remove `#` - interpreting every word in every comment in the file as a
potential valid feature flag. We want splitlines() here.

Partial-line comments were inadvertently "supported" before, because of
this bug. Instead, support them explicitly by chopping off a `#`
character, anything after it, and any whitespace immediately preceding it.
2023-03-06 17:31:20 +01:00
Philip Chimento 6e1b737357 linter: Use same Python interpreter when executing script in subprocess
If a specific Python interpreter is used (e.g. by invoking the script with
"/path/to/python run.py") then we should use the same Python interpreter
to execute scripts in subprocesses, not the one from the environment.

The path to the running Python interpreter is given by sys.executable.
2023-03-06 17:31:20 +01:00
Cam d216cc1972 asyncHelpers implementation: Apply suggestions from code review
Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
2023-02-21 11:04:09 -08:00
Cam Tenny eb44f67274 asyncHelpers tests: Address code review feedback 2023-02-21 11:04:09 -08:00
Cam Tenny e0d5b780e7 Update CONTRIBUTING.md to suggest using asyncHelpers 2023-02-21 11:04:09 -08:00