diff options
Diffstat (limited to 'js/src/tests/test262/intl402/Date/prototype/toLocaleString')
5 files changed, 109 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Date/prototype/toLocaleString/browser.js b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/browser.js diff --git a/js/src/tests/test262/intl402/Date/prototype/toLocaleString/builtin.js b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/builtin.js new file mode 100644 index 0000000000..7db6c9b8df --- /dev/null +++ b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/builtin.js @@ -0,0 +1,30 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +es5id: 13.3.1_L15 +description: > + 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: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(Object.prototype.toString.call(Date.prototype.toLocaleString), "[object Function]", + "The [[Class]] internal property of a built-in function must be " + + "\"Function\"."); + +assert(Object.isExtensible(Date.prototype.toLocaleString), + "Built-in objects must be extensible."); + +assert.sameValue(Object.getPrototypeOf(Date.prototype.toLocaleString), Function.prototype); + +assert.sameValue(Date.prototype.toLocaleString.hasOwnProperty("prototype"), false, + "Built-in functions that aren't constructors must not have a prototype property."); + +assert.sameValue(isConstructor(Date.prototype.toLocaleString), false, + "Built-in functions don't implement [[Construct]] unless explicitly specified."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Date/prototype/toLocaleString/default-options-object-prototype.js b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/default-options-object-prototype.js new file mode 100644 index 0000000000..28654c8173 --- /dev/null +++ b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/default-options-object-prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Daniel Ehrenberg. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-todatetimeoptions +description: > + Monkey-patching Object.prototype does not change the default + options for DateTimeFormat as a null prototype is used. +info: | + ToDateTimeOptions ( options, required, defaults ) + + 1. If options is undefined, let options be null; otherwise let options be ? ToObject(options). + 1. Let options be ObjectCreate(options). +---*/ + +if (new Intl.DateTimeFormat("en").resolvedOptions().locale === "en") { + Object.prototype.year = "2-digit"; + assert.notSameValue(new Date().toLocaleString("en").length, 2); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Date/prototype/toLocaleString/length.js b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/length.js new file mode 100644 index 0000000000..5554f5285c --- /dev/null +++ b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sup-date.prototype.tolocalestring +description: > + Date.prototype.toLocaleString.length is 0. +info: | + Date.prototype.toLocaleString ( [ locales [ , options ] ] ) + + 17 ECMAScript Standard Built-in Objects: + + Every built-in function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are shown using the form «...name») are not included in the default + argument count. + Unless otherwise specified, the length property of a built-in function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. + +includes: [propertyHelper.js] +---*/ + +verifyProperty(Date.prototype.toLocaleString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Date/prototype/toLocaleString/shell.js b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/intl402/Date/prototype/toLocaleString/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} |