Commit Graph

2523 Commits

Author SHA1 Message Date
Philip Chimento 0a6341de65 Temporal: Call user code on relativeTo only when necessary in RoundDuration 2023-09-13 10:57:43 +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
Peter Klecha 1db9a49eb9 address comments 2023-09-08 16:31:50 -07:00
Peter Klecha 2a4c458002 Update test/built-ins/Promise/withResolvers/ctx-ctor.js
Co-authored-by: Linus Groh <mail@linusgroh.de>
2023-09-08 16:31:50 -07:00
Peter Klecha 998f811e58 Update test/built-ins/Promise/withResolvers/ctx-non-ctor.js
Co-authored-by: Ms2ger <Ms2ger@gmail.com>
2023-09-08 16:31:50 -07:00
Peter Klecha 15e0933cb5 Update test/built-ins/Promise/withResolvers/result.js
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2023-09-08 16:31:50 -07:00
Peter Klecha 8f8aa971d8 Update test/built-ins/Promise/withResolvers/result.js
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2023-09-08 16:31:50 -07:00
Peter Klecha ab0d665192 Update test/built-ins/Promise/withResolvers/result.js
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2023-09-08 16:31:50 -07:00
Peter Klecha d2ac342089 include esids 2023-09-08 16:31:50 -07:00
Peter Klecha 81ba258677 add tests for Promise.withResolvers proposal 2023-09-08 16:31:50 -07:00
Philip Chimento e04e1c1a39 Temporal: Fix front matter of Temporal/ZonedDateTime/p/round/order-of-operations.js 2023-09-08 09:38:14 -07:00
Philip Chimento d4f49b84ab Temporal: Update outdated test descriptions 2023-09-08 09:38:14 -07:00
Philip Chimento 6c16577f34 Temporal: Remove unused variables
These are also leftovers from the recent refactor, I think.
2023-09-08 09:38:14 -07:00
Philip Chimento ce92940645 Temporal: Improve various assertion messages
Some of these were overlooked in a recent big refactor.
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
Jordan Harband eb613f6891 use proper isConstructor check for recently added ArrayBuffer/SharedArrayBuffer tests 2023-08-25 15:31:27 +02:00
Michael Ficarra 9efb4f8e53 update iterator helpers tests that passed even in noncompliant impls 2023-08-24 13:09:05 -07:00
André Bargull e273cd470a Add tests for recursively calling IteratorHelper generators 2023-08-24 12:44:04 -07:00
Kevin Gibbons 8a7b686502 add test for regexp matching with zero-length quantified matches 2023-08-24 10:47:01 +02:00
Aditi bdddd9e2d2 Update test for monthDayFromFields() 2023-08-21 09:14:43 -07:00
Philip Chimento c30aff08af Temporal: Copy options object in Plain{Date,MonthDay,YearMonth}.{from,p.with} 2023-08-16 14:49:15 -07:00
Philip Chimento 5ecb902a0a Temporal: Copy options object in {Plain,Zoned}DateTime.{from,p.with} 2023-08-16 14:49:15 -07:00
Philip Chimento 01a49502f6 Temporal: Get receiver fields from a PlainDateTime in ZonedDateTime.with() 2023-08-16 14:49:15 -07:00
Philip Chimento 4155594804 Temporal: Get receiver's time units from internal slots in with() 2023-08-16 14:49:15 -07:00
Philip Chimento 4b4de778d4 Temporal: Limit allowed values for Calendar.fields to date units 2023-08-16 14:49:15 -07:00
Philip Chimento c372de0bbe Temporal: Avoid recalculating offset ns after GetPlainDateTimeFor 2023-08-16 14:49:15 -07:00
Justin Grant 0c87a86b58 Disallow sub-minute annotations in Instant strings
Adds tests that verify that Instant strings cannot include offset time
zone annotations with sub-minute units.

Also removes a few staging test cases that, due to a polyfill bug, were
incorrectly passing.
2023-08-10 15:45:34 +02:00
Justin Grant 2e4e0e6b8e Test ISO sub-minute offsets, incl. trailing zeroes
Plugs a test hole where we were not fully testing ISO strings with
sub-minute offsets, in particular those with trailing zeroes.
2023-08-10 10:13:27 +02:00
Justin Grant 2e1d7a72ff Test rejecting ISO strings with subminute offsets
This commit verifies that ISO strings with sub-minute offsets cannot
be parsed into time zone identifiers. This was a change introduced in
the recently-merged tc39/proposal-temporal#2607, but tests for this case
were missing from #3862 (the tests for that PR).

I noticed in codecov results on an unrelated PR that this case wasn't
being tested, so fixing that mistake now.
2023-08-09 11:37:39 -07:00
Justin Grant 29dde1ce0e Tests for new API Temporal.TimeZone.p.equals 2023-08-07 15:01:16 -07:00
Justin Grant a53f190e1f Add ZonedDateTime tests for proposal-canonical-tz 2023-08-07 15:01:16 -07:00
Justin Grant 425716345f Test Temporal.Instant w/ trailing zeroes in offset
I noticed a small test hole in codecov: we weren't testing
Temporal.Instant parsing with trailing zeroes in the offset.
I also didn't see fractional offset testing, so added that too.
2023-07-27 12:52:25 +02:00
Justin Grant c84752415d Test PlainTime without full ISO strings
Codecov showed that PlainTime strings like "09:00:00Z[UTC]" or
"09:00:00Z" were not being tested. This commit fills that gap.

