mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 23:44:27 +02:00
No longer use testBuiltInObject for built-in objects
This commit is contained in:
parent
ecf814bb4c
commit
c81370348d
@ -9,56 +9,47 @@ description: |
|
|||||||
* @description Tests that obj meets the requirements for built-in objects
|
* @description Tests that obj meets the requirements for built-in objects
|
||||||
* 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.
|
|
||||||
* @author Norbert Lindenberg
|
* @author Norbert Lindenberg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function testBuiltInObject(obj, isFunction) {
|
function testBuiltInObject(obj) {
|
||||||
|
|
||||||
if (obj === undefined) {
|
if (obj === undefined) {
|
||||||
$ERROR("Object being tested is undefined.");
|
$ERROR("Object being tested is undefined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var objString = Object.prototype.toString.call(obj);
|
var objString = Object.prototype.toString.call(obj);
|
||||||
if (isFunction) {
|
|
||||||
if (objString !== "[object Function]") {
|
if (objString !== "[object Function]") {
|
||||||
$ERROR("The [[Class]] internal property of a built-in function must be " +
|
$ERROR("The [[Class]] internal property of a built-in function must be " +
|
||||||
"\"Function\", but toString() returns " + objString);
|
"\"Function\", but toString() returns " + objString);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (objString !== "[object Object]") {
|
|
||||||
$ERROR("The [[Class]] internal property of a built-in non-function object must be " +
|
|
||||||
"\"Object\", but toString() returns " + objString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Object.isExtensible(obj)) {
|
if (!Object.isExtensible(obj)) {
|
||||||
$ERROR("Built-in objects must be extensible.");
|
$ERROR("Built-in objects must be extensible.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFunction && Object.getPrototypeOf(obj) !== Function.prototype) {
|
if (Object.getPrototypeOf(obj) !== Function.prototype) {
|
||||||
$ERROR("Built-in functions must have Function.prototype as their prototype.");
|
$ERROR("Built-in functions must have Function.prototype as their prototype.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var exception;
|
var exception;
|
||||||
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
|
// arguments or the this value that this statement doesn't meet.
|
||||||
// arguments or the this value that this statement doesn't meet.
|
try {
|
||||||
try {
|
/*jshint newcap:false*/
|
||||||
/*jshint newcap:false*/
|
var instance = new obj();
|
||||||
var instance = new obj();
|
} catch (e) {
|
||||||
} catch (e) {
|
exception = e;
|
||||||
exception = e;
|
}
|
||||||
}
|
if (exception === undefined || exception.name !== "TypeError") {
|
||||||
if (exception === undefined || exception.name !== "TypeError") {
|
$ERROR("Built-in functions that aren't constructors must throw TypeError when " +
|
||||||
$ERROR("Built-in functions that aren't constructors must throw TypeError when " +
|
"used in a \"new\" statement.");
|
||||||
"used in a \"new\" statement.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFunction && obj.hasOwnProperty("prototype")) {
|
if (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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,4 +12,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(new Intl.Collator().compare, true);
|
testBuiltInObject(new Intl.Collator().compare);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get , true);
|
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Intl.Collator.prototype.resolvedOptions, true);
|
testBuiltInObject(Intl.Collator.prototype.resolvedOptions);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Intl.Collator.supportedLocalesOf, true);
|
testBuiltInObject(Intl.Collator.supportedLocalesOf);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Date.prototype.toLocaleDateString, true);
|
testBuiltInObject(Date.prototype.toLocaleDateString);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Date.prototype.toLocaleString, true);
|
testBuiltInObject(Date.prototype.toLocaleString);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Date.prototype.toLocaleTimeString, true);
|
testBuiltInObject(Date.prototype.toLocaleTimeString);
|
||||||
|
@ -12,4 +12,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(new Intl.DateTimeFormat().format, true);
|
testBuiltInObject(new Intl.DateTimeFormat().format);
|
||||||
|
@ -12,4 +12,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, "format").get , true);
|
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, "format").get);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Intl.DateTimeFormat.prototype.resolvedOptions, true);
|
testBuiltInObject(Intl.DateTimeFormat.prototype.resolvedOptions);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Intl.DateTimeFormat.supportedLocalesOf, true);
|
testBuiltInObject(Intl.DateTimeFormat.supportedLocalesOf);
|
||||||
|
@ -8,8 +8,16 @@ description: >
|
|||||||
defined by the introduction of chapter 17 of the ECMAScript
|
defined by the introduction of chapter 17 of the ECMAScript
|
||||||
Language Specification.
|
Language Specification.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testBuiltInObject.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(this.Intl, false);
|
assert.sameValue(Object.prototype.toString.call(Intl), "[object Object]",
|
||||||
testBuiltInObject(Intl, false);
|
"The [[Class]] internal property of a built-in non-function object must be " +
|
||||||
|
"\"Object\".");
|
||||||
|
|
||||||
|
assert(Object.isExtensible(Intl), "Built-in objects must be extensible.");
|
||||||
|
|
||||||
|
assert.sameValue(Object.getPrototypeOf(Intl), Object.prototype,
|
||||||
|
"The [[Prototype]] of Intl is %ObjectPrototype%.");
|
||||||
|
|
||||||
|
assert.sameValue(this.Intl, Intl,
|
||||||
|
"%Intl% is accessible as a property of the global object.");
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Number.prototype.toLocaleString, true);
|
testBuiltInObject(Number.prototype.toLocaleString);
|
||||||
|
@ -12,4 +12,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(new Intl.NumberFormat().format, true);
|
testBuiltInObject(new Intl.NumberFormat().format);
|
||||||
|
@ -12,4 +12,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get , true);
|
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Intl.NumberFormat.prototype.resolvedOptions, true);
|
testBuiltInObject(Intl.NumberFormat.prototype.resolvedOptions);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Intl.NumberFormat.supportedLocalesOf, true);
|
testBuiltInObject(Intl.NumberFormat.supportedLocalesOf);
|
||||||
|
@ -11,4 +11,4 @@ author: Zibi Braniecki
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Intl.PluralRules.prototype.resolvedOptions, true);
|
testBuiltInObject(Intl.PluralRules.prototype.resolvedOptions);
|
||||||
|
@ -11,4 +11,4 @@ author: Zibi Braniecki
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(Intl.PluralRules.supportedLocalesOf, true);
|
testBuiltInObject(Intl.PluralRules.supportedLocalesOf);
|
||||||
|
@ -11,4 +11,4 @@ author: Norbert Lindenberg
|
|||||||
includes: [testBuiltInObject.js]
|
includes: [testBuiltInObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
testBuiltInObject(String.prototype.localeCompare, true);
|
testBuiltInObject(String.prototype.localeCompare);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user