No longer use testBuiltInObject for built-in constructors

This commit is contained in:
André Bargull 2017-12-21 12:08:27 -08:00 committed by Rick Waldron
parent 4337b396bd
commit ecf814bb4c
29 changed files with 84 additions and 45 deletions

View File

@ -10,11 +10,10 @@ description: |
* defined by the introduction of chapter 15 of the ECMAScript Language Specification.
* @param {Object} obj the object to be tested.
* @param {boolean} isFunction whether the specification describes obj as a function.
* @param {boolean} isConstructor whether the specification describes obj as a constructor.
* @author Norbert Lindenberg
*/
function testBuiltInObject(obj, isFunction, isConstructor) {
function testBuiltInObject(obj, isFunction) {
if (obj === undefined) {
$ERROR("Object being tested is undefined.");
@ -41,12 +40,8 @@ function testBuiltInObject(obj, isFunction, isConstructor) {
$ERROR("Built-in functions must have Function.prototype as their prototype.");
}
if (isConstructor && Object.getPrototypeOf(obj.prototype) !== Object.prototype) {
$ERROR("Built-in prototype objects must have Object.prototype as their prototype.");
}
var exception;
if (isFunction && !isConstructor) {
if (isFunction) {
// this is not a complete test for the presence of [[Construct]]:
// if it's absent, the exception must be thrown, but it may also
// be thrown if it's present and just has preconditions related to
@ -63,7 +58,7 @@ function testBuiltInObject(obj, isFunction, isConstructor) {
}
}
if (isFunction && !isConstructor && obj.hasOwnProperty("prototype")) {
if (isFunction && obj.hasOwnProperty("prototype")) {
$ERROR("Built-in functions that aren't constructors must not have a prototype property.");
}

View File

@ -8,7 +8,12 @@ description: >
objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.Collator, true, true);
assert.sameValue(Object.prototype.toString.call(Intl.Collator), "[object Function]",
"The [[Class]] internal property of a built-in function must be " +
"\"Function\".");
assert(Object.isExtensible(Intl.Collator), "Built-in objects must be extensible.");
assert.sameValue(Object.getPrototypeOf(Intl.Collator), Function.prototype);

View File

@ -8,7 +8,13 @@ description: >
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.Collator.prototype, false, false);
assert.sameValue(Object.prototype.toString.call(Intl.Collator.prototype), "[object Object]",
"The [[Class]] internal property of a built-in non-function object must be " +
"\"Object\".");
assert(Object.isExtensible(Intl.Collator.prototype), "Built-in objects must be extensible.");
assert.sameValue(Object.getPrototypeOf(Intl.Collator.prototype), Object.prototype,
"Built-in prototype objects must have Object.prototype as their prototype.");

View File

@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(new Intl.Collator().compare, true, false);
testBuiltInObject(new Intl.Collator().compare, true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get , true, false);
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get , true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.Collator.prototype.resolvedOptions, true, false);
testBuiltInObject(Intl.Collator.prototype.resolvedOptions, true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.Collator.supportedLocalesOf, true, false);
testBuiltInObject(Intl.Collator.supportedLocalesOf, true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Date.prototype.toLocaleDateString, true, false);
testBuiltInObject(Date.prototype.toLocaleDateString, true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Date.prototype.toLocaleString, true, false);
testBuiltInObject(Date.prototype.toLocaleString, true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Date.prototype.toLocaleTimeString, true, false);
testBuiltInObject(Date.prototype.toLocaleTimeString, true);

View File

@ -8,7 +8,12 @@ description: >
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.DateTimeFormat, true, true);
assert.sameValue(Object.prototype.toString.call(Intl.DateTimeFormat), "[object Function]",
"The [[Class]] internal property of a built-in function must be " +
"\"Function\".");
assert(Object.isExtensible(Intl.DateTimeFormat), "Built-in objects must be extensible.");
assert.sameValue(Object.getPrototypeOf(Intl.DateTimeFormat), Function.prototype);

View File

@ -8,7 +8,13 @@ description: >
for built-in objects defined by the introduction of chapter 17 of
the ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.DateTimeFormat.prototype, false, false);
assert.sameValue(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object Object]",
"The [[Class]] internal property of a built-in non-function object must be " +
"\"Object\".");
assert(Object.isExtensible(Intl.DateTimeFormat.prototype), "Built-in objects must be extensible.");
assert.sameValue(Object.getPrototypeOf(Intl.DateTimeFormat.prototype), Object.prototype,
"Built-in prototype objects must have Object.prototype as their prototype.");