It'd probably be good to make similar changes for other Plain* types,
but Codecov didn't complain about them so they may be covered
via other tests so it was less urgent.
2023-07-25 09:36:18 +02:00
Justin Grant e8bbfe704f Ensure that non-string TimeZone IDs will throw
This commit fills a test hole found by Codecov: we weren't checking for
the case of a custom time zone whose `id` property returns a non-string
value.

Note that the `id` property is only read in a few places, all on the
ZonedDateTime prototype: `until`, `since`, `equals`, `toString`,
`toLocaleString`, `toJSON`, and `timeZoneId`.
2023-07-25 09:30:37 +02:00
Justin Grant 6f146e6f30 Limit offset time zones to minute precision
Modify/add tests for https://github.com/tc39/proposal-temporal/pull/2607
2023-07-18 17:44:19 +02:00
Justin Grant 60e475248d Tests for Temporal PR #2574
Edits Temporal tests to account for changes in
https://github.com/tc39/proposal-temporal/pull/2574.

This PR stops coercing non-string primitive inputs to strings
in Temporal methods, to avoid cases where numbers
are coerced to syntactically valid but often unexpected
string results.
2023-07-18 17:09:04 +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
Michael Ficarra 550c11163e
add tests for tc39/proposal-iterator-helpers#281 (#3869)
Co-authored-by: Ms2ger <Ms2ger@igalia.com>
2023-07-13 16:04:33 +02:00
André Bargull 8ce9864511 Add copy of transfer/transferToFixedLength tests with resizable-arraybuffer features removed 2023-07-03 15:10:04 +02:00
André Bargull 9ac846e0b9 Remove "resizable-arraybuffer" from ArrayBuffer transfer tests
Also adds missing "arraybuffer-transfer" feature flags.
2023-07-03 15:10:04 +02:00
Shu-yu Guo 2f0193d4cf Add missing iterator-helpers feature flag 2023-06-15 20:18:14 +02:00
Rick Waldron dfc7ce4c28
Iterator Helpers (#2818)
drop:

property descriptor
name
length
[[Prototype]]
is a function
is not constructible
result instanceof Iterator
limit is given a non-primitive that needs to be converted to a number
  through valueOf
  through toString (array)
limit coercion to number throws
limit converts to NaN
  same as limit not supplied
limit behaves properly
  limit < number of values
  limit = number of values
  limit > number of values
gets the next method from the underlying iterator only once
underlying iterator has throwing next getter
underlying iterator next throws when advancing past dropped items
underlying iterator is advanced after calling drop
underlying iterator is closed after calling drop
underlying iterator is already closed
underlying iterator next returns non-object
underlying iterator next returns object with throwing done/value getters
underlying iterator return is never called when result iterator is closed

every:

property descriptor
name
length
[[Prototype]]
is a function
is callable
is not constructible
result is a Boolean
predicate is non-callable
iterator already exhausted
called on non-object
called on object with "next" method
called on object with non-callable "next" method
predicate returns non-Boolean
predicate returns truthy for all iterated values
  returns true
predicate returns truthy for some iterated values but then falsey for at least one iterated value
  returns false
  iteration stops
  iterator is closed
predicate returns falsey immediately
  returns false
  iteration stops
  iterator is closed
predicate throws
  every throws
  iterator is closed
predicate throws then iterator close also throws
predicate this value is undefined
predicate is passed the yielded value as the first parameter and a counter as second parameter
gets the next method from the iterator only once
iterator has throwing next getter
iterator has throwing return getter
iterator next throws
iterator return throws
iterator next returns non-object
iterator next returns object with throwing done/value getters

Co-authored-by: Michael Ficarra <mficarra@shapesecurity.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2023-06-15 17:07:41 +02:00
Shu-yu Guo e337fc9506 Remove old Array group tests 2023-06-15 10:23:02 +02:00
Jordan Harband c5b24c64c3
groupBy: fix throwing iterator tests
Fixes #3852
2023-06-13 19:56:17 -07:00
Philip Chimento 63e451dc80 Temporal: Tests for malicious time zones with zero-length days
Based on test cases provided by Anba in
https://github.com/tc39/proposal-temporal/issues/2333. (Thanks!)
2023-05-31 09:11:25 -07:00
Jordan Harband feb6f107f8 Convert Array.prototype.groupToMap tests to Map.groupBy tests 2023-05-31 08:32:28 -07:00
Jordan Harband 49237f30de Convert Array.prototype.group tests to Object.groupBy tests 2023-05-31 08:32:28 -07:00
Philip Chimento 3e858ef02d Tests for multiple calendar annotations with at least one critical
As per IETF review, an IXDTF string (ISO 8601 with annotations) is no
longer valid if it contains more than one u-ca annotation and at least one
of the annotations is marked critical.

Removes tests where such a string was assumed to be valid, and adds new
ones with a few variations on invalid strings.
2023-05-24 13:12:40 -07:00
Mathias Bynens 1010e63caf Add tests for RegExp `v` flag errors that were allowed with `u`
https://github.com/tc39/proposal-regexp-v-flag#how-is-the-v-flag-different-from-the-u-flag

Issue: #3496
Issue: https://github.com/tc39/proposal-regexp-v-flag/issues/52
2023-05-01 23:34:57 -07:00
Guillaume Emont 72c0c5e163 Added new tests to reflect the change that daysInMonth is the count of days in a month
This change affects how PlainYearMonth's add and subtract behave. They
now ignore daysInMonth reimplementations in the calendar, and they call
dateadd() a different number of times.

See https://github.com/tc39/proposal-temporal/issues/1315
2023-04-28 12:16:41 -07:00