Commit Graph

355 Commits

Author SHA1 Message Date
Kevin Gibbons 67a5153cf5
add Float16Array to all generic TypedArray tests (#3849) 2024-01-10 14:07:57 +01:00
Philip Chimento 50abc12d97 Temporal: Remove BigInt arithmetic and loops in UnbalanceDurationRelative 2023-11-16 11:08:42 -08:00
Philip Chimento dab8ccc5df Temporal: Add more coverage for non-ISO PlainMonthDay underspecification
Built-in non-ISO calendars require either monthCode/day, or month/day plus
some form of year specification.

This adds test coverage for each of the categories listed in
https://github.com/tc39/proposal-temporal/issues/2664, of which some must
currently reside in the test/intl402/ folders.
2023-10-26 12:37:43 -04:00
Philip Chimento 8bc3dbb234 Temporal: Move non-ISO calendar tests to intl402/
We'll do this for now, then separately work on migrating all of the tests
that require a non-ISO8601 calendar but aren't dependent on it being any
particular calendar.
2023-10-26 12:37:43 -04:00
Richard Gibson 5c629683f2 Temporal: Update PlainMonthDay-related tests
As of https://github.com/tc39/proposal-temporal/pull/2500 ,
year is always optional for the ISO 8601 calendar.
2023-10-26 12:37:43 -04:00
André Bargull 9f5938bc15 Fix harness tests for verifyProperty 2023-10-02 11:27:59 +02:00
André Bargull 534decc36d Fix typos in calls to verifyProperty
And update verifyProperty to catch misspelled descriptor fields.
2023-09-13 16:05:40 +02:00
André Bargull b4f72feb52 Verify object value in addition to descriptor value in verifyProperty 2023-09-13 16:05:40 +02:00
Philip Chimento f44bbe4035 Temporal: Avoid calling user code in no-op round operations
This shortcut path now exists in all round(), since(), and until()
operations.
In Instant, PlainDate, PlainDateTime, and PlainTime, the change isn't
observable, so no tests could be added. This adds test coverage for

- Duration.p.round()
- PlainYearMonth.p.since()
- PlainYearMonth.p.until()
- ZonedDateTime.p.round()
- ZonedDateTime.p.since()
- ZonedDateTime.p.until()

As well as a few cases where we are testing that certain calendar methods
get called during a round operation, but previously were doing so with
options that now become a no-op and no longer call those calendar methods.
In those cases, round to 2 ns, rather than 1 ns.
2023-09-13 10:57:43 +02:00
Philip Chimento 5c7f4009dc Temporal Helpers: Avoid observable calendar ID lookup in OneShiftTimeZone
This toString() call would observably get the `id` property of the
plainDateTime's calendar object. Not good for the tests that I am writing
that verify observable calls!
2023-09-08 09:38:14 -07:00
Mathias Bynens 1a0b9d23f2 Add tests ensuring the latest Unicode Emoji standard is being followed
The behavior of `/\p{RGI_Emoji}/v` and other properties of strings depends on the Unicode & Emoji version being used in the JavaScript engine. This patch adds tests verifying new additions to `RGI_Emoji` for each release of the Unicode Emoji standard are correctly matched.
2023-08-28 16:31:57 +02:00
André Bargull 71091f1541 Use simplified PartitionDurationFormatPattern to computed expected results 2023-08-28 16:18:47 +02:00
Frank Yung-Fong Tang 9437cab774 Normative: Add new numbering system "kawi" and "nagm"
Adding tests for https://github.com/tc39/ecma402/pull/714
2023-07-25 10:00:13 +02:00
Guillaume Emont 016e4bf8e8
Temporal Issue 2532 (#3858)
* Add tests for the new PrepareTemporalFields behavior for all direct callers

See https://github.com/tc39/proposal-temporal/pull/2570

* Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalDate

* Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalDateTime

* Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalZonedDateTime

* Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalYearMonth

* Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalMonthDay

* Add tests for the new PrepareTemporalFields behavior for indirect callers through ToRelativeTemporalObject

* Add tests for the new PrepareTemporalFields behavior for indirect callers through AddDurationToOrSubtractDurationFromPlainYearMonth
2023-07-17 07:55:34 -07:00
Justin Grant 20e442011c Update temporalHelpers.js
* Fix SpecificOffsetTimeZone so that it correctly implements the time
  zone protocol. Previously, tests were passing but not actually
  exercising the expected codepaths.
* Add assertDateDuration function, which makes it shorter to assert
  durations that only contain date components.
2023-07-11 11:45:19 +02:00
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
Philip Chimento b4c0aeda20 Bring existing toString options tests in sync with each other
Of the toString() methods that have options for printing a time with
seconds and fractional seconds, PlainTime seems to have the most
comprehensive set of tests. Bring all the others (Duration, Instant,
PlainDateTime, and ZonedDateTime) in sync with PlainTime, and edit the
PlainTime ones where necessary to include improvements from the others.

Tests:
  - fractionalseconddigits-invalid-string.js: copy and expand on
    PlainTime's more comprehensive set of invalid strings. Add assertion
    message. Fix front matter.
  - fractionalseconddigits-non-integer.js: Fix front matter.
  - fractionalseconddigits-out-of-range.js: make sure infinity is tested.
    Add assertion messages. Fix front matter.
  - fractionalseconddigits-undefined.js: copy PlainTime's more
    comprehensive test with whole minutes, whole seconds, and subseconds.
    Copy PlainTime's test of an empty function object. Add more
    descriptive variable names and assertion messages. Fix front matter.
  - fractionalseconddigits-wrong-type.js: inline and delete TemporalHelper
    used here; it was only good for this test anyway. Improve assertion
    messages.
  - smallestunit-valid-units.js: copy PlainTime's test with a second value
    with zero seconds even. Refactor repetitive tests into a loop. Copy
    the invalid unit "era" from the Instant test. Add assertion messages.
2022-04-13 10:46:20 +02:00
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
Philip Chimento 16ad841e7e Fix arithmetic in TemporalHelpers.oneShiftTimeZone
I made a mistake with one of the signs in one of the time zones that we
use for verifying DST handling. Luckily this didn't affect any previously
existing tests, but it affected some new tests that I'm going to add in
the next commit.

How do I know that _this_ arithmetic is correct? I feel reasonably
confident with the added test.
2022-04-04 16:24:17 -04:00
Mike Pennisi 276e79d62e Deprecate some property helpers
Document the preference for `verifyProperty` over the various other
property-related helper functions.
2022-04-04 11:28:37 -04:00
Philip Chimento 9af34ce28c Rewrite tests that relied on previous branding behaviour
A follow up to the previous commit, this rewrites some tests that relied
on the lack of brand checks for certain Temporal.TimeZone methods.
https://github.com/tc39/proposal-temporal/pull/1693 added brand checks to
these methods.

We can no longer use a plain object time zone or even a Proxy with a real
branded Temporal.TimeZone object as its handler to do these tests, so we
instead create an instance of Temporal.TimeZone and define own accessor
properties on it in order to test the observable property accesses that we
need to see according to the spec text.

This requires an improvement to TemporalHelpers.observeProperty() in order
to be able to log property accesses to Symbol-valued properties.
2022-02-08 15:43:25 -05:00
Mathias Bynens 489a9f8d52 Add tests for \p{…} with properties of strings
This functionality is part of the RegExp `v` flag proposal: https://github.com/tc39/proposal-regexp-set-notation
2022-01-04 09:31:37 -05:00
Philip Chimento 2d1a1b159e Fix parameter names in TemporalHelpers.calendarDateAddUndefinedOptions
I used kind of misleading parameter names in this function, they are not
"one" and "two" of the same thing, but a Temporal.PlainDate and a
Temporal.Duration.
2021-12-14 13:46:13 -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 cba42e88c7 Tests for string shorthand API in round() and total()
Tests for the normative changes made to Temporal in
https://github.com/tc39/proposal-temporal/pull/1875

For convenience, adds some functions to TemporalHelpers to assert that two
Temporal objects are equal, for Duration, Instant, PlainDateTime,
PlainTime, and ZonedDateTime.
2021-11-16 17:06:06 -05:00
Rick Waldron b1f3390fe4
Features: remove duplicate "cleanupSome" feature (#2892)
* Features: remove duplicate "cleanupSome" feature

* Replace feature flag in harness file

Co-authored-by: Mike Pennisi <mike@mikepennisi.com>
2021-11-04 13:27:30 -04:00
Mike Pennisi f782971ad2 Remove harness file, arrayContains.js
The `arrayContains` function has a number of deficiencies which make it
inappropriate for Test262:

- It apparently isn't very useful: despite being available for over 7
  years, fewer than ten tests use it
- It's misleading: its documentation reads, "Verify that a subArray is
  contained within an array." In reality, it only verifies that all the
  elements of one array are present in another--order does not matter.
- It's not ergonomic for test authors: it has been misused to create
  tests that were prone to false positives [1]
- It's not ergonomic for implementers: ostensibly designed for use with
  `assert`, the failure messages produced by tests that use it do not
  necessarily have very much context

All code in the "harness" directory adds to the total amount of
project-specific information which contributors are expected to to
learn. In light of the above deficiencies, the burden of this particular
harness file is unjustified.

Remove the harness file and its associated tests. Update the tests which
depend on it to express their expectations using alternate methods, and
strengthen the tests to assert element order wherever appropriate.

[1] https://github.com/tc39/test262/pull/3289
2021-11-01 12:55:10 -04:00
rwaldron addfd8bf3d fix: ensure that symbol args as message don't break assert.compareArray 2021-10-05 15:16:53 -04:00
Philip Chimento 77a34cf93f Add Temporal tests
This copies over the tests that previously existed in the
tc39/proposal-temporal repository.

For context, see thread starting at:
https://github.com/tc39/test262/issues/3002#issuecomment-926234480

In service of https://github.com/tc39/test262/issues/3002
2021-10-01 14:30:12 -04:00
Rick Waldron b3158bce51
fix: corrections to assert.compareArray and assert.compareArray.format (#3226) 2021-10-01 12:52:15 -04:00
Mike Pennisi d9ddf80479 Revert "Merge pull request #3219 from tc39/rwaldron/migrate-comparearray"
This reverts commit b690cb67be, reversing
changes made to 50dd431dff. This is
necessary because the reverted changeset reduced coverage by an unknown
extent.
2021-10-01 10:18:47 -04:00
rwaldron a81a2a2b1f fix: ensure that assert.compareArray doesn't iterate and evaluate actual and expected more than once, unless absolutely necessary. 2021-09-24 14:26:04 -04:00
rwaldron 1feafce8ce chore: change name of argument 2021-09-24 13:59:02 -04:00
rwaldron 92dad8d640 chore: use [].map.call instead of spread 2021-09-24 13:52:37 -04:00
rwaldron 78554b2dac fix: update assert.compareArray.format to accept "spreadable" 2021-09-24 11:21:44 -04:00
Leo Balter 61bd4e9453 Add identity tests for the assert.throws 2021-09-21 16:45:27 -04:00
André Bargull 71460edfeb Add helper functions to retrieve all calendars, collations, numberingSystems, and simple sanctioned units
And then use these helpers to replace hard-coded lists in other tests.
2021-09-08 09:29:06 -04:00
Rick Waldron 6540b15597
chore: migrate $ERROR -> throw new Test262Error in .jshintrc, harness/sta.js (#3122) 2021-07-29 12:38:45 -07:00
rwaldron 488eb365db chore: migrate $ERROR -> throw new Test262Error in harness/ & test/harness 2021-07-21 15:15:55 -04:00
Frank Yung-Fong Tang bd03c96b60 porting over the Temporal asserts to temporalHelpers.js
Per suggestion by https://github.com/tc39/test262/pull/3049#discussion_r672675461
2021-07-21 09:10:40 -04:00
jugglinmike 162e8be99f
Add tests for Temporal.now.plainDateTime (#3037)
* Temporal.now.plainDateTime: import tests from prop

* Add required metadata

* Correct invalid test

Ensure the error is thrown due to the invocation of the provided method.
Add a separate test to verify how the method is invoked.

* Remove duplicated assertions

* Improve coverage

* Rewrite test to focus on Calendar parameter

The observable interactions with the "timeZone" parameter are verified
by another test which is named for that purpose.

* Remove non-standard test

This test's title suggests that it was intended to verify the behavior
when the "calendar" parameter was undefined. The expected behavior in
that case depends on the presence of a builtin calendar named
"undefined." Test262 cannot definitively assert the presence or absence
of such a calendar.

In contrast to the title, the test body actually uses the calendar name
"japanese."  Test262 cannot definitively assert the presence or absence
of such a calendar.
2021-07-16 09:25:55 -04:00
Paul Bakker a6a895db12
Remove usage of rest and default parameters in harness (#3034)
Also see https://github.com/tc39/test262/issues/3032
2021-07-02 09:04:13 -04:00
Frank Yung-Fong Tang 9997a26c7d
Fix tests on {localeMatcher: "lookup"} (#3008)
* Fix test for only {localeMatcher: "lookup"}

The expectation that "sr-Thai-RS" would be returned is only true with the 
9.2.2 BestAvailableLocale ( availableLocales, locale )
https://tc39.es/ecma402/#sec-bestavailablelocale
algorithm used by 9.2.3 LookupMatcher ( availableLocales, requestedLocales )
https://tc39.es/ecma402/#sec-lookupmatcher

The default for localeMatcher is "best fit" but not "lookup" for all Intl objects.

And for 9.2.4 BestFitMatcher ( availableLocales, requestedLocales )
https://tc39.es/ecma402/#sec-bestfitmatcher
It may not match "sr-Thai-RS" for "sr"  and return ["de", "zh-CN"] instead. Therefore, we need to change this test to only test on {localeMatcher: "lookup"}

* Add option to getLocaleSupportInfo

Needed to test different localeMatcher

* only test for "lookup" localeMatcher

* Get the info based on the localeMatcher

* pass in localeMatcher to getLocaleSupportInfo
2021-06-24 13:37:33 -04:00
Linus Groh 10fc95cacb
Don't use function argument destructuring in regExpUtils.js (#3000)
This increases compatibility with less advanced engines that only have
partial support for recent language features like assignment patterns.
2021-05-28 19:47:36 -04:00
Frank Yung-Fong Tang f9a834c05e Update testIntl.js 2020-12-16 11:59:06 -05:00
Rick Waldron 0e7319c015 atomicsHelper.js: Add $262.agent.setTimeout to defines 2020-10-19 17:48:00 -04:00
Rick Waldron 6d8ab9c35e Coverage: more Atomics.waitAsync tests, fixes, improved messages. 2020-10-08 17:25:45 -04:00
Rick Waldron 04517c7ded Remove erroneous ArrowFunction 2020-10-07 16:43:48 -04:00
Rick Waldron 8aacff591c Standardize built-in constructor testing 2020-10-06 12:01:34 -04:00
Rick Waldron 8250b886b0 Create "Test262Error.thrower" as replacement for "$ERROR". Define $ERROR as Test262Error.thrower 2020-09-16 17:36:54 -04:00
Yusuke Suzuki e8cdf923ef Property clearing code of RegExp constructor is wrong
This code is setting values to $1 etc., which can be non-writable or accessors.
For example, https://github.com/tc39/proposal-regexp-legacy-features/ is specifying them as accessors, and they should throw an error when
it is done in strict code. We should execute `(/(?:)/).test("");` to clear them.
2020-09-02 15:32:18 -04:00