Skip to content

Commit

Permalink
Add a host-reliant Intl.DateTimeFormat
Browse files Browse the repository at this point in the history
Ref tc39/ecma402#709 (comment)

Passes relevant tests after minor modification:
```sh
$ npm run test:test262 -- --extended-tests --run-slow-tests $(
    find $(
      find test/test262/test262/ -type d -a '(' -iname '*intl*' -o -iname '*402*' ')' -prune | \
      tee /dev/stderr \
    ) -iname '*date*' -prune | \
    grep -viE 'temporal|\bdate\b|\bsupportedValuesOf\b|\bDisplayName'
  )
test/test262/test262/test/staging/Intl402
test/test262/test262/test/intl402
test/test262/test262/implementation-contributed/v8/intl
test/test262/test262/implementation-contributed/v8/test262/local-tests/test/intl402

> @engine262/[email protected] test:test262
> node --enable-source-maps test/test262/test262.js --extended-tests --run-slow-tests test/test262/test262/test/intl402/DateTimeFormat test/test262/test262/test/intl402/Intl/DateTimeFormat test/test262/test262/implementation-contributed/v8/test262/local-tests/test/intl402/DateTimeFormat

 engine262 Test Runner
 Detected 4 CPUs
 Not running on CI

[00:04|:  342|+  322|-    0|»   20] (68.00/s)

$ pushd test/test262/test262/ && git diff; popd
diff --git i/harness/testIntl.js w/harness/testIntl.js
index 286ccd129e..f674055e2c 100644
--- i/harness/testIntl.js
+++ w/harness/testIntl.js
@@ -42,7 +42,8 @@ defines:
  *   @param {Function} Constructor the constructor object to test with.
  */
 function testWithIntlConstructors(f) {
-  var constructors = ["Collator", "NumberFormat", "DateTimeFormat"];
+  // engine262 does not yet implement Collator or NumberFormat.
+  var constructors = [/*"Collator", "NumberFormat",*/ "DateTimeFormat"];

   // Optionally supported Intl constructors.
   // NB: Intl.Locale isn't an Intl service constructor!
diff --git i/implementation-contributed/v8/test262/local-tests/test/intl402/DateTimeFormat/12.1.1_1.js w/implementation-contributed/v8/test262/local-tests/test/intl402/DateTimeFormat/12.1.1_1.js
index 64845e74a9..bee9c5cf53 100644
--- i/implementation-contributed/v8/test262/local-tests/test/intl402/DateTimeFormat/12.1.1_1.js
+++ w/implementation-contributed/v8/test262/local-tests/test/intl402/DateTimeFormat/12.1.1_1.js
@@ -11,7 +11,8 @@ includes: [testIntl.js]
 testWithIntlConstructors(function (Constructor) {
     var obj, newObj;

-    if (Constructor === Intl.DateTimeFormat) {
+    // engine262 does not implement ChainDateTimeFormat (which is normative-optional).
+    if (false && Constructor === Intl.DateTimeFormat) {
       obj = new Constructor();
       newObj = Intl.DateTimeFormat.call(obj);
       if (obj !== newObj) {
diff --git i/test/intl402/DateTimeFormat/date-time-options.js w/test/intl402/DateTimeFormat/date-time-options.js
index 7d9ef93d20..8c8502fc3b 100644
--- i/test/intl402/DateTimeFormat/date-time-options.js
+++ w/test/intl402/DateTimeFormat/date-time-options.js
@@ -36,6 +36,8 @@ function testWithDateTimeFormat(options, expected) {
 }

 function testWithToLocale(f, options, expected) {
+    // engine262 does not yet implement Intl-integrated Date.prototype.toLocaleString.
+    return;
     // expected can be either one subset or an array of possible subsets
     if (expected.length === undefined) {
         expected = [expected];
```
  • Loading branch information
gibson042 committed Jan 16, 2023
1 parent 642bdce commit d2db5d1
Show file tree
Hide file tree
Showing 5 changed files with 407 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/abstract-ops/realms.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { bootstrapFunctionPrototype } from '../intrinsics/FunctionPrototype.mjs'
import { bootstrapFunction } from '../intrinsics/Function.mjs';
import { bootstrapSymbolPrototype } from '../intrinsics/SymbolPrototype.mjs';
import { bootstrapSymbol } from '../intrinsics/Symbol.mjs';
import { bootstrapIntl } from '../intrinsics/Intl.mjs';
import { bootstrapMath } from '../intrinsics/Math.mjs';
import { bootstrapDatePrototype } from '../intrinsics/DatePrototype.mjs';
import { bootstrapDate } from '../intrinsics/Date.mjs';
Expand Down Expand Up @@ -204,6 +205,7 @@ export function CreateIntrinsics(realmRec) {

bootstrapReflect(realmRec);

bootstrapIntl(realmRec);
bootstrapMath(realmRec);

bootstrapDatePrototype(realmRec);
Expand Down Expand Up @@ -356,6 +358,7 @@ export function SetDefaultGlobalBindings(realmRec) {

// Other Properties of the Global Object
// 'Atomics',
...(realmRec.Intrinsics['%Intl%'] ? [ 'Intl' ] : []),
'JSON',
'Math',
'Reflect',
Expand Down
4 changes: 2 additions & 2 deletions src/intrinsics/ArrayPrototype.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function ArrayProto_keys(args, { thisValue }) {
}

/** http://tc39.es/ecma262/#sec-array.prototype.map */
function ArrayProto_map([callbackfn = Value.undefined, thisArg = Value.undefined], { thisValue }) {
export function ArrayProto_map([callbackfn = Value.undefined, thisArg = Value.undefined], { thisValue }) {
const O = Q(ToObject(thisValue));
const len = Q(LengthOfArrayLike(O));
if (IsCallable(callbackfn) === Value.false) {
Expand Down Expand Up @@ -346,7 +346,7 @@ function ArrayProto_shift(args, { thisValue }) {
}

/** http://tc39.es/ecma262/#sec-array.prototype.slice */
function ArrayProto_slice([start = Value.undefined, end = Value.undefined], { thisValue }) {
export function ArrayProto_slice([start = Value.undefined, end = Value.undefined], { thisValue }) {
const O = Q(ToObject(thisValue));
const len = Q(LengthOfArrayLike(O));
const relativeStart = Q(ToIntegerOrInfinity(start));
Expand Down
2 changes: 1 addition & 1 deletion src/intrinsics/Date.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function DateConstructor(args, { NewTarget }) {
}

/** http://tc39.es/ecma262/#sec-date.now */
function Date_now() {
export function Date_now() {
const now = Date.now();
return F(now);
}
Expand Down
Loading

0 comments on commit d2db5d1

Please sign in to comment.