mirror of https://github.com/tc39/test262.git
New tests and test fixes for ECMAScript Internationalization API.
Updated copyright notice for 2013.
This commit is contained in:
parent
a2380a4257
commit
96321f30c9
2
LICENSE
2
LICENSE
|
@ -5,7 +5,7 @@ are granted under this license even if the third party concerned is a member of
|
|||
CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT http://www.ecma-international.org/memento/codeofconduct.htm FOR
|
||||
INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS*.
|
||||
|
||||
Copyright (C) <<2012>> <<Ecma International>>
|
||||
Copyright (C) 2012-2013 Ecma International
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
|
||||
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
||||
// Copyright 2012-2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
|
@ -860,6 +860,44 @@ function mustNotHaveProperty(obj, property) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Properties of the RegExp constructor that may be affected by use of regular
|
||||
* expressions, and the default values of these properties. Properties are from
|
||||
* https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties
|
||||
*/
|
||||
var regExpProperties = ["$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
|
||||
"$_", "$*", "$&", "$+", "$`", "$'",
|
||||
"input", "lastMatch", "lastParen", "leftContext", "rightContext"
|
||||
];
|
||||
|
||||
var regExpPropertiesDefaultValues = (function () {
|
||||
var values = Object.create(null);
|
||||
regExpProperties.forEach(function (property) {
|
||||
values[property] = RegExp[property];
|
||||
});
|
||||
return values;
|
||||
}());
|
||||
|
||||
|
||||
/**
|
||||
* Tests that executing the provided function (which may use regular expressions
|
||||
* in its implementation) does not create or modify unwanted properties on the
|
||||
* RegExp constructor.
|
||||
*/
|
||||
function testForUnwantedRegExpChanges(testFunc) {
|
||||
regExpProperties.forEach(function (property) {
|
||||
RegExp[property] = regExpPropertiesDefaultValues[property];
|
||||
});
|
||||
testFunc();
|
||||
regExpProperties.forEach(function (property) {
|
||||
if (RegExp[property] !== regExpPropertiesDefaultValues[property]) {
|
||||
$ERROR("RegExp has unexpected property " + property + " with value " +
|
||||
RegExp[property] + ".");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests whether name is a valid BCP 47 numbering system name
|
||||
* and not excluded from use in the ECMAScript Internationalization API.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
|
||||
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
||||
// Copyright 2012-2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
|
@ -860,6 +860,44 @@ function mustNotHaveProperty(obj, property) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Properties of the RegExp constructor that may be affected by use of regular
|
||||
* expressions, and the default values of these properties. Properties are from
|
||||
* https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties
|
||||
*/
|
||||
var regExpProperties = ["$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
|
||||
"$_", "$*", "$&", "$+", "$`", "$'",
|
||||
"input", "lastMatch", "lastParen", "leftContext", "rightContext"
|
||||
];
|
||||
|
||||
var regExpPropertiesDefaultValues = (function () {
|
||||
var values = Object.create(null);
|
||||
regExpProperties.forEach(function (property) {
|
||||
values[property] = RegExp[property];
|
||||
});
|
||||
return values;
|
||||
}());
|
||||
|
||||
|
||||
/**
|
||||
* Tests that executing the provided function (which may use regular expressions
|
||||
* in its implementation) does not create or modify unwanted properties on the
|
||||
* RegExp constructor.
|
||||
*/
|
||||
function testForUnwantedRegExpChanges(testFunc) {
|
||||
regExpProperties.forEach(function (property) {
|
||||
RegExp[property] = regExpPropertiesDefaultValues[property];
|
||||
});
|
||||
testFunc();
|
||||
regExpProperties.forEach(function (property) {
|
||||
if (RegExp[property] !== regExpPropertiesDefaultValues[property]) {
|
||||
$ERROR("RegExp has unexpected property " + property + " with value " +
|
||||
RegExp[property] + ".");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests whether name is a valid BCP 47 numbering system name
|
||||
* and not excluded from use in the ECMAScript Internationalization API.
|
||||
|
|
|
@ -21,7 +21,13 @@ var validLanguageTags = [
|
|||
"i-klingon", // grandfathered tag
|
||||
"cmn-hans-cn-t-ca-u-ca-x-t-u", // singleton subtags can also be used as private use subtags
|
||||
"enochian-enochian", // language and variant subtags may be the same
|
||||
"de-gregory-u-ca-gregory" // variant and extension subtags may be the same
|
||||
"de-gregory-u-ca-gregory", // variant and extension subtags may be the same
|
||||
"aa-a-foo-x-a-foo-bar", // variant subtags can also be used as private use subtags
|
||||
"x-en-US-12345", // anything goes in private use tags
|
||||
"x-12345-12345-en-US",
|
||||
"x-en-US-12345-12345",
|
||||
"x-en-u-foo",
|
||||
"x-en-u-foo-u-bar"
|
||||
];
|
||||
|
||||
testWithIntlConstructors(function (Constructor) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
var invalidCurrencyCodes = [
|
||||
"",
|
||||
"€",
|
||||
"$",
|
||||
"SFr.",
|
||||
|
@ -26,9 +27,9 @@ invalidCurrencyCodes.forEach(function (code) {
|
|||
error = e;
|
||||
}
|
||||
if (error === undefined) {
|
||||
$ERROR("Invalid currency code " + code + " was not rejected.");
|
||||
$ERROR("Invalid currency code '" + code + "' was not rejected.");
|
||||
} else if (error.name !== "RangeError") {
|
||||
$ERROR("Invalid currency code " + code + " was rejected with wrong error " + error.name + ".");
|
||||
$ERROR("Invalid currency code '" + code + "' was rejected with wrong error " + error.name + ".");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that Intl has Object.prototype as its prototype.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
if (Object.getPrototypeOf(Intl) !== Object.prototype) {
|
||||
$ERROR("Intl doesn't have Object.prototype as its prototype.");
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that constructing a Collator doesn't create or modify
|
||||
* unwanted properties on the RegExp constructor.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
testForUnwantedRegExpChanges(function () {
|
||||
new Intl.Collator("de-DE-u-co-phonebk");
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that Intl.Collator.supportedLocalesOf
|
||||
* doesn't access arguments that it's not given.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
taintDataProperty(Object.prototype, "1");
|
||||
new Intl.Collator("und");
|
|
@ -7,7 +7,7 @@
|
|||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
// data from http://www.currency-iso.org/dl_iso_table_a1.xml, 2012-08-10
|
||||
// data from http://www.currency-iso.org/dl_iso_table_a1.xml, 2013-02-25
|
||||
var currencyDigits = {
|
||||
AED: 2,
|
||||
AFN: 2,
|
||||
|
@ -158,7 +158,7 @@ var currencyDigits = {
|
|||
TWD: 2,
|
||||
TZS: 2,
|
||||
UAH: 2,
|
||||
UGX: 2,
|
||||
// UGX: 2, will be changed to 0 when maintenance agency releases updated table
|
||||
USD: 2,
|
||||
USN: 2,
|
||||
USS: 2,
|
||||
|
@ -175,7 +175,7 @@ var currencyDigits = {
|
|||
XPF: 0,
|
||||
YER: 2,
|
||||
ZAR: 2,
|
||||
ZMK: 2,
|
||||
ZMW: 2,
|
||||
ZWL: 2
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that the options minimumSignificantDigits and
|
||||
* maximumSignificantDigits are read in the right sequence.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
var read = 0;
|
||||
|
||||
function readMinimumSignificantDigits() {
|
||||
++read;
|
||||
if (read === 1) {
|
||||
return 0; // invalid value, but on first read that's OK
|
||||
} else if (read === 3) {
|
||||
return 1; // valid value
|
||||
} else {
|
||||
$ERROR("minimumSignificantDigits read out of sequence: " + read + ".");
|
||||
}
|
||||
}
|
||||
|
||||
function readMaximumSignificantDigits() {
|
||||
++read;
|
||||
if (read === 2) {
|
||||
return 0; // invalid value, but on first read that's OK
|
||||
} else if (read === 4) {
|
||||
return 1; // valid value
|
||||
} else {
|
||||
$ERROR("maximumSignificantDigits read out of sequence: " + read + ".");
|
||||
}
|
||||
}
|
||||
|
||||
var options = {};
|
||||
Object.defineProperty(options, "minimumSignificantDigits",
|
||||
{ get: readMinimumSignificantDigits });
|
||||
Object.defineProperty(options, "maximumSignificantDigits",
|
||||
{ get: readMaximumSignificantDigits });
|
||||
|
||||
new Intl.NumberFormat("de", options);
|
||||
|
||||
if (read !== 4) {
|
||||
$ERROR("insuffient number of property reads: " + read + ".");
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that constructing a NumberFormat doesn't create or modify
|
||||
* unwanted properties on the RegExp constructor.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
testForUnwantedRegExpChanges(function () {
|
||||
new Intl.NumberFormat("de-DE-u-nu-latn");
|
||||
});
|
||||
|
||||
testForUnwantedRegExpChanges(function () {
|
||||
new Intl.NumberFormat("de-DE-u-nu-latn", {style: "currency", currency: "EUR"});
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that Intl.NumberFormat.supportedLocalesOf
|
||||
* doesn't access arguments that it's not given.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
taintDataProperty(Object.prototype, "1");
|
||||
new Intl.NumberFormat("und");
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
var formatter = new Intl.NumberFormat();
|
||||
var testData = [undefined, null, true, '0.6666666'];
|
||||
var testData = [undefined, null, true, '0.6666666', {valueOf: function () { return '0.1234567';}}];
|
||||
var number;
|
||||
var i, input, correctResult, result;
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that constructing a DateTimeFormat doesn't create or modify
|
||||
* unwanted properties on the RegExp constructor.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
testForUnwantedRegExpChanges(function () {
|
||||
new Intl.DateTimeFormat("de-DE-u-ca-gregory");
|
||||
});
|
||||
|
||||
testForUnwantedRegExpChanges(function () {
|
||||
new Intl.DateTimeFormat("de-DE-u-ca-gregory", {timeZone: "UTC"});
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that Intl.DateTimeFormat.supportedLocalesOf
|
||||
* doesn't access arguments that it's not given.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
taintDataProperty(Object.prototype, "1");
|
||||
new Intl.DateTimeFormat("und");
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that String.prototype.localeCompare uses the standard
|
||||
* built-in Intl.Collator constructor.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
taintDataProperty(Intl, "Collator");
|
||||
"a".localeCompare("b");
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that Number.prototype.toLocaleString uses the standard
|
||||
* built-in Intl.NumberFormat constructor.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
taintDataProperty(Intl, "NumberFormat");
|
||||
(0.0).toLocaleString();
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @description Tests that Date.prototype.toLocaleString & Co. use the standard
|
||||
* built-in Intl.DateTimeFormat constructor.
|
||||
* @author Norbert Lindenberg
|
||||
*/
|
||||
|
||||
$INCLUDE("testIntl.js");
|
||||
|
||||
taintDataProperty(Intl, "DateTimeFormat");
|
||||
new Date().toLocaleString();
|
||||
new Date().toLocaleDateString();
|
||||
new Date().toLocaleTimeString();
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
|
||||
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
||||
// Copyright 2012-2013 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/**
|
||||
|
@ -860,6 +860,44 @@ function mustNotHaveProperty(obj, property) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Properties of the RegExp constructor that may be affected by use of regular
|
||||
* expressions, and the default values of these properties. Properties are from
|
||||
* https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties
|
||||
*/
|
||||
var regExpProperties = ["$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
|
||||
"$_", "$*", "$&", "$+", "$`", "$'",
|
||||
"input", "lastMatch", "lastParen", "leftContext", "rightContext"
|
||||
];
|
||||
|
||||
var regExpPropertiesDefaultValues = (function () {
|
||||
var values = Object.create(null);
|
||||
regExpProperties.forEach(function (property) {
|
||||
values[property] = RegExp[property];
|
||||
});
|
||||
return values;
|
||||
}());
|
||||
|
||||
|
||||
/**
|
||||
* Tests that executing the provided function (which may use regular expressions
|
||||
* in its implementation) does not create or modify unwanted properties on the
|
||||
* RegExp constructor.
|
||||
*/
|
||||
function testForUnwantedRegExpChanges(testFunc) {
|
||||
regExpProperties.forEach(function (property) {
|
||||
RegExp[property] = regExpPropertiesDefaultValues[property];
|
||||
});
|
||||
testFunc();
|
||||
regExpProperties.forEach(function (property) {
|
||||
if (RegExp[property] !== regExpPropertiesDefaultValues[property]) {
|
||||
$ERROR("RegExp has unexpected property " + property + " with value " +
|
||||
RegExp[property] + ".");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests whether name is a valid BCP 47 numbering system name
|
||||
* and not excluded from use in the ECMAScript Internationalization API.
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
{"date":"2013-02-07","version":"ES5.1"}
|
||||
{"date":"2013-03-24","version":"ES5.1"}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"numTests":142,
|
||||
"numTests":153,
|
||||
"testSuite":[
|
||||
"json/intl402.json"
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue