Bug 1346079: Update length of function returned from DateTimeFormat.prototype.format to match latest spec. r=gandalf

This commit is contained in:
André Bargull 2017-04-06 14:26:10 +02:00
parent f97c82453a
commit 933c665eb2
3 changed files with 50 additions and 27 deletions

View File

@ -2503,7 +2503,7 @@ static const JSFunctionSpec dateTimeFormat_static_methods[] = {
static const JSFunctionSpec dateTimeFormat_methods[] = {
JS_SELF_HOSTED_FN("resolvedOptions", "Intl_DateTimeFormat_resolvedOptions", 0, 0),
JS_SELF_HOSTED_FN("formatToParts", "Intl_DateTimeFormat_formatToParts", 0, 0),
JS_SELF_HOSTED_FN("formatToParts", "Intl_DateTimeFormat_formatToParts", 1, 0),
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, dateTimeFormat_toSource, 0, 0),
#endif

View File

@ -1658,13 +1658,19 @@ function collatorSearchLocaleData(locale) {
* Spec: ECMAScript Internationalization API Specification, 12.3.2.
*/
function collatorCompareToBind(x, y) {
// Steps 1.a.i-ii implemented by ECMAScript declaration binding instantiation,
// ES5.1 10.5, step 4.d.ii.
// Step 1.
var collator = this;
// Step 1.a.iii-v.
// Step 2.
assert(IsObject(collator), "collatorCompareToBind called with non-object");
assert(IsCollator(collator), "collatorCompareToBind called with non-Collator");
// Steps 3-6
var X = ToString(x);
var Y = ToString(y);
return intl_CompareStrings(this, X, Y);
// Step 7.
return intl_CompareStrings(collator, X, Y);
}
@ -1678,23 +1684,26 @@ function collatorCompareToBind(x, y) {
* Spec: ECMAScript Internationalization API Specification, 10.3.2.
*/
function Intl_Collator_compare_get() {
// Check "this Collator object" per introduction of section 10.3.
if (!IsObject(this) || !IsCollator(this))
// Step 1.
var collator = this;
// Steps 2-3.
if (!IsObject(collator) || !IsCollator(collator))
ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "Collator", "compare", "Collator");
var internals = getCollatorInternals(this);
var internals = getCollatorInternals(collator);
// Step 1.
// Step 4.
if (internals.boundCompare === undefined) {
// Step 1.a.
// Step 4.a.
var F = collatorCompareToBind;
// Steps 1.b-d.
var bc = callFunction(FunctionBind, F, this);
// Steps 4.b-d.
var bc = callFunction(FunctionBind, F, collator);
internals.boundCompare = bc;
}
// Step 2.
// Step 5.
return internals.boundCompare;
}
_SetCanonicalName(Intl_Collator_compare_get, "get compare");
@ -2107,12 +2116,18 @@ function numberFormatLocaleData(locale) {
* Spec: ECMAScript Internationalization API Specification, 11.3.2.
*/
function numberFormatFormatToBind(value) {
// Steps 1.a.i implemented by ECMAScript declaration binding instantiation,
// ES5.1 10.5, step 4.d.ii.
// Step 1.
var nf = this;
// Step 1.a.ii-iii.
// Step 2.
assert(IsObject(nf), "InitializeNumberFormat called with non-object");
assert(IsNumberFormat(nf), "InitializeNumberFormat called with non-NumberFormat");
// Steps 3-4.
var x = ToNumber(value);
return intl_FormatNumber(this, x, /* formatToParts = */ false);
// Step 5.
return intl_FormatNumber(nf, x, /* formatToParts = */ false);
}
@ -2795,13 +2810,19 @@ function dateTimeFormatLocaleData(locale) {
*
* Spec: ECMAScript Internationalization API Specification, 12.3.2.
*/
function dateTimeFormatFormatToBind() {
// Steps 1.a.i-ii
var date = arguments.length > 0 ? arguments[0] : undefined;
function dateTimeFormatFormatToBind(date) {
// Step 1.
var dtf = this;
// Step 2.
assert(IsObject(dtf), "dateTimeFormatFormatToBind called with non-Object");
assert(IsDateTimeFormat(dtf), "dateTimeFormatFormatToBind called with non-DateTimeFormat");
// Steps 3-4.
var x = (date === undefined) ? std_Date_now() : ToNumber(date);
// Step 1.a.iii.
return intl_FormatDateTime(this, x, /* formatToParts = */ false);
// Step 5.
return intl_FormatDateTime(dtf, x, /* formatToParts = */ false);
}
/**
@ -2833,7 +2854,10 @@ function Intl_DateTimeFormat_format_get() {
_SetCanonicalName(Intl_DateTimeFormat_format_get, "get format");
function Intl_DateTimeFormat_formatToParts() {
/**
* Intl.DateTimeFormat.prototype.formatToParts ( date )
*/
function Intl_DateTimeFormat_formatToParts(date) {
// Steps 1-3.
var dtf = UnwrapDateTimeFormat(this, "formatToParts");
@ -2841,7 +2865,6 @@ function Intl_DateTimeFormat_formatToParts() {
getDateTimeFormatInternals(dtf);
// Steps 4-5.
var date = arguments.length > 0 ? arguments[0] : undefined;
var x = (date === undefined) ? std_Date_now() : ToNumber(date);
// Step 6.

View File

@ -861,9 +861,6 @@ skip script test262/built-ins/SharedArrayBuffer/data-allocation-after-object-cre
skip script test262/intl402/NumberFormat/prototype/format/11.3.2_TRP.js
skip script test262/intl402/NumberFormat/prototype/format/11.3.2_TRF.js
# https://bugzilla.mozilla.org/show_bug.cgi?id=1346079
skip script test262/intl402/DateTimeFormat/prototype/format/12.3.2_1_a_L15.js
# https://bugzilla.mozilla.org/show_bug.cgi?id=1346080
skip script test262/intl402/PluralRules/prototype/select/tainting.js
@ -879,5 +876,8 @@ skip script test262/language/statements/async-generator/yield-star-async-next.js
skip script test262/language/statements/async-generator/yield-star-async-return.js
skip script test262/language/statements/async-generator/yield-star-async-throw.js
# https://github.com/tc39/test262/pull/947
skip script test262/intl402/DateTimeFormat/prototype/formatToParts/length.js
# https://github.com/tc39/test262/pull/947
skip script test262/intl402/PluralRules/this-not-ignored.js