Commit Graph

6146 Commits

Author SHA1 Message Date
Frank Tang 576c0c0c7f Make minimumFractionDigits = maximumFractionDigits
Make minimumFractionDigits equal to maximumFractionDigits while
roundingIncrement != 1 to sync with latest spec change in
https://github.com/tc39/proposal-intl-numberformat-v3/pull/85
which landed to spec text in Feb 22, 2022
2022-04-25 11:35:24 -04:00
Philip Chimento 8a1ec2f20b Test ISO strings with extended year -000000
In Date.parse() and new Date(), representations of the year 0 as -000000
must not be accepted. In the case of Date.parse(), they should yield NaN,
and in the case of new Date(), they should yield an invalid Date object,
whose valueOf() is NaN.
2022-04-25 11:34:52 -04:00
Jesse Alama 1b71018adb Temporal: `PlainDateTime`: Port Demitasse tests for bounds 2022-04-25 12:22:49 +02:00
Jesse Alama cba02351f8 Temporal: Port Demitasse tests for PlainDateTime toZonedDateTime 2022-04-25 12:16:46 +02:00
rwaldron 45fa0063e0 CI: disable graaljs test run 2022-04-25 11:44:14 +02:00
Ms2ger efcac4c05a Temporal: Port some Duration tests. 2022-04-25 11:07:11 +02:00
Philip Chimento 78c6ec7f1c Test wrong types in conversions to Temporal types
These tests cover, for every API entry point where a Temporal object is
expected, what happens when a value of a different type is passed in that
can't be converted.

Most entry points can convert a string to the expected Temporal type, and
will do ToString on any non-Object argument, and throw RangeError if the
result isn't a string that's convertible to that Temporal type. ToString
will throw TypeError on a Symbol.

Most entry points also take a property bag, and will throw TypeError if
the property bag doesn't have the required properties.

We also have to test for TimeZone and Calendar what happens if the wrong
type is provided as the value of a 'timeZone' or 'calendar' property in
another property bag, up to one level of nested properties.
2022-04-21 12:14:10 -07:00
Philip Chimento afce1b3fde Test conversion of Number to Temporal objects
Adds tests for conversion of a Number whose corresponding toString() value
is a valid ISO string. For some Temporal types this is possible, with a
number like 20220418.

Especially for Temporal.Calendar, we have to take into account the case
where the number is provided as the value for the 'calendar' property in a
property bag, and the case of up to one level of nested property bag as
well.

Regularizes and expands existing tests for this case.
2022-04-21 12:14:10 -07:00
Philip Chimento a38d3f3b67 Add missing test for Temporal.ZonedDateTime constructor
The test for a TimeZone created from an ISO string with multiple offsets
was missing from the Temporal.ZonedDateTime constructor, whereas it was
present for several other APIs. Add it.
2022-04-21 12:14:10 -07:00
Philip Chimento 7b3c176629 Add missing tests for PlainTime property bag with no time units
We already had similar tests to these for other methods, such as
Temporal.PlainTime.prototype.equals(). since() and until() should have
these tests too.

Update assertion messages in all of the existing tests as well, as per
Ms2ger's review comment.
2022-04-21 12:14:10 -07:00
Philip Chimento 15ed94c891 Test conversion of object to string in Temporal.Instant context
An object may be given in any context where a Temporal.Instant is expected
(see ToTemporalInstant). There is no conversion from a property bag to an
Instant, unlike with other Temporal types. Instead the object is converted
to a string, and if its toString() method yields a valid ISO string, the
conversion succeeds. (An object with the default Object.prototype.toString
will not.)
2022-04-21 12:14:10 -07:00
Philip Chimento d28ca991cb Test conversion of Temporal.Instant strings with sub-minute UTC offsets 2022-04-21 12:14:10 -07:00
Philip Chimento 9cd27beb12 Test basic functionality of Temporal.Instant.from 2022-04-21 12:14:10 -07:00
Philip Chimento 4fdb4ee52f Fix invocations of some Temporal methods
We should make sure that we are providing the correct arguments to these
methods even if they are supposed to throw; they should throw for the
reason we expect, and not because we provided the wrong arguments.
2022-04-21 12:14:10 -07:00
Philip Chimento c82e2782e6 Regularize some quotes
Some of the similar tests to these use double quotes, some use single.
2022-04-21 12:14:10 -07:00
Jesse Alama 089c74ce59 Temporal: Port `PlainDateTime`'s `from` tests 2022-04-19 11:13:01 -07:00
Philip Chimento b68c751f5b Replace deepEqual with compareArray
Here is one place where compareArray is better fit for purpose, because we
are comparing an array.
2022-04-19 12:16:03 -04:00
Jordan Harband f0bf5dfcea parseInt: fix description typo 2022-04-15 18:17:02 -04:00
Jordan Harband 4bbe20d52c add missing TypedArray feature 2022-04-15 18:17:02 -04:00
Jesse Alama 33a5433d1b Temporal: PlainDateTime: Port Demitasse `until` and `since` tests
Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
2022-04-15 10:49:18 -07:00
Ms2ger 84679fd7ed
Temporal: Add a test for PlainDateTime#withPlainDate with intl calendars. (#3483) 2022-04-15 10:47:38 -07:00
Ms2ger ff5af6fccf Temporal: Consolidate tests for invalid string argument to round(). 2022-04-15 10:12:19 -07:00
Shu-yu Guo 1c19242ae4 Remove check for per-iteration detach check in TypedArray.prototype.set
Note that this test currently unintentionally passes, because a
TypeError is thrown for failing to convert the undefined returned from
the getter to a BigInt. But since this test was intended to test
detaching, it's no longer valid and should still be removed.

