Commit Graph

6559 Commits

Author SHA1 Message Date
Kevin Gibbons 080c5490a2
assert on the length of the backing buffer of the result 2024-03-11 22:56:22 -07:00
Kevin Gibbons 44803f799c
add test for excess padding 2024-03-11 22:51:35 -07:00
Kevin Gibbons 070d7ee87e
add tests that boxed strings are not valid values for options 2024-03-11 22:47:43 -07:00
Kevin Gibbons 6d7bd55175
address ljharb comments 2024-03-11 22:43:06 -07:00
Kevin Gibbons 911aa6173d
update detached buffer tests 2024-02-07 16:43:17 -08:00
Kevin Gibbons 07807bd544
fromBase64Into -> setFromBase64 2024-02-07 16:41:32 -08:00
Kevin Gibbons bd05e23d40
add tests for base64 proposal 2024-01-21 17:09:11 -08:00
Philip Chimento 3a7a72aef5 Temporal: Add tests for conversion of calendar and time zone IDs in constructors
Now that we don't have to deal with strings or objects as input to the
calendar ID or time zone ID parameter of constructors, we accept only the
data that actually goes into the internal slots.
2024-07-05 10:43:53 +02:00
Philip Chimento cb13595617 Temporal: Add staging test to check June 2024 API removals
This test should trip if an implementation forgets to perform the removals
that reached consensus in June 2024. (Although such an implementation
would technically comply with the specification, if you really need to do
that, please open an issue on the Temporal proposal repo rather than just
skiplisting this test.)
2024-07-05 10:43:53 +02:00
Philip Chimento bbfcfd59b0 Temporal: Port staging tests that require non-ISO calendar or non-UTC time zone
As in the previous commit, without custom calendars and time zones, some
functionality cannot be tested on implementations that don't have any
other calendars and time zones than iso8601 and UTC.

Some of the staging tests fall in this category. We take the opportunity
to port these into proper tests, in the intl402/ folder.
2024-07-05 10:43:53 +02:00
Philip Chimento efc7424844 Temporal: Don't use getISOFields() in other tests
Previously getISOFields() was used to get the exact value of the
[[Calendar]] and [[TimeZone]] internal slots, as well as to get the
reference ISO year for PlainMonthDay and reference ISO day for
PlainYearMonth.

