Commit Graph

2523 Commits

Author SHA1 Message Date
Cam Tenny f00d4118db Temporal operation NanosecondsToDays: Test RangeErrors reachable in Duration and ZonedDateTime. 2022-12-23 15:35:51 +01:00
Ms2ger 920a567b72 Improve is/toWellFormedString coverage. 2022-12-21 10:57:19 +01:00
snek 06b982d2f0 add missing feature to cleanupSome test 2022-12-19 10:04:34 +01:00
Philip Chimento 7c9a885b79 Array.fromAsync: Boilerplate tests
Here are some of the standard tests for property metadata of the
Array.fromAsync property and for the built-in function object. These don't
require doing anything asynchronously, so can be considered separately
from the Async Helpers RFC.
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
Richard Gibson 8cd563f978
Intl: Add substantive tests for Array.prototype.toLocaleString (#3741) 2022-12-05 10:51:55 +01: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
Timothy Flynn f1fc5c6497 Fix typos in String.prototype.isWellFormed/String.prototype.toWellFormed
1. String.prototype.toWellFormed's name is "toWellFormed".

2. "asserts" does not exist in the test harness, and "assert.throws"
   expects the error type first.
2022-12-01 17:02:41 +01:00
Jordan Harband 30a5b38f23 `String.prototype.isWellFormed`/`String.prototype.toWellFormed`: add tests 2022-12-01 16:04:31 +01:00
Philip Chimento 7ee321e76a Temporal: Reconcile yearOfWeek tests with changes to YYYY-MM-DD+UU format
This reconciles changes made in two normative PRs to the Temporal proposal
which each had their own separate PRs for tests. The yearOfWeek tests were
written before the changes to the ISO 8601 grammar which disallowed the
YYYY-MM-DD+UU format. This brings the yearOfWeek tests in line with the
tests for the other calendar methods.
2022-12-01 15:07:47 +01:00
Philip Chimento d87a7da6e1 Replace Object.hasOwnProperty.call with Object.prototype.hasOwnProperty.call
While we're at it, use assert() instead of assert.sameValue() for brevity,
if we are not specifically testing that the return value of hasOwnProperty
is the value true or false; and add more informative assertion messages to
help with debugging.

In some cases, the Object.hasOwnProperty.call could be replaced with
verifyProperty(), if the property descriptor was also being verified at
the same time.

This fixes some tests that were faulty to begin with: a common mistake was
Object.hasOwnProperty(obj, prop) which is probably going to return false
when that's not what you want.

The only instances left of `Object.hasOwnProperty` are one regression test
in implementation-contributed which I can't tell if it was intentionally
needed to trigger the regression, and a few instances of
`Object.hasOwnProperty('prototype')` which would defeat the purpose to
convert into `Object.prototype.hasOwnProperty.call(Object, 'prototype')`
form.

Closes: #3524
2022-11-30 16:04:02 -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 3775b4774b Temporal: Add tests for new yearOfWeek API
To be presented for consensus in the November/December TC39 meeting. This
adds tests for a 'yearOfWeek' getter to PlainDate, PlainDateTime, and
ZonedDateTime, for use alongside 'weekOfYear', and tests for a
corresponding method to Calendar.

The tests are basically the existing tests of 'weekOfYear' adapted.

Temporal issue: https://github.com/tc39/proposal-temporal/issues/2405
2022-11-30 10:06:53 -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 39302ea3c1 Temporal: Add test for Calendar.id with custom calendar
We already have a similar test covering TimeZone.id that ensures toString
is not called. We did not have this coverage yet for Calendar.id, so adapt
the TimeZone test for Calendar.
2022-11-29 10:57:10 -08:00
Philip Chimento 0fc42035eb Temporal: Update tests to use internal slot in TimeZone and Calendar.id
In https://github.com/tc39/proposal-temporal/pull/2411, to be proposed for
consensus in TC39 in December, the .id getter of TimeZone and Calendar
should no longer call toString().
2022-11-29 10:57: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 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 5747285940 Temporal: Observe ToString of calendar property in Temporal.PlainTime.from
Similar to the previous commit, but with a toPrimitiveObserver instead of
a calendarObserver, which would cause PlainTime.from() to throw.
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 22e01996f3 Temporal: Expand order-of-operations tests to cover different types of relativeTo
The `relativeTo` parameter in an options bag may be undefined, a PlainDate
instance, or a ZonedDateTime instance. Each of these three possibilities
causes a different set of observable operations, which we can test in our
existing order-of-operations tests.
2022-11-29 11:53:40 +01:00
Philip Chimento 1c2508e801 Temporal: Add offset field to order-of-operations tests
There are additional observable operations that occur when providing an
`offset` property in a relativeTo or ZonedDateTime property bag. We can
test these in our existing order-of-operations tests.
2022-11-29 11:53:40 +01:00
Yusuke Suzuki 83a46bfe0e
test/built-ins/TypedArray/prototype/map/callbackfn-resize.js test result is incorrect (#3721)
%TypedArray%.prototype.map's iteration count does not change even though the source view is resized during the iteration.
And since result is just returning index, then result array should be [0, 1, 2].
2022-11-18 14:17:12 -05: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 10ac2ad03e Fix esids 2022-11-16 16:32:42 -08:00
Mathias Bynens 1d5dc6b577 Remove tests involving the `Emoji_Test` property
`Emoji_Test` is not an official Unicode property of strings. Work on standardizing such a property (although likely under a different name) is happening: https://github.com/mathiasbynens/emoji-test-regex-pattern/issues/7
2022-11-10 13:51:56 +01:00
Ms2ger 0593463817 Add missed changes for Symbols as WeakMap keys proposal.
Co-authored-by: Rick Waldron <waldron.rick@gmail.com>
2022-11-08 09:44:40 -08:00
Ms2ger 745f3c01aa Add more tests for duplicated named capture groups.
Fixes #3704.
2022-11-04 10:54:28 -07:00
Ms2ger 54c9ff9084 Rename duplicate-names.js. 2022-11-04 10:54:28 -07:00
Ms2ger c3c6c86663 Fix some esids.
Ref #3705.
2022-11-03 09:20:27 -07:00
Philip Chimento 9e1907e5f7 Unicode case-folding tests
Adds a test similar to the one in #3697, but in the main tree.

The six code points in this test have an "F" for full case mapping in
CaseFolding.txt, and so they should not be considered in the
Canonicalize operation.

Current versions of SpiderMonkey and V8 fail this test, others pass.
2022-11-03 11:50:29 +01:00
Philip Chimento 27063ae219 Duplicate named capture groups: .groups and .indices.groups objects
These tests should cover the full functionality of the .groups object (and
the .indices.groups object, in the case of the /d flag) for RegExp.p.exec
and String.p.match:

- Matched DNCG has a result
- Unmatched DNCG is present and undefined
- DNCG matched in previous iteration but not in current iteration is
  treated as unmatched
- Iteration order of properties corresponds with source order

See: #3704
2022-11-02 15:22:58 +01:00
Philip Chimento fabb1fd379 Duplicate named capture groups: Fix match arrays
Each named capturing group should count as its own parenthesized capturing
group, even if it has the same name as another group. So, some of these
expectations were missing `undefined` array elements for the variant of
the `x` capturing group that didn't match.

In the other expectations, we forgot to take into account that the
backreference is not inside a capturing group, so the group match should
not have doubled letters in it.
2022-11-02 15:22:58 +01:00
Philip Chimento d77d9b2b85 Duplicate named capture groups: Syntax tests
Parse-time syntax for RegExp literals is already tested. These two files
test runtime RegExp compilation, with respect to duplicate named capture
groups.

See: #3704
2022-11-02 15:22:58 +01:00
Shu-yu Guo ade328d530 Fix toSpliced mutate-while-iterating test 2022-10-25 09:50:41 +02:00
Shu-yu Guo c15d4bef28 Add missing include to WeakSet/iterable-with-symbol-values 2022-10-24 15:50:52 -07:00
Philip Chimento b5d3192914 Temporal: Test Calendar.p.mergeFields enumeration changes
This tests 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 the
Temporal.Calendar.prototype.mergeFields method.

Due to the use of the pre-existing spec operation CopyDataProperties, now
symbol keys are merged into the return value, and 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.
2022-10-20 17:33:36 +02: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 dfbeca3c79 Temporal: Fix mergeFields test for non-string keys
Using assert.deepEqual was faulty here, since deepEqual doesn't take
symbol keys into account. This test wasn't actually testing that the
symbol keys were absent, and in fact passes if they are present.

(Rather than fixing deepEqual, since we hope to deprecate it as per
https://github.com/tc39/test262/issues/3476, add a custom assert function
in the test.)
2022-10-20 17:33:36 +02:00
Philip Chimento 1f59bf5911 Temporal: Add tests for fast path in ToTemporalTimeZone
Normally, a plain object passed into an API that takes a Temporal.TimeZone
has its 'timeZone' 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.TimeZone
internal slots.

This adds tests to all entry points that pass a user-supplied object to
ToTemporalTimeZone, with a "poisoned" timeZone object which has the
correct internal slots but a 'timeZone' 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 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 fefa14c285 Temporal: Clarify names of some time zone tests
In these tests, we should make a distinction in the name for clarity. It's
testing a time zone passed as a property in a property bag (either as an
argument, or as a relativeTo option), so name it accordingly as we do with
other tests in the same folder.
2022-10-18 14:38:38 +02:00
Linus Groh 5a858cc0c4 Add missing includes to toSorted/toReversed this-value-invalid.js tests
Otherwise $DETACHBUFFER() is not defined in those files.
2022-10-18 14:05:01 +02:00
Nicolò Ribaudo 6f4601d095
Add "Change Array by Copy" tests (stage 3) (#3464)
Co-authored-by: Ashley Claymore <acutmore@users.noreply.github.com>
Co-authored-by: Tim Chevalier <tjc@igalia.com>
Co-authored-by: Ms2ger <Ms2ger@igalia.com>
2022-10-18 10:16:20 +02:00
Philip Chimento 77b559ce68 Temporal: Fix expectation for observable operations in Duration.p.round()
I had missed that there's an early return step from
UnbalanceDurationRelative if years, months, weeks, and days are all 0.

Closes: #3684
2022-10-17 14:29:19 +02:00
Philip Chimento 554a18c34d Add tests for regular and well-known Symbols as weak values
This adds tests to WeakMap, WeakSet, WeakRef, and FinalizationRegistry for
Symbols as weakly-held values. Regular symbols and well-known symbols are
both tested. These tests correspond to existing tests for Objects as
weakly-held values, but are put in separate files so that they can be
filtered out with the "symbols-as-weakmap-keys" feature flag.

Registered symbols are not allowed; this is already tested in the "cannot-
be-held-weakly" tests.

See: #2850
2022-10-12 09:58:45 +02:00
Philip Chimento d101ab9bc4 Adapt descriptions of existing tests using Objects as weak values
There are many existing tests for WeakMap, WeakSet, WeakRef, and
FinalizationRegistry using Objects as weak values. For symbols-as-weakmap-
keys, we'll want to write tests that parallel these for Symbol keys.

Change the descriptions and filenames of these tests to describe their new
scope of only Object weak values.

Update the front matter of these tests while we're at it, to reflect the
changes to the spec text that the symbols-as-weakmap-keys brings in. (In
some cases, remove irrelevant bits of the front matter.)

See: #2850
2022-10-12 09:58:45 +02:00
Philip Chimento 6291e42a72 Adapt existing tests regarding Symbols as weak values
WeakMap, WeakSet, WeakRef, and FinalizationRegistry all had tests
verifying what would happen if they were called with a value that wasn't
allowed as a weak value: before this proposal, that was a non-Object.
Now, allowed weak values are Objects, well-known Symbols, and unregistered
Symbols. That leaves registered Symbols that are still not allowed as weak
values.

This commit updates those tests to use a registered Symbol instead of an
unregistered Symbol; they should still pass, regardless of whether the
implementation has implemented symbols-as-weakmap-keys yet.

The tests are renamed as appropriate.

Also updates the frontmatter to the most current spec text, including the
CanBeHeldWeakly abstract operation.

See: #2850
2022-10-12 09:58:45 +02:00
Rick Waldron 735f95adf5 Add WeakMap and WeakSet features to tests affected by symbols-as-weakmap-keys
Originally taken from Rick's draft commit for symbols-as-weakmap-keys
tests.
2022-10-12 09:58:45 +02:00
Rick Waldron 145c440069 Remove duplicate WeakSet test
This test is duplicated by WeakSet/prototype/add/value-not-object-throw.js

Originally taken from Rick's draft commit for symbols-as-weakmap-keys
tests.
2022-10-12 09:58:45 +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 1550f7f7e1 Temporal: Test that the offset option has the last word in ZDT.from()
The programmer always gets the last word over how the string is
interpreted, since otherwise it's not possible to make any guarantees
about the offset option. (This is the "out-of-band" mechanism mentioned in
the IETF draft.) Add a test for this.
2022-10-11 12:19:49 +02:00
Philip Chimento 6205eb529d Temporal: Add tests for ZDT#toString timeZoneName: "critical" option
See https://github.com/tc39/proposal-temporal/pull/2397
This normative change adds a new accepted value for the timeZoneName
option in ZonedDateTime.prototype.toString().
2022-10-11 12:19:49 +02:00
Philip Chimento d5404f4d24 Temporal: Improve existing tests for ZDT#toString timeZoneName option
Based on the improvements just made to the calendarName option, improve
the tests for the timeZoneName option of ZonedDateTime.prototype.toString
as well.
2022-10-11 12:19:49 +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 bf3efa65fc Temporal: Adjust relativeto-string-datetime tests
As of https://github.com/tc39/proposal-temporal/pull/2397 which reached
consensus in the August 2022 TC39 meeting, a date-time + Z with no bracket
annotation is no longer accepted as a relativeTo parameter; either the Z
should be removed or a bracket annotation should be added.

This requires adjusting a few existing tests, but doesn't require any new
ones.
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 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
Mathias Bynens 3eaa7c9313 Update RegExp `\p{…}` tests per Unicode 15
Upstream commit: 859db0d6df

Issue: https://github.com/tc39/ecma262/issues/2904
2022-09-21 11:19: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
Jordan Harband 8f19bb4a45
Fix features in tests from #3354 and #3353 2022-09-14 11:30:22 -07:00
Justin Ridgewell 9592077530 Update groupToMap tests 2022-09-14 11:38:07 -07:00
polsevev ce511219e8 add tests for array.prototype.groupByToMap 2022-09-14 11:38:07 -07:00
Justin Ridgewell e7af14502e Test callback throwing 2022-09-14 11:02:48 -07:00
Justin Ridgewell 95f869ce0d Test non-property key throws 2022-09-14 11:02:48 -07:00
Justin Ridgewell 457185507e Add test for get access throwing 2022-09-14 11:02:48 -07:00
Justin Ridgewell 6cdb375d8c Add test for length conversion 2022-09-14 11:02:48 -07:00
Justin Ridgewell 22fe1b44b2 Update group tests 2022-09-14 11:02:48 -07:00
polsevev 5bd6844df5 added tests for groupBy 2022-09-14 11:02:48 -07: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
Kevin Gibbons adba7dfd9c fix order 2022-08-09 12:15:49 -07:00
Kevin Gibbons 418419a345 add non-matching example 2022-08-09 12:15:49 -07:00
Kevin Gibbons 52284ba4bb add tests for proposal-duplicate-named-capturing-groups 2022-08-09 12:15:49 -07:00
Philip Chimento d45766bef3 Add cases to RegExp.prototype flags brand checking tests
For completeness, as we are doing in newer brand checking tests such as
those of Temporal, call these getters with a function object and a bigint
as the receiver.

Suggested in https://github.com/tc39/test262/pull/3614/files#r929662337
2022-08-09 12:07:36 -07:00
Richard Gibson 9e51a9d855 Update RegExp.prototype.{match,replace} tests to expect Get(rx, "flags")
Ref https://github.com/tc39/ecma262/pull/2791
2022-08-09 12:02:45 -07:00
Linus Groh 0f35848794 ShadowRealm: Relax requirements of globalThis available properties test
The intention of this test is to ensure that all built-in properties of
the global object are also exposed on the ShadowRealm's global object,
without penalizing implementations that don't have all of them
implemented.
Notably, SharedArrayBuffer may still not be (re-)enabled in all
circumstances.
2022-08-04 20:37:23 +02:00
Aditi e9f424b6fc Remove duplicate timezone tests 2022-08-04 11:03:46 +02:00
Yusuke Suzuki f74cee5f59 Rename Array#groupBy and Array#groupByToMap to Array#group and Array#groupToMap
TC39 decided to rename them to avoid web-compat issue[1].
This change follows to it.

[1]: https://github.com/tc39/proposal-array-grouping/pull/39
2022-08-03 13:29:11 -07: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
Kevin Gibbons 4c0322569c add tests for "only coerce once in BigInt constructor" 2022-08-02 18:17:20 -07: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
Mathias Bynens e623dd7a11
Add manually written tests for RegExp `v` flag proposal (#3614)
https://github.com/tc39/proposal-regexp-v-flag

Issue: #3496, https://github.com/tc39/proposal-regexp-v-flag/issues/52

Add more tests for the new RegExp `v` flag

Add test for combination of `u` and `v` flag
2022-07-26 10:42:06 -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
Zirak c665ccea28 Test primitive retval of Iterator and AsyncIterator getters
The existing test passed an object for a `this` value. This commit checks that
primitive values are returned verbatim, without any conversion.

Resolve #3489.
2022-07-25 13:32:57 -07:00
Aditi dadf18f416 Add tests for temporalDurationLike argument and improve existing tests 2022-07-25 13:30:46 -07:00
snek 6833180066 add SharedArrayBuffer feature to test 2022-07-22 07:04:58 -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
Mathias Bynens 67160e94a9 Remove duplicate entries from `nonMatchStrings`
https://github.com/mathiasbynens/unicode-property-escapes-tests/pull/12
2022-07-12 19:21:53 -07:00
Mathias Bynens 33ea5b6439 Move folder around 2022-07-12 19:21:53 -07:00
Mathias Bynens d361217eb7 Add tests for RegExp set notation
Set notation and extended character class functionality is part of the RegExp `v` flag proposal: https://github.com/tc39/proposal-regexp-set-notation

Issue: https://github.com/tc39/test262/issues/3496, https://github.com/tc39/proposal-regexp-set-notation/issues/52
2022-07-12 19:21:53 -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
dnalborczyk 1b3bddbeff Fix spelling in test description 2022-07-04 09:40:40 +02: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