See https://github.com/tc39/test262/pull/3465#issuecomment-1098388916
2022-04-13 21:24:57 -04:00
Ms2ger 4dafd2158b Temporal: Remove some stray arguments to TemporalHelpers.assertDuration. 2022-04-13 09:37:35 -07:00
Ms2ger c35ae2099d
Temporal: Some more tests for PlainDateTime#with. (#3481) 2022-04-13 09:31:57 -07:00
Philip Chimento d9616ed91f Add tests for direction of rounding functionality
The round() and toString() methods of Temporal.Instant, PlainDateTime, and
ZonedDateTime can round up or down. However, the instance must not be
treated as "negative" even when the time is before 1 BCE (years are
negative) or before the Unix epoch (epoch nanoseconds are negative). That
is, rounding down is always towards the Big Bang, and rounding up is
always away from it. Add tests that verify this.
2022-04-13 10:46:20 +02:00
Philip Chimento 3905c0c80a Expand toString() rounding tests from PlainTime to cover other types
This takes the tests of the rounding functionality of
Temporal.PlainTime.p.toString() and adds similar tests covering the
equivalent functionality to Duration, Instant, PlainDateTime, and
ZonedDateTime: all the types that have rounding and precision controls
for how they output their subsecond values.

It also takes the opportunity to improve the existing PlainTime tests:

- fractionalseconddigits-auto.js: More descriptive variable names. Added
  assertion messages.
- fractionalseconddigits-number.js: Ditto.
- rounding-cross-midnight.js: Use constructor directly to remove coupling
  with from().
- roundingmode-*.js: Add additional tests for specifying the precision
  using fractionalSecondDigits.
- smallestunit-fractionalseconddigits.js: Add assertion messages.
2022-04-13 10:46:20 +02:00
Philip Chimento 4ac16c2589 Add tests for Temporal options bags being of the wrong type
This consolidates the few existing tests for options bags in Temporal
being of the wrong type, and adds them for every entry point in Temporal
that accepts an options bag.

These are mostly identical tests, but there is a variation for methods
like round() where either an options bag or string is accepted.
2022-04-13 10:46:20 +02:00
Philip Chimento 9f303112bd Repeat Instant.p.toString() test with timeZone parameter for IANA time zones
This adds to the intl402/ tree a copy of
built-ins/Temporal/Instant/prototype/toString/timezone-offset.js but which
uses IANA time zones.
2022-04-13 10:46:20 +02:00
Philip Chimento 9b2c98c02b Bring existing "invalid string" tests for smallestUnit and largestUnit in sync
Add a consistent set of invalid strings for all of the
smallestunit-invalid-string.js and largestunit-invalid-string.js tests:
- "era" and "eraYear" in singular and plural
- all of the units that are disallowed for that particular method call, in
  singular and plural