Use calendarId and timeZoneId for the former and toString() for the
latter.
2024-07-05 10:43:53 +02:00
Philip Chimento 7e4de57437 Temporal: Remove tests for getISOFields methods 2024-07-05 10:43:53 +02:00
Philip Chimento e5ef51ba7e Temporal: Move tests into intl402/ that require non-ISO calendar or non-UTC time zone
Without custom calendars and time zones there are actually a bunch of
things that we now can't test on implementations that don't have non-ISO
calendars or non-UTC time zones. (Alternatively, we can say that these are
functionalities that those implementations don't have to implement.)
2024-07-05 10:43:53 +02:00
Philip Chimento 9671c4a613 Temporal: Test adjustments for removing calendar and time zone objects 2024-07-05 10:43:53 +02:00
Philip Chimento 5cd7e9077d Temporal: Remove calendar and time zone observers
These are no longer possible without custom objects. Also add an exception
for calendar and timeZone properties in property bag observers so they are
not treated as objects.
2024-07-05 10:43:53 +02:00
Philip Chimento 27bc974287 Temporal: Replace TemporalHelpers.specificOffsetTimeZone with offset strings 2024-07-05 10:43:53 +02:00
Philip Chimento 0a1cb1307f Temporal: Edit test descriptions that refer to Calendar and TimeZone objects 2024-07-05 10:43:53 +02:00
Philip Chimento 372527e572 Temporal: Don't pass custom calendar in helper tests
This is no longer necessary if there are no calendar objects.
2024-07-05 10:43:53 +02:00
Philip Chimento 9c6734f39b Temporal: Remove Calendar and TimeZone objects from "wrong-type" tests
Test the "wrong type of object" with Duration objects where appropriate,
otherwise just use plain objects.
2024-07-05 10:43:53 +02:00
Philip Chimento debd22a2ad Temporal: Remove tests that throw on calendar or time zone method accesses
Many tests tested some functionality while asserting that there were no
calls of calendar or time zone methods. We can continue testing the
functionality, but there are no more methods to call, so we can delete
those parts of the tests.
2024-07-05 10:43:53 +02:00
Philip Chimento 7d970fbe4e Temporal: Remove fake West Coast and Samoa time zones from TemporalHelpers
It's no longer possible to fake built-in time zones using custom objects.
So testing DST shifts will have to use real built-in time zones. Replace
TemporalHelpers.springForwardFallBackTimeZone with America/Vancouver (it
was modelled on the DST transitions in 2000) and
TemporalHelpers.crossDateLineTimeZone with Pacific/Apia (it was modelled
on the 2011 switch to the other side of the international date line.)

These tests have to move to the intl402/ folder since non-Intl-aware
implementations are allowed (but not required) to support any built-in
time zones other than UTC.
2024-07-05 10:43:53 +02:00
Philip Chimento c728e6d89e Temporal: Fix tests that unnecessarily create TimeZone or Calendar instances
In many cases we created a TimeZone or Calendar instance from a built-in
time zone or calendar. These tests can be trivially adapted to just use
the string ID.
2024-07-05 10:43:53 +02:00
Philip Chimento ea2268aa43 Temporal: Remove tests directly relating to custom calendar and time zones
These are tests that just won't apply anymore without custom calendars and
time zones.
2024-07-05 10:43:53 +02:00
Philip Chimento 6595838b3d Temporal: Remove TimeZone.p.equals method
Some of the tests can be removed altogether since they deal with what
forms of input can be passed to ToTemporalTimeZoneSlotValue. Those are
tested on every method that takes a TimeZone as input.

Other tests are still relevant, but need to move to ZonedDateTime.p.equals
where the various quirks of time zone equality can still be tested. (Some
of these still will be removed in a following commit because they use
time zone objects.)

See: #2826
2024-07-05 10:43:53 +02:00
Philip Chimento 1213ab17ec Temporal: Remove getCalendar and getTimeZone methods
Temporarily replace them with getISOFields().calendar/timeZone just to
keep the tests running until we remove Calendar and TimeZone objects
altogether.

See: tc39/proposal-temporal#2826
2024-07-05 10:43:53 +02:00
Philip Chimento 73f85aeeaf Temporal: Add tests covering options bag argument of getTimeZoneTransition 2024-07-05 10:43:53 +02:00
Philip Chimento c22fbc7b45 Temporal: Port staging tests that use next/previousTransition
See: tc39/proposal-temporal#2826
2024-07-05 10:43:53 +02:00
Philip Chimento 71877cde79 Temporal: Move tests for getNext/PreviousTransition into ZonedDateTime
See: tc39/proposal-temporal#2826
2024-07-05 10:43:53 +02:00
Philip Chimento 9ff6ac3368 Temporal: Remove tests for argument of TimeZone.p.getNext/PreviousTransition
This is being moved to a method on Temporal.ZonedDateTime.prototype. It
will not take a Temporal.Instant argument.

See: tc39/proposal-temporal#2826
2024-07-05 10:43:53 +02:00
Ioanna M Dimitriou H 673856839c
RAB: Integrate staging tests for the .findLastIndex method (#4129)
* Import relevant files from #3888

* Removing parts in resizableArrayBufferUtils.js and adding it in includes,
while adjusting usage of CollectValuesAndResize and applying review changes
from PRs for previously tested methods.
2024-07-04 13:15:53 -07:00
Ioanna M Dimitriou H 6f2eeebdcc
RAB: Integrate staging tests for the .findLast method (#4128)
* Import relevant files from #3888

* Removing parts in resizableArrayBufferUtils.js and adding it in includes,
while adjusting usage of CollectValuesAndResize and applying review changes
from PRs for previously tested methods.
2024-07-04 12:48:33 -07:00
Ioanna M Dimitriou H 105906a49c
RAB: Integrate staging tests for the .findIndex method (#4127)
* Import relevant files from #3888

* Removing parts in resizableArrayBufferUtils.js and adding it in includes,
while adjusting usage of CollectValuesAndResize and applying review changes
from PRs for previously tested methods.
2024-07-04 12:12:02 -07:00
Ioanna M Dimitriou H e023765890
RAB: Integrate staging tests for the .find method (#4126)
* Import relevant files from #3888

* Removing parts in resizableArrayBufferUtils.js and adding it in includes,
while adjusting usage of CollectValuesAndResize and applying review changes
from PRs for previously tested methods.
2024-07-04 11:05:24 -07:00
Ioanna M Dimitriou H a507aa01de
RAB: Integrate staging tests for the .filter method (#4125)
* Import relevant files from #3888

* Removing parts in resizableArrayBufferUtils.js and adding it in includes,
while adjusting usage of CollectValuesAndResize and applying review changes
from PRs for previously tested methods.

* Addresses review comment removing forgoten onlyStrict flag

a62d978ca6 (r1663298683)
2024-07-04 08:35:13 -07:00
Peter Hoddie e4f4abdcb2
Compatibility with Hardened JavaScript (#4088)
This PR proposes changes to existing test262 tests to allow them to pass under Hardened JavaScript (see Secure ECMAScript proposal and Hardened JavaScript). Moddable uses Hardened JavaScript for JavaScript runtimes on resource constrained embedded devices, including those targeted by ECMA-419.

The changes fall into four groups:

1. Replace use of new Date() with new Date(1970). Scripts running inside a Compartment cannot retrieve the current time, so new Date() throws but new Date(1970) succeeds. Very few tests need the current time, but instead simply need a Date instance.
2. Use Object.defineProperty instead of setting existing built-in properties directly, such as toString and toValue. In Hardened JavaScript, prototypes of built-in objects are frozen. Consequently, setting properties of an instance that exist on the prototype throw (Hardened JavaScript is always in strict mode).
3. Eliminate use of Math.random(). Scripts running inside a Compartment cannot generate random numbers. One test identified so far uses Math.random() in a way that can easily be replaced with a counter.
4. Narrow the scope of exception tests. Consider the following

assert.throws(TypeError, () => {
  var s1 = new Date();
  s1.toString = Boolean.prototype.toString;
  s1.toString();
});

This test passes, but only because new Date() fails by throwing a TypeError. If the invocation of the Date constructor is resolved by (1) above, then the assignment to toString fails as per (2) above. The script should be modified as below to ensure that assert.throws only tests the intended statement, s1.toString(). The modified script tests the intended functionality and passes under Hardened JavaScript

var s1 = new Date(1970);
Object.defineProperty(s1, "toString", {
  value: Boolean.prototype.toString
});
assert.throws(TypeError, () => {
  s1.toString();
});

This is an initial PR to begin the process of adapting test262 for use with Hardened JavaScript. Further changes are expected, with the vast majority likely to fall into the four groups described above.

Thank you to gibson042, kriskowal, and erights for their advice on this work.
2024-07-04 08:19:23 -07:00
Philip Chimento 3f805a1383 Temporal: Test calendar canonicalization in Temporal
Following the upstream ECMA-402 change tested in the previous commit, add
test coverage for the corresponding functionality in Temporal. Fix one
test that was erroneous.
2024-07-04 11:14:16 +02:00
Philip Chimento 31a20380b0 Intl: Test calendar canonicalization in Intl.DateTimeFormat constructor
This ECMA-402 change is already from several years ago, but lacked test
coverage: https://github.com/tc39/ecma402/pull/418
2024-07-04 11:14:16 +02:00
Linus Groh a82f5382ff Remove 'AsyncArrowFunction' test
There is no such hidden constructor, it's the same as the hidden
AsyncFunction constructor. In other words:

```js
Object.getPrototypeOf(async () => {}).constructor ===
Object.getPrototypeOf(async function () {}).constructor
```

Also add a test to ensure that %AsyncFunction.prototype% is indeed the
prototype of an async arrow function.

Closes #4044.
2024-07-04 11:03:23 +02:00
Kevin Gibbons 3d5c52e112
add tests for Math.sumPrecise (#4049)
* add tests for Math.sumPrecise

* add feature

* I hate yaml

* fix writability check
2024-07-03 08:56:34 -07:00
Philip Chimento 6626b60df6 Temporal: Make U+2212 MINUS SIGN invalid in ISO strings
These are the test adjustments corresponding to the normative PR
https://github.com/tc39/ecma262/pull/3334 which reached consensus at the
June 2024 TC39 meeting.
2024-07-03 08:50:57 -07:00
Philip Chimento 7c985a4fd9 Make U+2212 MINUS SIGN an invalid sign character for offset time zone IDs
These are the test adjustments corresponding to the normative PR
https://github.com/tc39/ecma262/pull/3334 which reached consensus at the
June 2024 TC39 meeting.
2024-07-03 08:50:57 -07:00
Ioanna M Dimitriou H d2596e2651
RAB: Integrate staging tests for the .every method (#4074)
* RAB: Integrate staging tests for the .every method
of Array.prototype and TypedArray.prototype

This is part of PR #3888 to make reviewing easier.
Includes changes to use the helper ./harness/resizableArrayBufferUtils.js

* Added missing includes

* Removed unnecessary function call.

* Apply suggestions from code review

* Applied review suggestion to the rest of the files

* Addressed forgotten review comment noting some files are missing.

https://github.com/tc39/test262/pull/4074#pullrequestreview-2046589557

Adds forgotten tests from #3888

* Addresses review comment.

* Fixed forgotten rename

* Simplify the tests and add documentation.

New approach replaces ...Helper with CollectResize to make the tests easier to understand.
In particular:
- Replaced the need for '...Helper' abstractions with a more descriptive
  function 'ResizeBufferMidIteration', which the .every method can call
  directly.
- Moved 'let values' back outside of the loops, together with a function
  definition 'ResizeBufferMidIteration' to persist the side effects that
  'CollectValuesAndResize' has on 'values' but without having to define
  this inside every loop.
  + So this reverts commit d9a2bac41f87f0964a43d34c6f349b6d78401633 and
  + this reverts commit 0bc2d66335671cac56912981b73c7900bf309cee.
- Added documentation.

* Documentation style change and remove accidental additions.
2024-06-28 16:42:09 -07:00
Nicolò Ribaudo 03852c962b
Avoid duplicate binding import-source-binding-name.js (#4121) 2024-06-28 15:14:23 +02:00
SUZUKI Sosuke 27b2551c00
Add test to check `nfOptions.roundingMode` for seconds / microseconds / nanoseconds is `"trunc"` (#4115)
* Test that `nfOptions.roundingMode` for seconds / microseconds / nanoseconds is `"trunc"`

* Add license header

* Use `Intl.NumberFormat` instead of `testintl.js` harness

* Use correct harness
2024-06-27 10:08:11 -07:00
Chengzhong Wu 8a2229cde8
Add tests for Source Phase Imports (#3980) 2024-06-27 14:58:04 +02:00
Frank Yung-Fong Tang c3a326ace8
Add test for ECMA402 PR833 Allow locale based ignorePunctuation default (#3922)
* Add test for ECMA402 833

https://github.com/tc39/ecma402/pull/833

* Update test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-default.js

Co-authored-by: André Bargull <andre.bargull@gmail.com>

* Update test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-default.js

Co-authored-by: André Bargull <andre.bargull@gmail.com>

---------

Co-authored-by: André Bargull <andre.bargull@gmail.com>
2024-06-26 17:40:01 -07:00
Ioanna M Dimitriou H c2815ec090
RAB: Integrate staging tests for .fill method (#4075)
RAB: Integrate staging tests for the .fill method
of Array.prototype and TypedArray.prototype

This is part of PR #3888 to make reviewing easier.
Includes changes to use the helper ./harness/resizableArrayBufferUtils.js
2024-06-26 16:26:22 -07:00
Ioanna M Dimitriou H cbdff1ca5f
RAB: Integrate staging tests for the .entries method (#4073)
RAB: Integrate staging tests for the .entries method
of Array.prototype and TypedArray.prototype

This is part of PR #3888 to make reviewing easier.
Includes changes to use the helper ./harness/resizableArrayBufferUtils.js
2024-06-26 16:12:35 -07:00
Ioanna M Dimitriou H d7b2f4acfc
RAB: Integrate staging tests for .copyWithin method (#4072)
RAB: Integrate staging tests for .copyWithin method
of Array.prototype and TypedArray.prototype

This is part of PR #3888 to make reviewing easier.
Includes changes to use the helper ./harness/resizableArrayBufferUtils.js
2024-06-26 16:05:45 -07:00
André Bargull c47b716e8d Update harness tests for Float16Array
Fixes #4029
2024-06-24 17:02:39 +02:00