Commit Graph

607 Commits

Author SHA1 Message Date
Romulo Cintra b17b9411e0 Update DurationFormat and FormatToParts tests
https://github.com/tc39/proposal-intl-duration-format/pull/126
2023-02-08 10:53:17 -08:00
Romulo Cintra 780b7b806e Add test to approximately format 2023-02-07 17:14:06 -08:00
Timothy Flynn f5e2214b30 Swap call order of NumberFormat's notation and roundingIncrement options
The order in which these options are read was changed in commit:
29acfc6c3f
2023-02-07 16:14:13 -08:00
Richard Gibson 788bc809bf
Update DateTimeFormat proleptic Gregorian testing to include era (#3722)
Ref https://github.com/tc39/ecma402/issues/723
2023-02-01 11:50:39 -05:00
Philip Chimento 374aac475d Regularize "calendar-case-insensitive" tests
For each entry point where a string calendar name is accepted, we should
have a test that ensures the calendar name is case-insensitive. These
tests existed but several were incomplete as they didn't take nested
properties into account, and several entry points were missing this test.

Fix a minor copy-paste issue with double semicolons.
2023-02-01 10:50:12 +01:00
Richard Gibson 8700c92095 Temporal: Remove subsumed intl402 custom Calendar/TimeZone tests 2023-01-31 17:17:28 -08:00
Richard Gibson ea10ca0cc6 Temporal: Add intl402 custom Calendar/TimeZone tests to cover rejection of invalid output 2023-01-31 17:17:28 -08:00
Justin Grant 2ac0d3c47b Final batch of CLDR backwards-compatibility fixes
Following up on #3751 and #3762, this commit makes a few tests
work on both CLDR 42 and CLDR 41. Previously these tests were
tied to a specific CLDR 42 format.
2023-01-11 10:22:26 +01:00
Justin Grant 2c599b020e Fix more 402 Temporal tests broken by ICU72/CLDR42
Fixes 4 more Temporal-related tests that break in ICU 72 / CLDR 42.

Follows up on https://github.com/tc39/test262/pull/3676 and
https://github.com/tc39/test262/pull/3751.
2023-01-10 10:30:51 -08:00
Ms2ger 6fcebf2f85 Improve NumberFormat and DateTimeFormat tests for OrdinaryHasInstance 2023-01-03 12:40:48 -08:00
Frank Yung-Fong Tang dac6956348
sync with duration-format PR130 (#3752)
https://github.com/tc39/proposal-intl-duration-format/pull/130
2022-12-14 16:08:52 +01:00
Timothy Flynn e6c6460a5b Update Intl.NumberFormat test with recent reorder of option evaluation
The order of evaluation for "notation" and "roundingIncrement" changed
in https://github.com/tc39/proposal-intl-numberformat-v3/commit/a260aa3.
2022-12-12 12:15:53 +01:00
Justin Grant d8bc356d01 Fix Temporal test failures under Node 19 2022-12-10 11:33:20 -05:00
Richard Gibson 8cd563f978
Intl: Add substantive tests for Array.prototype.toLocaleString (#3741) 2022-12-05 10:51:55 +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
André Bargull 7988e3eb65 Update expected results for CLDR 42 2022-11-29 11:59:25 +01: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
Philip Chimento 85373b4ce1 Temporal: Fix PlainDateTime construct args
I discovered these tests had omitted some arguments to the PlainDateTime
constructor, leaving the calendar in the wrong position.

The tests were technically not incorrect, since the operation
ToIntegerThrowOnInfinity on the string "gregory" gives 0. But they could
spuriously pass if the implementation didn't do argument conversion
correctly, failed to throw on eraYear being ±Infinity, but subsequently
threw RangeError anyway because the calendars of the arguments didn't
match.
2022-10-26 15:20:05 +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
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 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
Frank Yung-Fong Tang 58b7a23582 Sync to intl-duration-format PR 119
Sync to https://github.com/tc39/proposal-intl-duration-format/pull/119
Use "unit" type for listFormat
2022-09-28 13:58:09 -07: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
Romulo Cintra 1714f231c7 Update:RangeError when useGrouping is string 'undefined' 2022-09-20 09:53:18 -07: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 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
Frank Yung-Fong Tang 4569e73420
Fix DurationFormat default tests (#3640)
1. add the test for "seconds"
2. since the default value for "style" is "long", baseStyle for GetDurationUnitOptions is "long" and therefore the 
last argument in testOption should be "long"
3. the valid values for "days" does not contains  "numeric", and "2-digit". remove them. 
4. the valid values for "milliseconds", "microseconds" and "nanoseconds" does not contains "2-digit". remove it.

See https://tc39.es/proposal-intl-duration-format/#table-duration-components about the valid value
notice the last colum is for "Digital Default" while the baseStyle is "digital" but the set up does not set it that way, the default value for "style" is "long" as in
```
13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "long").
```
of https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat

* Sync to PR 121

Change default from "long" to "short"
2022-09-14 12:51:40 -07:00
Frank Yung-Fong Tang 03cff7fcba Remove undefined to sync to PR 113
undefined is no longer value output for resolvedOptions().fractionalDigits
2022-09-14 12:42:53 -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 cf51de578f Add calendar case insensitive tests 2022-09-13 11:32:16 -07:00
Romulo Cintra f1870753fa Update Tests accoring with spec changes 2022-09-05 11:05:44 +02:00
André Bargull d7a10658d9 Replace time zone link name canonicalisation tests
Replace tests with more simple tests that only ensure link names are
accepted.
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 7d31aa21ad Temporal: Add basic IANA-time-zone-aware tests for TimeZone.getPlainDateTimeFor
This adds several tests for values that should be produced by the time
zone database and should not be subject to change in the future. This
tests basic functionality of TimeZone.getPlainDateTimeFor with an IANA
time zone database.
2022-08-01 13:48:11 -07:00
Philip Chimento 8ea8e3f15d Temporal: Add tests for IANA legacy name time zones
Aside from the ones that were already tested in etc-timezones.js, this
adds a test for other IANA legacy names.

Previously these were supported in the TimeZone constructor, but not in
from().

See https://github.com/tc39/proposal-temporal/pull/2292 which is a
normative change that achieved consensus at the July 2022 TC39 meeting.
2022-07-28 12:00:29 -07:00
Philip Chimento 5cb596f191 Temporal: Perform TimeZone 'Etc/GMT±NN' tests for from() as well
The Etc/GMT±... time zones should be accepted in from() as well as the
TimeZone constructor. Previously this was not the case for +0 and -0 due
to those being IANA legacy names.

This basically copies the existing test file for the TimeZone constructor,
and performs the same tests for TimeZone.from().

See https://github.com/tc39/proposal-temporal/pull/2292 which is a
normative change that achieved consensus at the July 2022 TC39 meeting.
2022-07-28 12:00:29 -07:00
André Bargull 12b7b5c916 Temporal: tests for out-of-range time zone transitions
This normative change reached consensus in the July 2022 TC39 meeting:
https://github.com/tc39/proposal-temporal/pull/2351
2022-07-25 13:33:32 -07:00
Frank Yung-Fong Tang e41d581c6d Sync with pull/100 of intl-numberformat-v3
https://github.com/tc39/proposal-intl-numberformat-v3/pull/100/files
2022-07-25 12:40:18 -07:00
Frank Yung-Fong Tang ab29fd3225
Sync to PR701 (#3609)
In 2022-07-20 TC39 we decide to take 
https://github.com/tc39/ecma402/pull/701 and not check the order of the x and y 
see https://docs.google.com/presentation/d/1UUvbf3FFu9PGtrPAKPdMad9DZuVFLIvkAsAxyJZyvxM/ for details
2022-07-21 13:30:08 -07:00