Skip to content
Snippets Groups Projects
Commit ecf814bb authored by André Bargull's avatar André Bargull Committed by Rick Waldron
Browse files

No longer use testBuiltInObject for built-in constructors

parent 4337b396
No related branches found
No related tags found
No related merge requests found
Showing
with 62 additions and 34 deletions
...@@ -10,11 +10,10 @@ description: | ...@@ -10,11 +10,10 @@ description: |
* defined by the introduction of chapter 15 of the ECMAScript Language Specification. * defined by the introduction of chapter 15 of the ECMAScript Language Specification.
* @param {Object} obj the object to be tested. * @param {Object} obj the object to be tested.
* @param {boolean} isFunction whether the specification describes obj as a function. * @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 * @author Norbert Lindenberg
*/ */
function testBuiltInObject(obj, isFunction, isConstructor) { function testBuiltInObject(obj, isFunction) {
if (obj === undefined) { if (obj === undefined) {
$ERROR("Object being tested is undefined."); $ERROR("Object being tested is undefined.");
...@@ -41,12 +40,8 @@ function testBuiltInObject(obj, isFunction, isConstructor) { ...@@ -41,12 +40,8 @@ function testBuiltInObject(obj, isFunction, isConstructor) {
$ERROR("Built-in functions must have Function.prototype as their prototype."); $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; var exception;
if (isFunction && !isConstructor) { if (isFunction) {
// this is not a complete test for the presence of [[Construct]]: // this is not a complete test for the presence of [[Construct]]:
// if it's absent, the exception must be thrown, but it may also // 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 // be thrown if it's present and just has preconditions related to
...@@ -63,7 +58,7 @@ function testBuiltInObject(obj, isFunction, isConstructor) { ...@@ -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."); $ERROR("Built-in functions that aren't constructors must not have a prototype property.");
} }
......
...@@ -8,7 +8,12 @@ description: > ...@@ -8,7 +8,12 @@ description: >
objects defined by the introduction of chapter 17 of the objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification. ECMAScript Language Specification.
author: Norbert Lindenberg 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);
...@@ -8,7 +8,13 @@ description: > ...@@ -8,7 +8,13 @@ description: >
built-in objects defined by the introduction of chapter 17 of the built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification. ECMAScript Language Specification.
author: Norbert Lindenberg 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.");
...@@ -12,4 +12,4 @@ author: Norbert Lindenberg ...@@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(new Intl.Collator().compare, true, false); testBuiltInObject(new Intl.Collator().compare, true);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get , true, false); testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get , true);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Intl.Collator.prototype.resolvedOptions, true, false); testBuiltInObject(Intl.Collator.prototype.resolvedOptions, true);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Intl.Collator.supportedLocalesOf, true, false); testBuiltInObject(Intl.Collator.supportedLocalesOf, true);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Date.prototype.toLocaleDateString, true, false); testBuiltInObject(Date.prototype.toLocaleDateString, true);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Date.prototype.toLocaleString, true, false); testBuiltInObject(Date.prototype.toLocaleString, true);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Date.prototype.toLocaleTimeString, true, false); testBuiltInObject(Date.prototype.toLocaleTimeString, true);
...@@ -8,7 +8,12 @@ description: > ...@@ -8,7 +8,12 @@ description: >
built-in objects defined by the introduction of chapter 17 of the built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification. ECMAScript Language Specification.
author: Norbert Lindenberg 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);
...@@ -8,7 +8,13 @@ description: > ...@@ -8,7 +8,13 @@ description: >
for built-in objects defined by the introduction of chapter 17 of for built-in objects defined by the introduction of chapter 17 of
the ECMAScript Language Specification. the ECMAScript Language Specification.
author: Norbert Lindenberg 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.");
...@@ -12,4 +12,4 @@ author: Norbert Lindenberg ...@@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(new Intl.DateTimeFormat().format, true, false); testBuiltInObject(new Intl.DateTimeFormat().format, true);
...@@ -12,4 +12,4 @@ author: Norbert Lindenberg ...@@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, "format").get , true, false); testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, "format").get , true);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Intl.DateTimeFormat.prototype.resolvedOptions, true, false); testBuiltInObject(Intl.DateTimeFormat.prototype.resolvedOptions, true);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Intl.DateTimeFormat.supportedLocalesOf, true, false); testBuiltInObject(Intl.DateTimeFormat.supportedLocalesOf, true);
...@@ -11,5 +11,5 @@ author: Norbert Lindenberg ...@@ -11,5 +11,5 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(this.Intl, false, false); testBuiltInObject(this.Intl, false);
testBuiltInObject(Intl, false, false); testBuiltInObject(Intl, false);
...@@ -11,4 +11,4 @@ author: Norbert Lindenberg ...@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js] includes: [testBuiltInObject.js]
---*/ ---*/
testBuiltInObject(Number.prototype.toLocaleString, true, false); testBuiltInObject(Number.prototype.toLocaleString, true);
...@@ -8,7 +8,12 @@ description: > ...@@ -8,7 +8,12 @@ description: >
objects defined by the introduction of chapter 17 of the objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification. ECMAScript Language Specification.
author: Norbert Lindenberg 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);
...@@ -8,7 +8,13 @@ description: > ...@@ -8,7 +8,13 @@ description: >
built-in objects defined by the introduction of chapter 17 of the built-in objects defined by the introduction of chapter 17 of the
ECMAScript Language Specification. ECMAScript Language Specification.
author: Norbert Lindenberg 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.");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment