Merge pull request #357 from anba/intl402-ed2

Intl402 ed2
This commit is contained in:
Brian Terlson 2015-07-16 16:49:03 -07:00
commit ada5db7569
35 changed files with 141 additions and 146 deletions

View File

@ -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,
* and element order.

View File

@ -3,40 +3,27 @@
/*---
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
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
var obj, error;
var obj, newObj;
// variant 1: use constructor in a "new" expression
obj = new Constructor();
try {
Intl.Collator.call(obj);
} catch (e) {
error = e;
newObj = Intl.Collator.call(obj);
if (obj === newObj) {
$ERROR("Collator object created with \"new\" was not ignored as this-value.");
}
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
obj = Constructor.call({});
error = undefined;
try {
Intl.Collator.call(obj);
} catch (e) {
error = e;
obj = Constructor();
newObj = Intl.Collator.call(obj);
if (obj === newObj) {
$ERROR("Collator object created with constructor as function was not ignored as this-value.");
}
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;
});

View File

@ -4,8 +4,8 @@
/*---
es5id: 10.1.2.1_4
description: >
Tests that for non-object values passed as this to Collator a
wrapper object will be initialized and returned.
Tests that non-object values passed as this to Collator are ignored
and a normal collator object will be initialized and returned.
author: Norbert Lindenberg
---*/

View File