- an allowed unit with \0 at the end
- an allowed unit with an "i" replaced by a dotless i
- an allowed unit but with all-caps
- an unrelated string.
2022-04-13 10:46:20 +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
Ms2ger 2c880bf5c1 Temporal: Some more tests for PlainDateTime.compare. 2022-04-12 10:33:20 -07:00
Ms2ger a226601d12 Temporal: Some more tests for PlainDateTime#withPlainDate. 2022-04-12 10:10:04 -07:00
Ms2ger 7823be3e96 Temporal: Move test with typo in name. 2022-04-12 10:10:04 -07:00
Ms2ger 62e0130447
Temporal: Some more tests for PlainDateTime#equals. (#3479) 2022-04-12 10:02:53 -07:00
Jesse Alama 5f1aba63ee
Temporal: Port Demitasse PlainDateTime `round` tests (#3478)
Co-authored-by: Ms2ger <Ms2ger@gmail.com>
2022-04-12 17:36:03 +02:00
rwaldron 9055521fc7 ShadowRealm: fix for incorrect test 2022-04-11 13:25:42 -04:00
Mike Pennisi d4ede37b67 Add assertions for functions with infinite length
A prior version of ECMA262 described invalid mathematical operations
with infinite values [1]. Update the test metadata to reflect the
corrected specification text, and add two assertions for the obsolete
conditions.

[1] ".bind on a function with infinite length has imprecise spec and
    engine divergences"
    https://github.com/tc39/ecma262/issues/2170
2022-04-11 13:12:42 -04:00
rwaldron 24e4eb09da ShadowRealm: add more tests for globalThis ordinary object conformance 2022-04-11 12:59:01 -04:00
Shu-yu Guo d7c0a2076c Remove check for per-comparator call detach check in TypedArray.prototype.sort
This updates tests in line with the normative change in
https://github.com/tc39/ecma262/pull/2723
2022-04-05 11:25:05 -04:00
Shu-yu Guo 3ac6b73369 Add test that TypedArray.prototype.set doesn't throw if a getter for an element detaches 2022-04-05 11:18:45 -04:00
Shu-yu Guo 8b29141224 Remove check for per-iteration detach check in TypedArray.prototype.set
This updates tests in line with the normative change in
https://github.com/tc39/ecma262/pull/2646
2022-04-05 11:18:45 -04:00
rwaldron f60d7cf67d fixup! Fix false negative in for-in test 2022-04-05 11:18:45 -04:00
rwaldron 384a4e1368 Fix false negative in for-in test
As originally written, this test would spuriously pass when the deleted
property was incorrectly visited by enumation but correctly removed from
the object. In such cases, the accumulator string would take the form

    "aa1baundefinedca3"

And satisfy all conditions intended to highlight implementation errors.

Refactor the test to avoid false negative by using an object with a null
prototype and verifying the exact contents of the accumulator string.
2022-04-05 11:18:10 -04:00
Mike Pennisi 3c88e9b619 Fix false negative in for-in test
As originally written, this test would spuriously pass when the deleted
property was incorrectly visited by enumation but correctly removed from
the object. In such cases, the accumulator string would take the form

    "aa1baundefinedca3"

And satisfy all conditions intended to highlight implementation errors.

Refactor the test to avoid false negative by using an object with a null
prototype and verifying the exact contents of the accumulator string.
2022-04-05 11:15:21 -04:00
Philip Chimento 833a784f20 Tests for computing PlainYearMonth addition and subtraction in correct calendar space
https://github.com/tc39/proposal-temporal/pull/2003 is a normative change
that reached consensus at the March 2022 TC39 plenary meeting. This adds
tests that verify the new spec text is implemented correctly, performing
arithmetic on a PlainYearMonth instance that would previously have thrown
an error if it was implemented as written.
2022-04-04 16:58:09 -04:00
Richard Gibson c58ac691eb Test that "infinity" is not recognized as numeric 2022-04-04 16:56:40 -04:00
Richard Gibson c572588ea9 Test that "INFINITY" is not recognized as numeric
Fixes #3442
2022-04-04 16:56:40 -04:00
Shu-yu Guo 51822ff2d8 Update Symbol.species tests for TypedArray constructor
This updates tests in line with
https://github.com/tc39/ecma262/pull/2719
2022-04-04 16:52:23 -04:00
Philip Chimento da507a703e Tests for Temporal formatting the year appropriately as 4 or 6 digits
https://github.com/tc39/proposal-temporal/pull/2090 is a normative change
that reached consensus at the March 2022 TC39 plenary meeting. This adds
tests that verify the change made to the formatting of years between 0 and
999 inclusive in all toString and toJSON methods of Temporal types that
can output an ISO year number in their return value.
2022-04-04 16:36:03 -04:00