mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 23:14:47 +02:00
commit
ada5db7569
@ -1147,6 +1147,43 @@ function testValidDateTimeComponentValue(component, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Tests whether timeZone is a String value representing a
|
||||||
|
* structurally valid and canonicalized time zone name, as defined in
|
||||||
|
* sections 6.4.1 and 6.4.2 of the ECMAScript Internationalization API
|
||||||
|
* Specification.
|
||||||
|
* @param {String} timeZone the string to be tested.
|
||||||
|
* @result {Boolean} whether the test succeeded.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isCanonicalizedStructurallyValidTimeZoneName(timeZone) {
|
||||||
|
/**
|
||||||
|
* Regular expression defining IANA Time Zone names.
|
||||||
|
*
|
||||||
|
* Spec: IANA Time Zone Database, Theory file
|
||||||
|
*/
|
||||||
|
var fileNameComponent = "(?:[A-Za-z_]|\\.(?!\\.?(?:/|$)))[A-Za-z.\\-_]{0,13}";
|
||||||
|
var fileName = fileNameComponent + "(?:/" + fileNameComponent + ")*";
|
||||||
|
var etcName = "(?:Etc/)?GMT[+-]\\d{1,2}";
|
||||||
|
var systemVName = "SystemV/[A-Z]{3}\\d{1,2}(?:[A-Z]{3})?";
|
||||||
|
var legacyName = etcName + "|" + systemVName + "|CST6CDT|EST5EDT|MST7MDT|PST8PDT|NZ|Canada/East-Saskatchewan";
|
||||||
|
var zoneNamePattern = new RegExp("^(?:" + fileName + "|" + legacyName + ")$");
|
||||||
|
|
||||||
|
if (typeof timeZone !== "string") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 6.4.2 CanonicalizeTimeZoneName (timeZone), step 3
|
||||||
|
if (timeZone === "UTC") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 6.4.2 CanonicalizeTimeZoneName (timeZone), step 3
|
||||||
|
if (timeZone === "Etc/UTC" || timeZone === "Etc/GMT") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return zoneNamePattern.test(timeZone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that the actual array matches the expected one in length, elements,
|
* Verifies that the actual array matches the expected one in length, elements,
|
||||||
* and element order.
|
* and element order.
|
||||||
|
@ -3,40 +3,27 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 10.1.1_1
|
es5id: 10.1.1_1
|
||||||
description: Tests that an object can't be re-initialized as a Collator.
|
description: Tests that the this-value is ignored in Collator.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testIntl.js]
|
includes: [testIntl.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithIntlConstructors(function (Constructor) {
|
testWithIntlConstructors(function (Constructor) {
|
||||||
var obj, error;
|
var obj, newObj;
|
||||||
|
|
||||||
// variant 1: use constructor in a "new" expression
|
// variant 1: use constructor in a "new" expression
|
||||||
obj = new Constructor();
|
obj = new Constructor();
|
||||||
try {
|
newObj = Intl.Collator.call(obj);
|
||||||
Intl.Collator.call(obj);
|
if (obj === newObj) {
|
||||||
} catch (e) {
|
$ERROR("Collator object created with \"new\" was not ignored as this-value.");
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Re-initializing object created with \"new\" as Collator was not rejected.");
|
|
||||||
} else if (error.name !== "TypeError") {
|
|
||||||
$ERROR("Re-initializing object created with \"new\" as Collator was rejected with wrong error " + error.name + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
// variant 2: use constructor as a function
|
// variant 2: use constructor as a function
|
||||||
obj = Constructor.call({});
|
obj = Constructor();
|
||||||
error = undefined;
|
newObj = Intl.Collator.call(obj);
|
||||||
try {
|
if (obj === newObj) {
|
||||||
Intl.Collator.call(obj);
|
$ERROR("Collator object created with constructor as function was not ignored as this-value.");
|
||||||
} catch (e) {
|
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Re-initializing object created with constructor as function as Collator was not rejected.");
|
|
||||||
} else if (error.name !== "TypeError") {
|
|
||||||
$ERROR("Re-initializing object created with constructor as function as Collator was rejected with wrong error " + error.name + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 10.1.2.1_4
|
es5id: 10.1.2.1_4
|
||||||
description: >
|
description: >
|
||||||
Tests that for non-object values passed as this to Collator a
|
Tests that non-object values passed as this to Collator are ignored
|
||||||
wrapper object will be initialized and returned.
|
and a normal collator object will be initialized and returned.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -15,15 +15,14 @@ var a = ["A", "C", "E", "B", "D", "F"];
|
|||||||
var referenceCollator = new Intl.Collator(locales);
|
var referenceCollator = new Intl.Collator(locales);
|
||||||
var referenceSorted = a.slice().sort(referenceCollator.compare);
|
var referenceSorted = a.slice().sort(referenceCollator.compare);
|
||||||
|
|
||||||
function MyCollator(locales, options) {
|
class MyCollator extends Intl.Collator {
|
||||||
Intl.Collator.call(this, locales, options);
|
constructor(locales, options) {
|
||||||
|
super(locales, options);
|
||||||
// could initialize MyCollator properties
|
// could initialize MyCollator properties
|
||||||
|
}
|
||||||
|
// could add methods to MyCollator.prototype
|
||||||
}
|
}
|
||||||
|
|
||||||
MyCollator.prototype = Object.create(Intl.Collator.prototype);
|
|
||||||
MyCollator.prototype.constructor = MyCollator;
|
|
||||||
// could add methods to MyCollator.prototype
|
|
||||||
|
|
||||||
var collator = new MyCollator(locales);
|
var collator = new MyCollator(locales);
|
||||||
a.sort(collator.compare);
|
a.sort(collator.compare);
|
||||||
testArraysAreSame(referenceSorted, a);
|
testArraysAreSame(referenceSorted, a);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 10.1_L15
|
es5id: 10.1_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.Collator meets the requirements for built-in
|
Tests that Intl.Collator meets the requirements for built-in
|
||||||
objects defined by the introduction of chapter 15 of the
|
objects defined by the introduction of chapter 17 of the
|
||||||
ECMAScript Language Specification.
|
ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 10.2.2_L15
|
es5id: 10.2.2_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.Collator.supportedLocalesOf meets the
|
Tests that Intl.Collator.supportedLocalesOf meets the
|
||||||
requirements for built-in objects defined by the introduction of
|
requirements for built-in objects defined by the introduction of
|
||||||
chapter 15 of the ECMAScript Language Specification.
|
chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
es5id: 10.3.2_1_a_L15
|
es5id: 10.3.2_1_a_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that the function returned by
|
Tests that the function returned by
|
||||||
Intl.Collator.prototype.compare meets the requirements for
|
Intl.Collator.prototype.compare meets the requirements for
|
||||||
built-in objects defined by the introduction of chapter 15 of the
|
built-in objects defined by the introduction of chapter 17 of the
|
||||||
ECMAScript Language Specification.
|
ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 10.3.2_L15
|
es5id: 10.3.2_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that the getter for Intl.Collator.prototype.compare meets
|
Tests that the getter for Intl.Collator.prototype.compare meets
|
||||||
the requirements for built-in objects defined by the introduction
|
the requirements for built-in objects defined by the introduction
|
||||||
of chapter 15 of the ECMAScript Language Specification.
|
of chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 10.3.3_L15
|
es5id: 10.3.3_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.Collator.prototype.resolvedOptions meets the
|
Tests that Intl.Collator.prototype.resolvedOptions meets the
|
||||||
requirements for built-in objects defined by the introduction of
|
requirements for built-in objects defined by the introduction of
|
||||||
chapter 15 of the ECMAScript Language Specification.
|
chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 10.3_L15
|
es5id: 10.3_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.Collator.prototype meets the requirements for
|
Tests that Intl.Collator.prototype meets the requirements for
|
||||||
built-in objects defined by the introduction of chapter 15 of the
|
built-in objects defined by the introduction of chapter 17 of the
|
||||||
ECMAScript Language Specification.
|
ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -3,40 +3,27 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.1_1
|
es5id: 11.1.1_1
|
||||||
description: Tests that an object can't be re-initialized as a NumberFormat.
|
description: Tests that the this-value is ignored in NumberFormat.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testIntl.js]
|
includes: [testIntl.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithIntlConstructors(function (Constructor) {
|
testWithIntlConstructors(function (Constructor) {
|
||||||
var obj, error;
|
var obj, newObj;
|
||||||
|
|
||||||
// variant 1: use constructor in a "new" expression
|
// variant 1: use constructor in a "new" expression
|
||||||
obj = new Constructor();
|
obj = new Constructor();
|
||||||
try {
|
newObj = Intl.NumberFormat.call(obj);
|
||||||
Intl.NumberFormat.call(obj);
|
if (obj === newObj) {
|
||||||
} catch (e) {
|
$ERROR("NumberFormat object created with \"new\" was not ignored as this-value.");
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Re-initializing object created with \"new\" as NumberFormat was not rejected.");
|
|
||||||
} else if (error.name !== "TypeError") {
|
|
||||||
$ERROR("Re-initializing object created with \"new\" as NumberFormat was rejected with wrong error " + error.name + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
// variant 2: use constructor as a function
|
// variant 2: use constructor as a function
|
||||||
obj = Constructor.call({});
|
obj = Constructor();
|
||||||
error = undefined;
|
newObj = Intl.NumberFormat.call(obj);
|
||||||
try {
|
if (obj === newObj) {
|
||||||
Intl.NumberFormat.call(obj);
|
$ERROR("NumberFormat object created with constructor as function was not ignored as this-value.");
|
||||||
} catch (e) {
|
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Re-initializing object created with constructor as function as NumberFormat was not rejected.");
|
|
||||||
} else if (error.name !== "TypeError") {
|
|
||||||
$ERROR("Re-initializing object created with constructor as function as NumberFormat was rejected with wrong error " + error.name + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 11.1.2.1_4
|
es5id: 11.1.2.1_4
|
||||||
description: >
|
description: >
|
||||||
Tests that for non-object values passed as this to NumberFormat a
|
Tests that non-object values passed as this to NumberFormat are ignored
|
||||||
wrapper object will be initialized and returned.
|
and a normal number format object will be initialized and returned.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -15,15 +15,14 @@ var a = [0, 1, -1, -123456.789, -Infinity, NaN];
|
|||||||
var referenceNumberFormat = new Intl.NumberFormat(locales);
|
var referenceNumberFormat = new Intl.NumberFormat(locales);
|
||||||
var referenceFormatted = a.map(referenceNumberFormat.format);
|
var referenceFormatted = a.map(referenceNumberFormat.format);
|
||||||
|
|
||||||
function MyNumberFormat(locales, options) {
|
class MyNumberFormat extends Intl.NumberFormat {
|
||||||
Intl.NumberFormat.call(this, locales, options);
|
constructor(locales, options) {
|
||||||
|
super(locales, options);
|
||||||
// could initialize MyNumberFormat properties
|
// could initialize MyNumberFormat properties
|
||||||
|
}
|
||||||
|
// could add methods to MyNumberFormat.prototype
|
||||||
}
|
}
|
||||||
|
|
||||||
MyNumberFormat.prototype = Object.create(Intl.NumberFormat.prototype);
|
|
||||||
MyNumberFormat.prototype.constructor = MyNumberFormat;
|
|
||||||
// could add methods to MyNumberFormat.prototype
|
|
||||||
|
|
||||||
var format = new MyNumberFormat(locales);
|
var format = new MyNumberFormat(locales);
|
||||||
var actual = a.map(format.format);
|
var actual = a.map(format.format);
|
||||||
testArraysAreSame(referenceFormatted, actual);
|
testArraysAreSame(referenceFormatted, actual);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 11.1_L15
|
es5id: 11.1_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.NumberFormat meets the requirements for built-in
|
Tests that Intl.NumberFormat meets the requirements for built-in
|
||||||
objects defined by the introduction of chapter 15 of the
|
objects defined by the introduction of chapter 17 of the
|
||||||
ECMAScript Language Specification.
|
ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 11.2.2_L15
|
es5id: 11.2.2_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.NumberFormat.supportedLocalesOf meets the
|
Tests that Intl.NumberFormat.supportedLocalesOf meets the
|
||||||
requirements for built-in objects defined by the introduction of
|
requirements for built-in objects defined by the introduction of
|
||||||
chapter 15 of the ECMAScript Language Specification.
|
chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
es5id: 11.3.2_1_a_L15
|
es5id: 11.3.2_1_a_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that the function returned by
|
Tests that the function returned by
|
||||||
Intl.NumberFormat.prototype.format meets the requirements for
|
Intl.NumberFormat.prototype.format meets the requirements for
|
||||||
built-in objects defined by the introduction of chapter 15 of the
|
built-in objects defined by the introduction of chapter 17 of the
|
||||||
ECMAScript Language Specification.
|
ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -6,7 +6,7 @@ es5id: 11.3.2_L15
|
|||||||
description: >
|
description: >
|
||||||
Tests that the getter for Intl.NumberFormat.prototype.format
|
Tests that the getter for Intl.NumberFormat.prototype.format
|
||||||
meets the requirements for built-in objects defined by the
|
meets the requirements for built-in objects defined by the
|
||||||
introduction of chapter 15 of the ECMAScript Language
|
introduction of chapter 17 of the ECMAScript Language
|
||||||
Specification.
|
Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 11.3.3_L15
|
es5id: 11.3.3_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.NumberFormat.prototype.resolvedOptions meets the
|
Tests that Intl.NumberFormat.prototype.resolvedOptions meets the
|
||||||
requirements for built-in objects defined by the introduction of
|
requirements for built-in objects defined by the introduction of
|
||||||
chapter 15 of the ECMAScript Language Specification.
|
chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 11.3_L15
|
es5id: 11.3_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.NumberFormat.prototype meets the requirements for
|
Tests that Intl.NumberFormat.prototype meets the requirements for
|
||||||
built-in objects defined by the introduction of chapter 15 of the
|
built-in objects defined by the introduction of chapter 17 of the
|
||||||
ECMAScript Language Specification.
|
ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -3,40 +3,27 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 12.1.1_1
|
es5id: 12.1.1_1
|
||||||
description: Tests that an object can't be re-initialized as a DateTimeFormat.
|
description: Tests that the this-value is ignored in DateTimeFormat.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testIntl.js]
|
includes: [testIntl.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithIntlConstructors(function (Constructor) {
|
testWithIntlConstructors(function (Constructor) {
|
||||||
var obj, error;
|
var obj, newObj;
|
||||||
|
|
||||||
// variant 1: use constructor in a "new" expression
|
// variant 1: use constructor in a "new" expression
|
||||||
obj = new Constructor();
|
obj = new Constructor();
|
||||||
try {
|
newObj = Intl.DateTimeFormat.call(obj);
|
||||||
Intl.DateTimeFormat.call(obj);
|
if (obj === newObj) {
|
||||||
} catch (e) {
|
$ERROR("DateTimeFormat object created with \"new\" was not ignored as this-value.");
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Re-initializing object created with \"new\" as DateTimeFormat was not rejected.");
|
|
||||||
} else if (error.name !== "TypeError") {
|
|
||||||
$ERROR("Re-initializing object created with \"new\" as DateTimeFormat was rejected with wrong error " + error.name + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
// variant 2: use constructor as a function
|
// variant 2: use constructor as a function
|
||||||
obj = Constructor.call({});
|
obj = Constructor();
|
||||||
error = undefined;
|
newObj = Intl.DateTimeFormat.call(obj);
|
||||||
try {
|
if (obj === newObj) {
|
||||||
Intl.DateTimeFormat.call(obj);
|
$ERROR("DateTimeFormat object created with constructor as function was not ignored as this-value.");
|
||||||
} catch (e) {
|
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Re-initializing object created with constructor as function as DateTimeFormat was not rejected.");
|
|
||||||
} else if (error.name !== "TypeError") {
|
|
||||||
$ERROR("Re-initializing object created with constructor as function as DateTimeFormat was rejected with wrong error " + error.name + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.1.2.1_4
|
es5id: 12.1.2.1_4
|
||||||
description: >
|
description: >
|
||||||
Tests that for non-object values passed as this to DateTimeFormat
|
Tests that non-object values passed as this to DateTimeFormat are ignored
|
||||||
a wrapper object will be initialized and returned.
|
and a normal date-time format object will be initialized and returned.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -15,15 +15,14 @@ var a = [new Date(0), Date.now(), new Date(Date.parse("1989-11-09T17:57:00Z"))];
|
|||||||
var referenceDateTimeFormat = new Intl.DateTimeFormat(locales);
|
var referenceDateTimeFormat = new Intl.DateTimeFormat(locales);
|
||||||
var referenceFormatted = a.map(referenceDateTimeFormat.format);
|
var referenceFormatted = a.map(referenceDateTimeFormat.format);
|
||||||
|
|
||||||
function MyDateTimeFormat(locales, options) {
|
class MyDateTimeFormat extends Intl.DateTimeFormat {
|
||||||
Intl.DateTimeFormat.call(this, locales, options);
|
constructor(locales, options) {
|
||||||
|
super(locales, options);
|
||||||
// could initialize MyDateTimeFormat properties
|
// could initialize MyDateTimeFormat properties
|
||||||
|
}
|
||||||
|
// could add methods to MyDateTimeFormat.prototype
|
||||||
}
|
}
|
||||||
|
|
||||||
MyDateTimeFormat.prototype = Object.create(Intl.DateTimeFormat.prototype);
|
|
||||||
MyDateTimeFormat.prototype.constructor = MyDateTimeFormat;
|
|
||||||
// could add methods to MyDateTimeFormat.prototype
|
|
||||||
|
|
||||||
var format = new MyDateTimeFormat(locales);
|
var format = new MyDateTimeFormat(locales);
|
||||||
var actual = a.map(format.format);
|
var actual = a.map(format.format);
|
||||||
testArraysAreSame(referenceFormatted, actual);
|
testArraysAreSame(referenceFormatted, actual);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.1_L15
|
es5id: 12.1_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.DateTimeFormat meets the requirements for
|
Tests that Intl.DateTimeFormat meets the requirements for
|
||||||
built-in objects defined by the introduction of chapter 15 of the
|
built-in objects defined by the introduction of chapter 17 of the
|
||||||
ECMAScript Language Specification.
|
ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.2.2_L15
|
es5id: 12.2.2_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.DateTimeFormat.supportedLocalesOf meets the
|
Tests that Intl.DateTimeFormat.supportedLocalesOf meets the
|
||||||
requirements for built-in objects defined by the introduction of
|
requirements for built-in objects defined by the introduction of
|
||||||
chapter 15 of the ECMAScript Language Specification.
|
chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
es5id: 12.3.2_1_a_L15
|
es5id: 12.3.2_1_a_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that the function returned by
|
Tests that the function returned by
|
||||||
Intl.DateTimeFormat.prototype.format meets the requirements for
|
Intl.DateTimeFormat.prototype.format meets the requirements for
|
||||||
built-in objects defined by the introduction of chapter 15 of the
|
built-in objects defined by the introduction of chapter 17 of the
|
||||||
ECMAScript Language Specification.
|
ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -6,7 +6,7 @@ es5id: 12.3.2_L15
|
|||||||
description: >
|
description: >
|
||||||
Tests that the getter for Intl.DateTimeFormat.prototype.format
|
Tests that the getter for Intl.DateTimeFormat.prototype.format
|
||||||
meets the requirements for built-in objects defined by the
|
meets the requirements for built-in objects defined by the
|
||||||
introduction of chapter 15 of the ECMAScript Language
|
introduction of chapter 17 of the ECMAScript Language
|
||||||
Specification.
|
Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -40,7 +40,7 @@ var calendars = [
|
|||||||
mustHaveProperty(actual, "locale", isCanonicalizedStructurallyValidLanguageTag);
|
mustHaveProperty(actual, "locale", isCanonicalizedStructurallyValidLanguageTag);
|
||||||
mustHaveProperty(actual, "calendar", calendars);
|
mustHaveProperty(actual, "calendar", calendars);
|
||||||
mustHaveProperty(actual, "numberingSystem", isValidNumberingSystem);
|
mustHaveProperty(actual, "numberingSystem", isValidNumberingSystem);
|
||||||
mustHaveProperty(actual, "timeZone", [undefined]);
|
mustHaveProperty(actual, "timeZone", isCanonicalizedStructurallyValidTimeZoneName);
|
||||||
mustNotHaveProperty(actual, "weekday");
|
mustNotHaveProperty(actual, "weekday");
|
||||||
mustNotHaveProperty(actual, "era");
|
mustNotHaveProperty(actual, "era");
|
||||||
mustHaveProperty(actual, "year", ["2-digit", "numeric"]);
|
mustHaveProperty(actual, "year", ["2-digit", "numeric"]);
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.3.3_L15
|
es5id: 12.3.3_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.DateTimeFormat.prototype.resolvedOptions meets
|
Tests that Intl.DateTimeFormat.prototype.resolvedOptions meets
|
||||||
the requirements for built-in objects defined by the introduction
|
the requirements for built-in objects defined by the introduction
|
||||||
of chapter 15 of the ECMAScript Language Specification.
|
of chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.3_L15
|
es5id: 12.3_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl.DateTimeFormat.prototype meets the requirements
|
Tests that Intl.DateTimeFormat.prototype meets the requirements
|
||||||
for built-in objects defined by the introduction of chapter 15 of
|
for built-in objects defined by the introduction of chapter 17 of
|
||||||
the ECMAScript Language Specification.
|
the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 13.1.1_L15
|
es5id: 13.1.1_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that String.prototype.localeCompare meets the requirements
|
Tests that String.prototype.localeCompare meets the requirements
|
||||||
for built-in objects defined by the introduction of chapter 15 of
|
for built-in objects defined by the introduction of chapter 17 of
|
||||||
the ECMAScript Language Specification.
|
the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 13.2.1_L15
|
es5id: 13.2.1_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Number.prototype.toLocaleString meets the requirements
|
Tests that Number.prototype.toLocaleString meets the requirements
|
||||||
for built-in objects defined by the introduction of chapter 15 of
|
for built-in objects defined by the introduction of chapter 17 of
|
||||||
the ECMAScript Language Specification.
|
the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 13.3.1_L15
|
es5id: 13.3.1_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Date.prototype.toLocaleString meets the requirements
|
Tests that Date.prototype.toLocaleString meets the requirements
|
||||||
for built-in objects defined by the introduction of chapter 15 of
|
for built-in objects defined by the introduction of chapter 17 of
|
||||||
the ECMAScript Language Specification.
|
the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 13.3.2_L15
|
es5id: 13.3.2_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Date.prototype.toLocaleDateString meets the
|
Tests that Date.prototype.toLocaleDateString meets the
|
||||||
requirements for built-in objects defined by the introduction of
|
requirements for built-in objects defined by the introduction of
|
||||||
chapter 15 of the ECMAScript Language Specification.
|
chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 13.3.3_L15
|
es5id: 13.3.3_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Date.prototype.toLocaleTimeString meets the
|
Tests that Date.prototype.toLocaleTimeString meets the
|
||||||
requirements for built-in objects defined by the introduction of
|
requirements for built-in objects defined by the introduction of
|
||||||
chapter 15 of the ECMAScript Language Specification.
|
chapter 17 of the ECMAScript Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 8.0_L15
|
es5id: 8.0_L15
|
||||||
description: >
|
description: >
|
||||||
Tests that Intl meets the requirements for built-in objects
|
Tests that Intl meets the requirements for built-in objects
|
||||||
defined by the introduction of chapter 15 of the ECMAScript
|
defined by the introduction of chapter 17 of the ECMAScript
|
||||||
Language Specification.
|
Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes:
|
includes:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user