@ -15,15 +15,14 @@ var a = ["A", "C", "E", "B", "D", "F"];
var referenceCollator = new Intl.Collator(locales);
var referenceSorted = a.slice().sort(referenceCollator.compare);
function MyCollator(locales, options) {
Intl.Collator.call(this, locales, options);
class MyCollator extends Intl.Collator {
constructor(locales, options) {
super(locales, options);
// 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);
a.sort(collator.compare);
testArraysAreSame(referenceSorted, a);

View File

@ -4,8 +4,8 @@
/*---
es5id: 10.1_L15
description: >
Tests that Intl.Collator meets the requirements for built-in
objects defined by the introduction of chapter 15 of the
Tests that Intl.Collator meets the requirements for built-in
objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,9 +4,9 @@
/*---
es5id: 10.2.2_L15
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
chapter 15 of the ECMAScript Language Specification.
chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -5,8 +5,8 @@
es5id: 10.3.2_1_a_L15
description: >
Tests that the function returned by
Intl.Collator.prototype.compare meets the requirements for
built-in objects defined by the introduction of chapter 15 of the
Intl.Collator.prototype.compare meets the requirements for
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,9 +4,9 @@
/*---
es5id: 10.3.2_L15
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
of chapter 15 of the ECMAScript Language Specification.
of chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -4,9 +4,9 @@
/*---
es5id: 10.3.3_L15
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
chapter 15 of the ECMAScript Language Specification.
chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -4,8 +4,8 @@
/*---
es5id: 10.3_L15
description: >
Tests that Intl.Collator.prototype meets the requirements for
built-in objects defined by the introduction of chapter 15 of the
Tests that Intl.Collator.prototype meets the requirements for
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -3,40 +3,27 @@
/*---
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
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
var obj, error;
var obj, newObj;
// variant 1: use constructor in a "new" expression
obj = new Constructor();
try {
Intl.NumberFormat.call(obj);
} catch (e) {
error = e;
newObj = Intl.NumberFormat.call(obj);
if (obj === newObj) {
$ERROR("NumberFormat object created with \"new\" was not ignored as this-value.");
}
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
obj = Constructor.call({});
error = undefined;
try {
Intl.NumberFormat.call(obj);
} catch (e) {
error = e;
obj = Constructor();
newObj = Intl.NumberFormat.call(obj);
if (obj === newObj) {
$ERROR("NumberFormat object created with constructor as function was not ignored as this-value.");
}
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;
});

View File

@ -4,8 +4,8 @@
/*---
es5id: 11.1.2.1_4
description: >
Tests that for non-object values passed as this to NumberFormat a
wrapper object will be initialized and returned.
Tests that non-object values passed as this to NumberFormat are ignored
and a normal number format object will be initialized and returned.
author: Norbert Lindenberg
---*/

View File

@ -15,15 +15,14 @@ var a = [0, 1, -1, -123456.789, -Infinity, NaN];
var referenceNumberFormat = new Intl.NumberFormat(locales);
var referenceFormatted = a.map(referenceNumberFormat.format);
function MyNumberFormat(locales, options) {
Intl.NumberFormat.call(this, locales, options);
class MyNumberFormat extends Intl.NumberFormat {
constructor(locales, options) {
super(locales, options);
// 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 actual = a.map(format.format);
testArraysAreSame(referenceFormatted, actual);

View File

@ -4,8 +4,8 @@
/*---
es5id: 11.1_L15
description: >
Tests that Intl.NumberFormat meets the requirements for built-in
objects defined by the introduction of chapter 15 of the
Tests that Intl.NumberFormat meets the requirements for built-in
objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,9 +4,9 @@
/*---
es5id: 11.2.2_L15
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
chapter 15 of the ECMAScript Language Specification.
chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -5,8 +5,8 @@
es5id: 11.3.2_1_a_L15
description: >
Tests that the function returned by
Intl.NumberFormat.prototype.format meets the requirements for
built-in objects defined by the introduction of chapter 15 of the
Intl.NumberFormat.prototype.format meets the requirements for
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -6,7 +6,7 @@ es5id: 11.3.2_L15
description: >
Tests that the getter for Intl.NumberFormat.prototype.format
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.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,9 +4,9 @@
/*---
es5id: 11.3.3_L15
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
chapter 15 of the ECMAScript Language Specification.
chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -4,8 +4,8 @@
/*---
es5id: 11.3_L15
description: >
Tests that Intl.NumberFormat.prototype meets the requirements for
built-in objects defined by the introduction of chapter 15 of the
Tests that Intl.NumberFormat.prototype meets the requirements for
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -3,40 +3,27 @@
/*---
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
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
var obj, error;
var obj, newObj;
// variant 1: use constructor in a "new" expression
obj = new Constructor();
try {
Intl.DateTimeFormat.call(obj);
} catch (e) {
error = e;
newObj = Intl.DateTimeFormat.call(obj);
if (obj === newObj) {
$ERROR("DateTimeFormat object created with \"new\" was not ignored as this-value.");
}
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
obj = Constructor.call({});
error = undefined;
try {
Intl.DateTimeFormat.call(obj);
} catch (e) {
error = e;
obj = Constructor();
newObj = Intl.DateTimeFormat.call(obj);
if (obj === newObj) {
$ERROR("DateTimeFormat object created with constructor as function was not ignored as this-value.");
}
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;
});

View File

@ -4,8 +4,8 @@
/*---
es5id: 12.1.2.1_4
description: >
Tests that for non-object values passed as this to DateTimeFormat
a wrapper object will be initialized and returned.
Tests that non-object values passed as this to DateTimeFormat are ignored
and a normal date-time format object will be initialized and returned.
author: Norbert Lindenberg
---*/

View File

@ -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 referenceFormatted = a.map(referenceDateTimeFormat.format);
function MyDateTimeFormat(locales, options) {
Intl.DateTimeFormat.call(this, locales, options);
class MyDateTimeFormat extends Intl.DateTimeFormat {
constructor(locales, options) {
super(locales, options);
// 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 actual = a.map(format.format);
testArraysAreSame(referenceFormatted, actual);

View File

@ -4,8 +4,8 @@
/*---
es5id: 12.1_L15
description: >
Tests that Intl.DateTimeFormat meets the requirements for
built-in objects defined by the introduction of chapter 15 of the
Tests that Intl.DateTimeFormat meets the requirements for
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,9 +4,9 @@
/*---
es5id: 12.2.2_L15
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
chapter 15 of the ECMAScript Language Specification.
chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -5,8 +5,8 @@
es5id: 12.3.2_1_a_L15
description: >
Tests that the function returned by
Intl.DateTimeFormat.prototype.format meets the requirements for
built-in objects defined by the introduction of chapter 15 of the
Intl.DateTimeFormat.prototype.format meets the requirements for
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -6,7 +6,7 @@ es5id: 12.3.2_L15
description: >
Tests that the getter for Intl.DateTimeFormat.prototype.format
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.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -40,7 +40,7 @@ var calendars = [
mustHaveProperty(actual, "locale", isCanonicalizedStructurallyValidLanguageTag);
mustHaveProperty(actual, "calendar", calendars);
mustHaveProperty(actual, "numberingSystem", isValidNumberingSystem);
mustHaveProperty(actual, "timeZone", [undefined]);
mustHaveProperty(actual, "timeZone", isCanonicalizedStructurallyValidTimeZoneName);
mustNotHaveProperty(actual, "weekday");
mustNotHaveProperty(actual, "era");
mustHaveProperty(actual, "year", ["2-digit", "numeric"]);

View File

@ -4,9 +4,9 @@
/*---
es5id: 12.3.3_L15
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
of chapter 15 of the ECMAScript Language Specification.
of chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -4,8 +4,8 @@
/*---
es5id: 12.3_L15
description: >
Tests that Intl.DateTimeFormat.prototype meets the requirements
for built-in objects defined by the introduction of chapter 15 of
Tests that Intl.DateTimeFormat.prototype meets the requirements
for built-in objects defined by the introduction of chapter 17 of
the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,8 +4,8 @@
/*---
es5id: 13.1.1_L15
description: >
Tests that String.prototype.localeCompare meets the requirements
for built-in objects defined by the introduction of chapter 15 of
Tests that String.prototype.localeCompare meets the requirements
for built-in objects defined by the introduction of chapter 17 of
the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,8 +4,8 @@
/*---
es5id: 13.2.1_L15
description: >
Tests that Number.prototype.toLocaleString meets the requirements
for built-in objects defined by the introduction of chapter 15 of
Tests that Number.prototype.toLocaleString meets the requirements
for built-in objects defined by the introduction of chapter 17 of
the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,8 +4,8 @@
/*---
es5id: 13.3.1_L15
description: >
Tests that Date.prototype.toLocaleString meets the requirements
for built-in objects defined by the introduction of chapter 15 of
Tests that Date.prototype.toLocaleString meets the requirements
for built-in objects defined by the introduction of chapter 17 of
the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]

View File

@ -4,9 +4,9 @@
/*---
es5id: 13.3.2_L15
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
chapter 15 of the ECMAScript Language Specification.
chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -4,9 +4,9 @@
/*---
es5id: 13.3.3_L15
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
chapter 15 of the ECMAScript Language Specification.
chapter 17 of the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/

View File

@ -4,8 +4,8 @@
/*---
es5id: 8.0_L15
description: >
Tests that Intl meets the requirements for built-in objects
defined by the introduction of chapter 15 of the ECMAScript
Tests that Intl meets the requirements for built-in objects
defined by the introduction of chapter 17 of the ECMAScript
Language Specification.
author: Norbert Lindenberg
includes: