Updated tests for ECMAScript Internationalization API spec changes; made small enhancements.

- Updated DateTimeFormat tests for new handling of hour12 options property.
- Added a few invalid language tags to test of IsStructurallyValidLanguageTag.
- Added user-defined language tag to test of CanonicalizeLanguageTag.
- Added test for the Intl property of the global object.
This commit is contained in:
Norbert Lindenberg 2012-09-10 11:53:56 -07:00
parent bcf9c18061
commit 75fbd71ee0
9 changed files with 17 additions and 7 deletions

View File

@ -58,7 +58,8 @@ function testBuiltInObject(obj, isFunction, isConstructor, properties, length) {
} }
if (obj.length !== length) { if (obj.length !== length) {
$ERROR("Function's length property doesn't have specified value."); $ERROR("Function's length property doesn't have specified value; expected " +
length + ", got " + obj.length + ".");
} }
var desc = Object.getOwnPropertyDescriptor(obj, "length"); var desc = Object.getOwnPropertyDescriptor(obj, "length");

View File

@ -58,7 +58,8 @@ function testBuiltInObject(obj, isFunction, isConstructor, properties, length) {
} }
if (obj.length !== length) { if (obj.length !== length) {
$ERROR("Function's length property doesn't have specified value."); $ERROR("Function's length property doesn't have specified value; expected " +
length + ", got " + obj.length + ".");
} }
var desc = Object.getOwnPropertyDescriptor(obj, "length"); var desc = Object.getOwnPropertyDescriptor(obj, "length");

View File

@ -20,6 +20,8 @@ var invalidLanguageTags = [
"cmn-hans-cn-u-u", // duplicate singleton "cmn-hans-cn-u-u", // duplicate singleton
"cmn-hans-cn-t-u-ca-u", // duplicate singleton "cmn-hans-cn-t-u-ca-u", // duplicate singleton
"de-gregory-gregory", // duplicate variant "de-gregory-gregory", // duplicate variant
"*", // language range
"de-*", // language range
"中文", // non-ASCII letters "中文", // non-ASCII letters
"en-ß", // non-ASCII letters "en-ß", // non-ASCII letters
"ıd" // non-ASCII letters "ıd" // non-ASCII letters

View File

@ -29,7 +29,8 @@ var canonicalizedTags = {
"de-DD": ["de-DE", "de"], "de-DD": ["de-DE", "de"],
"zh-hak-CN": ["hak-CN", "hak"], "zh-hak-CN": ["hak-CN", "hak"],
"sgn-ils": ["ils"], "sgn-ils": ["ils"],
"in": ["id"] "in": ["id"],
"x-foo": ["x-foo"]
}; };
// make sure the data above is correct // make sure the data above is correct

View File

@ -10,5 +10,6 @@
$INCLUDE("testBuiltInObject.js"); $INCLUDE("testBuiltInObject.js");
testBuiltInObject(fnGlobalObject().Intl, false, false, []);
testBuiltInObject(Intl, false, false, ["Collator", "NumberFormat", "DateTimeFormat"]); testBuiltInObject(Intl, false, false, ["Collator", "NumberFormat", "DateTimeFormat"]);

View File

@ -8,5 +8,8 @@
$INCLUDE("testIntl.js"); $INCLUDE("testIntl.js");
testOption(Intl.DateTimeFormat, "hour12", "boolean"); testOption(Intl.DateTimeFormat, "hour12", "boolean", undefined, undefined,
{extra: {any: {hour: "numeric", minute: "numeric"}}});
testOption(Intl.DateTimeFormat, "hour12", "boolean", undefined, undefined,
{noReturn: true});

View File

@ -39,7 +39,6 @@ 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", [undefined]);
mustHaveProperty(actual, "hour12", [true, false]);
mustNotHaveProperty(actual, "weekday"); mustNotHaveProperty(actual, "weekday");
mustNotHaveProperty(actual, "era"); mustNotHaveProperty(actual, "era");
mustHaveProperty(actual, "year", ["2-digit", "numeric"]); mustHaveProperty(actual, "year", ["2-digit", "numeric"]);
@ -49,4 +48,5 @@ mustNotHaveProperty(actual, "hour");
mustNotHaveProperty(actual, "minute"); mustNotHaveProperty(actual, "minute");
mustNotHaveProperty(actual, "second"); mustNotHaveProperty(actual, "second");
mustNotHaveProperty(actual, "timeZoneName"); mustNotHaveProperty(actual, "timeZoneName");
mustNotHaveProperty(actual, "hour12");

View File

@ -58,7 +58,8 @@ function testBuiltInObject(obj, isFunction, isConstructor, properties, length) {
} }
if (obj.length !== length) { if (obj.length !== length) {
$ERROR("Function's length property doesn't have specified value."); $ERROR("Function's length property doesn't have specified value; expected " +
length + ", got " + obj.length + ".");
} }
var desc = Object.getOwnPropertyDescriptor(obj, "length"); var desc = Object.getOwnPropertyDescriptor(obj, "length");

File diff suppressed because one or more lines are too long