diff options
author | André Bargull <andre.bargull@gmail.com> | 2017-12-21 12:08:28 -0800 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2017-12-21 16:46:56 -0500 |
commit | c81370348d9dffa6f43373c4ed959a4d25970f21 (patch) | |
tree | a2c1ba2c192b6f2fed703355e7c2d3b5ad6edd74 /harness | |
parent | ecf814bb4cfc0aa556bac79f1fbd801644b8a64e (diff) | |
download | qtdeclarative-testsuites-c81370348d9dffa6f43373c4ed959a4d25970f21.tar.gz |
No longer use testBuiltInObject for built-in objects
Diffstat (limited to 'harness')
-rw-r--r-- | harness/testBuiltInObject.js | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/harness/testBuiltInObject.js b/harness/testBuiltInObject.js index 52505f262..af0081c87 100644 --- a/harness/testBuiltInObject.js +++ b/harness/testBuiltInObject.js @@ -9,56 +9,47 @@ description: | * @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. - * @param {boolean} isFunction whether the specification describes obj as a function. * @author Norbert Lindenberg */ -function testBuiltInObject(obj, isFunction) { +function testBuiltInObject(obj) { if (obj === undefined) { $ERROR("Object being tested is undefined."); } var objString = Object.prototype.toString.call(obj); - if (isFunction) { - if (objString !== "[object Function]") { - $ERROR("The [[Class]] internal property of a built-in function must be " + - "\"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 (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 (isFunction && Object.getPrototypeOf(obj) !== Function.prototype) { + if (Object.getPrototypeOf(obj) !== Function.prototype) { $ERROR("Built-in functions must have Function.prototype as their prototype."); } var exception; - 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 - // 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."); - } + // 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 (isFunction && obj.hasOwnProperty("prototype")) { + if (obj.hasOwnProperty("prototype")) { $ERROR("Built-in functions that aren't constructors must not have a prototype property."); } |