Commit Graph

290 Commits

Author SHA1 Message Date
Linus Groh d52a5bbbe8 Replace arrow function with regular function in harness/sta.js 2023-06-21 17:19:47 +02:00
Philip Chimento aecd10eec8 Temporal helpers: format only ASCII identifiers specially
Using `\p{ID_Start}` and `\p{ID_Continue}` to match JS identifiers was not
supported everywhere. Let's assume that we only want to format ASCII
identifiers as bare property names. (This doesn't change any tests, just
the formatting of property names in lists of user-observable actions. No
tests currently checked for non-ASCII properties.)
2023-06-07 11:09:06 +02:00
Mathias Bynens 1a352aac50 Avoid excessive `U+` in error messages 2023-04-28 11:43:01 +02:00
Philip Chimento 63e0986803 Improve printing of property key names in observer helpers
These should be formatted in the same way that they'd be entered in source
code.
2023-04-24 12:14:18 +02: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 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 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 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
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
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
Cam Tenny 1d116b48a9 harness/asyncHelpers.js: Refactor asyncTest to always return undefined instead of a Promise 2023-02-21 11:04:09 -08:00
Cam Tenny d810c684ae harness/asyncHelpers.js: Refactor assert.throwsAsync to only accept a callable 2023-02-21 11:04:09 -08:00
Cam Tenny 4bd0545b29 harness/asyncHelpers.js: Remove dependency on Promise. 2023-02-21 11:04:09 -08:00
Cam Tenny 98952c3c51 harness/asyncHelpers.js: Refactor assert.throwsAsync to be async function 2023-02-21 11:04:09 -08:00
Cam Tenny c056d31b9b Adds harness/asyncHelpers.js: functions asyncTest and assert.throwsAsync, per rfcs/async-helpers.md 2023-02-21 11:04:09 -08:00
James Wright 01425696e6 Push into calls array in calendar and timeZone observers. 2023-02-08 12:29:24 +01:00
Cam Tenny 09f863d8c3 Temporal operation NanosecondsToDays: Test infinite or arbitrary-length observable loops in Duration and ZonedDateTime 2023-01-03 12:47:37 -08:00
Cam Tenny f00d4118db Temporal operation NanosecondsToDays: Test RangeErrors reachable in Duration and ZonedDateTime. 2022-12-23 15:35:51 +01:00
Philip Chimento 9821def022 Add missing feature flag to isContructor helper file
The linter says this should include the Reflect.construct feature flag.
2022-12-17 13:18:46 -08:00
jugglinmike 5093c3037d
Reject exceptional input to `isConstructor` (#3748)
* Reject exceptional input to `isConstructor`

Prior to this commit, the `isConstructor` harness function would return
`false` when invoked with a value that lacked a [[Call]] internal
method. While it's true that such values are not constructors, there are
no tests which benefit from using `isConstructor` to make such an
assertion.

Extend `isConstructor` to throw an error when invoked with a
non-function object. Update a test which was misleadingly invoking the
function with the value `undefined`.

* fixup! Reject exceptional input to `isConstructor`
2022-12-15 22:53:34 -05: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 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 e1d46f7fdc Temporal helpers: Track daysInMonth() in calendarObserver()
The Temporal.Calendar.prototype.daysInMonth() method is observably called
in a few places in the spec. It should be tracked on the object returned
from TemporalHelpers.calendarObserver().
2022-11-29 11:53:40 +01:00
Philip Chimento 7d0dde3635 Temporal: Remove duplicate number-as-PlainMonthDay test case
Conversion of a Number to an ISO string is already covered in the file
argument-number.js.
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
Timothy Flynn f6c48f333e Update Intl tests to recognize microsecond and nanosecond as sanctioned
These were added to the list of sanctioned units in a normative change:
https://github.com/tc39/ecma402/commit/f627573
2022-11-04 17:30:26 -07:00
Ms2ger 5d8ebdff05 Improve documentation for assert.compareIterator. 2022-11-04 10:54:28 -07: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 ee7c379375 Harness: Ensure $DONE called only once in async-gc.js
This looks like a bug: resolveAsyncGC() is supposed to succeed if the
thrown value is asyncGC.notCollected, but instead it would call $DONE()
twice. An added "return" prevents that.
2022-10-12 09:58:45 +02:00
Philip Chimento 1bb7ecee5b Harness: Account for Symbols being thrown in async tests
It's possible for an async test to throw a Symbol (harness/async-gc.js
does this.) The Symbol ends up getting passed to $DONE in a
.then($DONE, $DONE) call. Previously, $DONE would then throw an exception
due to not being able to convert the Symbol to a string.
2022-10-12 09:58:45 +02:00
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 46c3823117 Temporal: Add TemporalHelpers.crossDateLineTimeZone
Several tests in staging use the Pacific/Apia IANA time zone to test the
behaviour of various algorithms for the case where Samoa skipped the
entire day of Dec. 30, 2011, when they switched from one side of the
International Date Line to the other. Since implementations are not
technically required to support IANA time zones, add a fake Samoa time
zone to TemporalHelpers that has the same transition, and use it in those
tests.

(The time zone isn't exactly the same as Pacific/Apia, since Samoa also
observes DST and this time zone doesn't. It's only the same for this one
transition.)

See: #3649
2022-10-03 12:24:00 +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 38dd3c2823 Temporal: Consistently format property names in call logs
I've occasionally gotten bugs due to Get or Has operations being performed
on symbol-valued properties, and trying to format them inside backtick
strings, which throws. I've been meaning to consolidate this for a while
into a formatting function which nicely formats any kind of property key.
Now that I'm about to write more tests having to do with order of
observable operations, this seems like a good time to do it.

This is a refactor in temporalHelpers.js.
2022-09-21 10:41:14 +02: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
Mathias Bynens ab13ee1513 Add missing `define` 2022-07-12 19:21:53 -07:00
Mathias Bynens 242128ec78 Update regExpUtils.js 2022-07-12 19:21:53 -07: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
Romulo Cintra b458b9f0c2 Update harness/testIntl.js
thks

Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
2022-06-23 16:15:30 -04:00
Romulo Cintra 2877facc4c Update testIntl.js
Add NS digit mappings
2022-06-23 16:15:30 -04:00
Romulo Cintra 0efbba27ff Normative: Add new numbering system "tnsa"
Add [tnsa](https://github.com/unicode-org/cldr/blob/main/common/bcp47/number.xml#L95) to number systems
2022-06-23 16:15:30 -04:00
Ms2ger 820461ef4b Temporal: Extend tests for PlainDate.compare. 2022-06-14 16:45:56 +02:00
Mathias Bynens 997888324e Add missing binding 2022-05-04 07:57:38 -07: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