View File

@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(new Intl.DateTimeFormat().format, true, false);
testBuiltInObject(new Intl.DateTimeFormat().format, true);

View File

@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, "format").get , true, false);
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, "format").get , true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.DateTimeFormat.prototype.resolvedOptions, true, false);
testBuiltInObject(Intl.DateTimeFormat.prototype.resolvedOptions, true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.DateTimeFormat.supportedLocalesOf, true, false);
testBuiltInObject(Intl.DateTimeFormat.supportedLocalesOf, true);

View File

@ -11,5 +11,5 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(this.Intl, false, false);
testBuiltInObject(Intl, false, false);
testBuiltInObject(this.Intl, false);
testBuiltInObject(Intl, false);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Number.prototype.toLocaleString, true, false);
testBuiltInObject(Number.prototype.toLocaleString, true);

View File

@ -8,7 +8,12 @@ description: >
objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.NumberFormat, true, true);
assert.sameValue(Object.prototype.toString.call(Intl.NumberFormat), "[object Function]",
"The [[Class]] internal property of a built-in function must be " +
"\"Function\".");
assert(Object.isExtensible(Intl.NumberFormat), "Built-in objects must be extensible.");
assert.sameValue(Object.getPrototypeOf(Intl.NumberFormat), Function.prototype);

View File

@ -8,7 +8,13 @@ description: >
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.NumberFormat.prototype, false, false);
assert.sameValue(Object.prototype.toString.call(Intl.NumberFormat.prototype), "[object Object]",
"The [[Class]] internal property of a built-in non-function object must be " +
"\"Object\".");
assert(Object.isExtensible(Intl.NumberFormat.prototype), "Built-in objects must be extensible.");
assert.sameValue(Object.getPrototypeOf(Intl.NumberFormat.prototype), Object.prototype,
"Built-in prototype objects must have Object.prototype as their prototype.");

View File

@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(new Intl.NumberFormat().format, true, false);
testBuiltInObject(new Intl.NumberFormat().format, true);

View File

@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get , true, false);
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get , true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.NumberFormat.prototype.resolvedOptions, true, false);
testBuiltInObject(Intl.NumberFormat.prototype.resolvedOptions, true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.NumberFormat.supportedLocalesOf, true, false);
testBuiltInObject(Intl.NumberFormat.supportedLocalesOf, true);

View File

@ -8,7 +8,12 @@ description: >
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Zibi Braniecki
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.PluralRules, true, true);
assert.sameValue(Object.prototype.toString.call(Intl.PluralRules), "[object Function]",
"The [[Class]] internal property of a built-in function must be " +
"\"Function\".");
assert(Object.isExtensible(Intl.PluralRules), "Built-in objects must be extensible.");
assert.sameValue(Object.getPrototypeOf(Intl.PluralRules), Function.prototype);

View File

@ -8,7 +8,13 @@ description: >
built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification.
author: Zibi Braniecki
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.PluralRules.prototype, false, false);
assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype), "[object Object]",
"The [[Class]] internal property of a built-in non-function object must be " +
"\"Object\".");
assert(Object.isExtensible(Intl.PluralRules.prototype), "Built-in objects must be extensible.");
assert.sameValue(Object.getPrototypeOf(Intl.PluralRules.prototype), Object.prototype,
"Built-in prototype objects must have Object.prototype as their prototype.");

View File

@ -11,4 +11,4 @@ author: Zibi Braniecki
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.PluralRules.prototype.resolvedOptions, true, false);
testBuiltInObject(Intl.PluralRules.prototype.resolvedOptions, true);

View File

@ -11,4 +11,4 @@ author: Zibi Braniecki
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.PluralRules.supportedLocalesOf, true, false);
testBuiltInObject(Intl.PluralRules.supportedLocalesOf, true);

View File

@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(String.prototype.localeCompare, true, false);
testBuiltInObject(String.prototype.localeCompare, true);