mirror of
https://github.com/tc39/test262.git
synced 2025-07-21 13:04:39 +02:00
Remove harness/testBuiltInObject.js file
This commit is contained in:
parent
60692bb6e0
commit
266e0ffb66
@ -191,9 +191,14 @@ directory of the Test262 project.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
/*---
|
/*---
|
||||||
includes: [testBuildInObject.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
testBuiltInObject(Number.prototype.toLocaleString, true, false, [], 0);
|
verifyProperty(this, "Object", {
|
||||||
|
value: Object,
|
||||||
|
writable: true,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### `flags`
|
### `flags`
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
description: |
|
|
||||||
A function used to assert the correctness of 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.
|
|
||||||
* @param {Object} obj the object to be tested.
|
|
||||||
* @author Norbert Lindenberg
|
|
||||||
*/
|
|
||||||
|
|
||||||
function testBuiltInObject(obj) {
|
|
||||||
|
|
||||||
if (obj === undefined) {
|
|
||||||
$ERROR("Object being tested is undefined.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var objString = Object.prototype.toString.call(obj);
|
|
||||||
|
|
||||||
if (objString !== "[object Function]") {
|
|
||||||
$ERROR("The [[Class]] internal property of a built-in function must be " +
|
|
||||||
"\"Function\", but toString() returns " + objString);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Object.isExtensible(obj)) {
|
|
||||||
$ERROR("Built-in objects must be extensible.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.getPrototypeOf(obj) !== Function.prototype) {
|
|
||||||
$ERROR("Built-in functions must have Function.prototype as their prototype.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var exception;
|
|
||||||
// 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
|
|
||||||
// arguments or the this value that this statement doesn't meet.
|
|
||||||
try {
|
|
||||||
/*jshint newcap:false*/
|
|
||||||
var instance = new obj();
|
|
||||||
} catch (e) {
|
|
||||||
exception = e;
|
|
||||||
}
|
|
||||||
if (exception === undefined || exception.name !== "TypeError") {
|
|
||||||
$ERROR("Built-in functions that aren't constructors must throw TypeError when " +
|
|
||||||
"used in a \"new\" statement.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj.hasOwnProperty("prototype")) {
|
|
||||||
$ERROR("Built-in functions that aren't constructors must not have a prototype property.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// passed the complete test!
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Objects that are expected to be functions but do not define the correct
|
|
||||||
[[Class]] internal property do not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(null, true);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Functions whose `length` property does not match the expected value do not
|
|
||||||
satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(function(a, b) {}, true, false, [], 3);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Non-constructor functions that do not throw an when invoked via `new` do
|
|
||||||
not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(function() {}, true, false, [], 0);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Non-constructor functions that do not throw a TypeError when invoked via
|
|
||||||
`new` do not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
var fn = function() {
|
|
||||||
throw new Error();
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(fn, true, false, [], 0);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Objects that are not extensible do not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
var obj = {};
|
|
||||||
Object.preventExtensions(obj);
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(obj);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Objects that are not expected to be functions but do not define the correct
|
|
||||||
[[Class]] internal property do not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(function() {}, false);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Objects that do not define all of the specified "own" properties as
|
|
||||||
non-enumerable do not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
var obj = {};
|
|
||||||
Object.defineProperty(obj, 'a', {
|
|
||||||
writable: true, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(obj, 'b', {
|
|
||||||
writable: true, enumerable: true, configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(obj, 'c', {
|
|
||||||
writable: true, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(obj, false, false, ['a', 'b', 'c']);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Objects that do not define all of the specified "own" properties do not
|
|
||||||
satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
var obj = {};
|
|
||||||
Object.defineProperty(obj, 'a', {
|
|
||||||
writable: true, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(obj, 'c', {
|
|
||||||
writable: true, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(obj, false, false, ['a', 'b', 'c']);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Objects that do not define all of the specified "own" properties as
|
|
||||||
configurable do not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
var obj = {};
|
|
||||||
Object.defineProperty(obj, 'a', {
|
|
||||||
writable: true, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(obj, 'b', {
|
|
||||||
writable: true, enumerable: false, configurable: false
|
|
||||||
});
|
|
||||||
Object.defineProperty(obj, 'c', {
|
|
||||||
writable: true, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(obj, false, false, ['a', 'b', 'c']);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Objects that do not define all of the specified "own" properties as
|
|
||||||
writable do not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
var obj = {};
|
|
||||||
Object.defineProperty(obj, 'a', {
|
|
||||||
writable: true, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(obj, 'b', {
|
|
||||||
writable: false, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(obj, 'c', {
|
|
||||||
writable: true, enumerable: false, configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(obj, false, false, ['a', 'b', 'c']);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
`undefined` does not satisfy the assertion.
|
|
||||||
includes: [testBuiltInObject.js,sta.js]
|
|
||||||
---*/
|
|
||||||
var threw = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
testBuiltInObject(undefined);
|
|
||||||
} catch(err) {
|
|
||||||
threw = true;
|
|
||||||
if (err.constructor !== Test262Error) {
|
|
||||||
$ERROR(
|
|
||||||
'Expected a Test262Error, but a "' + err.constructor.name +
|
|
||||||
'" was thrown.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threw === false) {
|
|
||||||
$ERROR('Expected a Test262Error, but no error was thrown.');
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user