diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A1.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A1.js deleted file mode 100644 index 5f27c33bf9..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A1.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - When the isPrototypeOf method is called with argument V and when O and - V refer to the same object or to objects joined to each other, return true -es5id: 15.2.4.6_A1 -description: Creating two objects with the same prototype ----*/ - -function USER_FACTORY(name) { - this.name = name; - this.getName = function() { - return name; - }; -} - - -function FORCEDUSER_FACTORY(name, grade) { - this.name = name; - this.grade = grade; - this.getGrade = function() { - return grade; - }; -} - -var proto = new USER_FACTORY("noname"); - -FORCEDUSER_FACTORY.prototype = proto; - -var luke = new FORCEDUSER_FACTORY("Luke Skywalker", 12); -////// -// CHECK#1 -assert.sameValue( - proto.isPrototypeOf(luke), - true, - '#1: native ECMAScript objects have an internal property called [[Prototype]].' -); - -// -///////// -////// -// CHECK#2 -assert.sameValue( - USER_FACTORY.prototype.isPrototypeOf(luke), - true, - '#2: native ECMAScript objects have an internal property called [[Prototype]].' -); - -// -///////// -////// -// CHECK#3 -if (Number.isPrototypeOf(luke)) { - $ERROR('#2: Native ECMAScript objects have an internal property called [[Prototype]].'); -} -// -///////// diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A10.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A10.js deleted file mode 100644 index a1d7281691..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A10.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - The Object.prototype.isPrototypeOf.length property has the attribute - ReadOnly -es5id: 15.2.4.6_A10 -description: > - Checking if varying the Object.prototype.isPrototypeOf.length - property fails -includes: [propertyHelper.js] ----*/ - -//CHECK#1 -if (!(Object.prototype.isPrototypeOf.hasOwnProperty('length'))) { - $ERROR('#1: the Object.prototype.isPrototypeOf has length property'); -} - -var obj = Object.prototype.isPrototypeOf.length; - -verifyNotWritable(Object.prototype.isPrototypeOf, "length", null, function() { - return "shifted"; -}); - -//CHECK#2 -if (Object.prototype.isPrototypeOf.length !== obj) { - $ERROR('#2: the Object.prototype.isPrototypeOf length property has the attributes ReadOnly'); -} diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A11.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A11.js deleted file mode 100644 index dcd5e13e4e..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A11.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: The length property of the hasOwnProperty method is 1 -es5id: 15.2.4.6_A11 -description: Checking the Object.prototype.hasOwnProperty.length ----*/ - -//CHECK#1 -if (!(Object.prototype.isPrototypeOf.hasOwnProperty("length"))) { - $ERROR('#1: the Object.prototype.isPrototypeOf has length property'); -} - -//CHECK#2 -if (Object.prototype.isPrototypeOf.length !== 1) { - $ERROR('#2: The length property of the toObject method is 1'); -} diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A12.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A12.js deleted file mode 100644 index 49afa59a15..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A12.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2011 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.2.4.6_A12 -description: > - Let O be the result of calling ToObject passing the this value as - the argument. ----*/ - -assert.throws(TypeError, function() { - Object.prototype.isPrototypeOf.call(undefined, {}); -}); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A13.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A13.js deleted file mode 100644 index ebe5259a85..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A13.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2011 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.2.4.6_A13 -description: > - Let O be the result of calling ToObject passing the this value as - the argument. ----*/ - -assert.throws(TypeError, function() { - Object.prototype.isPrototypeOf.call(null, {}); -}); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A6.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A6.js deleted file mode 100644 index 3ab10f971f..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A6.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Object.prototype.isPrototypeOf has not prototype property -es5id: 15.2.4.6_A6 -description: > - Checking if obtaining the prototype property of - Object.prototype.isPrototypeOf fails ----*/ - -//CHECK#1 -if (Object.prototype.isPrototypeOf.prototype !== undefined) { - $ERROR('#1: Object.prototype.isPrototypeOf has not prototype property' + Object.prototype.isPrototypeOf.prototype); -} -// diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A7.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A7.js deleted file mode 100644 index 5e9bf6d46f..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A7.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Object.prototype.isPrototypeOf can't be used as a constructor -es5id: 15.2.4.6_A7 -description: Checking if creating new "Object.prototype.isPrototypeOf" fails ----*/ - -var FACTORY = Object.prototype.isPrototypeOf; - -assert.throws(TypeError, function() { - new FACTORY; -}); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A8.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A8.js deleted file mode 100644 index 8c959469bd..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A8.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - The Object.prototype.isPrototypeOf.length property has the attribute - DontEnum -es5id: 15.2.4.6_A8 -description: > - Checknig if enumerating the Object.prototype.isPrototypeOf.length - property fails ----*/ - -//CHECK#0 -if (!(Object.prototype.isPrototypeOf.hasOwnProperty('length'))) { - $ERROR('#0: the Object.prototype.isPrototypeOf has length property'); -} - - -// CHECK#1 -if (Object.prototype.isPrototypeOf.propertyIsEnumerable('length')) { - $ERROR('#1: the Object.prototype.isPrototypeOf.length property has the attributes DontEnum'); -} - -// CHECK#2 -for (var p in Object.prototype.isPrototypeOf) { - if (p === "length") - $ERROR('#2: the Object.prototype.isPrototypeOf.length property has the attributes DontEnum'); -} -// diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A9.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A9.js deleted file mode 100644 index 4e9d544573..0000000000 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A9.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - The Object.prototype.isPrototypeOf.length property does not have the - attribute DontDelete -es5id: 15.2.4.6_A9 -description: > - Checking deleting the Object.prototype.isPrototypeOf.length - property fails ----*/ - -//CHECK#0 -if (!(Object.prototype.isPrototypeOf.hasOwnProperty('length'))) { - $ERROR('#0: the Object.prototype.isPrototypeOf has length property'); -} - -//CHECK#1 -if (!delete Object.prototype.isPrototypeOf.length) { - $ERROR('#1: The Object.prototype.isPrototypeOf.length property does not have the attributes DontDelete'); -} -// diff --git a/test/built-ins/Object/prototype/isPrototypeOf/arg-is-proxy.js b/test/built-ins/Object/prototype/isPrototypeOf/arg-is-proxy.js new file mode 100644 index 0000000000..0b8e11dcb3 --- /dev/null +++ b/test/built-ins/Object/prototype/isPrototypeOf/arg-is-proxy.js @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.isprototypeof +description: > + If V is a Proxy object, only its "getPrototypeOf" trap gets invoked. +info: | + Object.prototype.isPrototypeOf ( V ) + + ... + 3. Repeat, + a. Set V to ? V.[[GetPrototypeOf]](). + b. If V is null, return false. + c. If SameValue(O, V) is true, return true. +includes: [proxyTrapsHelper.js] +features: [Proxy] +---*/ + +var proxyProto = []; +var handler = allowProxyTraps({ + getPrototypeOf: function(_target) { + return proxyProto; + }, +}); + +var proxy = new Proxy({}, handler); + +assert.sameValue(proxyProto.isPrototypeOf(proxy), true); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/builtin.js b/test/built-ins/Object/prototype/isPrototypeOf/builtin.js new file mode 100644 index 0000000000..d81c293c21 --- /dev/null +++ b/test/built-ins/Object/prototype/isPrototypeOf/builtin.js @@ -0,0 +1,18 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.isprototypeof +description: > + Tests that Object.prototype.isPrototypeOf meets the requirements + for built-in objects defined by the introduction of chapter 17 of + the ECMAScript Language Specification. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert(Object.isExtensible(Object.prototype.isPrototypeOf)); +assert.sameValue(Object.prototype.toString.call(Object.prototype.isPrototypeOf), "[object Function]"); +assert.sameValue(Object.getPrototypeOf(Object.prototype.isPrototypeOf), Function.prototype); +assert.sameValue(Object.prototype.isPrototypeOf.hasOwnProperty("prototype"), false); +assert.sameValue(isConstructor(Object.prototype.isPrototypeOf), false); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/length.js b/test/built-ins/Object/prototype/isPrototypeOf/length.js new file mode 100644 index 0000000000..b8e24bae8a --- /dev/null +++ b/test/built-ins/Object/prototype/isPrototypeOf/length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.isprototypeof +description: > + Object.prototype.isPrototypeOf.length is 1. +info: | + Object.prototype.isPrototypeOf ( V ) + + ECMAScript Standard Built-in Objects + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object.prototype.isPrototypeOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/name.js b/test/built-ins/Object/prototype/isPrototypeOf/name.js index 5459620e3f..87fca6ca11 100644 --- a/test/built-ins/Object/prototype/isPrototypeOf/name.js +++ b/test/built-ins/Object/prototype/isPrototypeOf/name.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 19.1.3.3 +esid: sec-object.prototype.isprototypeof description: > Object.prototype.isPrototypeOf.name is "isPrototypeOf". info: | @@ -19,8 +19,9 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.prototype.isPrototypeOf.name, "isPrototypeOf"); - -verifyNotEnumerable(Object.prototype.isPrototypeOf, "name"); -verifyNotWritable(Object.prototype.isPrototypeOf, "name"); -verifyConfigurable(Object.prototype.isPrototypeOf, "name"); +verifyProperty(Object.prototype.isPrototypeOf, "name", { + value: "isPrototypeOf", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/null-this-and-object-arg-throws.js b/test/built-ins/Object/prototype/isPrototypeOf/null-this-and-object-arg-throws.js new file mode 100644 index 0000000000..11f0acaabb --- /dev/null +++ b/test/built-ins/Object/prototype/isPrototypeOf/null-this-and-object-arg-throws.js @@ -0,0 +1,19 @@ +// Copyright (C) 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.isprototypeof +description: > + The ordering of steps 1 and 2 preserves the behaviour specified by previous + editions of this specification for the case where V is not an object and + the this value is undefined or null. +info: | + Object.prototype.isPrototypeOf ( V ) + + 1. If Type(V) is not Object, return false. + 2. Let O be ? ToObject(this value). +---*/ + +assert.throws(TypeError, function() { + Object.prototype.isPrototypeOf.call(null, function() {}); +}); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/null-this-and-primitive-arg-returns-false.js b/test/built-ins/Object/prototype/isPrototypeOf/null-this-and-primitive-arg-returns-false.js new file mode 100644 index 0000000000..1f440e9388 --- /dev/null +++ b/test/built-ins/Object/prototype/isPrototypeOf/null-this-and-primitive-arg-returns-false.js @@ -0,0 +1,23 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.isprototypeof +description: > + The ordering of steps 1 and 2 preserves the behaviour specified by previous + editions of this specification for the case where V is not an object and + the this value is undefined or null. +info: | + Object.prototype.isPrototypeOf ( V ) + + 1. If Type(V) is not Object, return false. + 2. Let O be ? ToObject(this value). +features: [Symbol] +---*/ + +assert.sameValue(Object.prototype.isPrototypeOf.call(null, undefined), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(null, null), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(null, false), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(null, ""), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(null, Symbol()), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(null, 10), false); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/this-value-is-in-prototype-chain-of-arg.js b/test/built-ins/Object/prototype/isPrototypeOf/this-value-is-in-prototype-chain-of-arg.js new file mode 100644 index 0000000000..373bb49bbb --- /dev/null +++ b/test/built-ins/Object/prototype/isPrototypeOf/this-value-is-in-prototype-chain-of-arg.js @@ -0,0 +1,42 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.isprototypeof +description: > + Object.prototype.isPrototypeOf returns true if either parameter V + and O refer to the same object or O is in [[Prototype]] chain of V. +info: | + Object.prototype.isPrototypeOf ( V ) + + ... + 3. Repeat, + a. Set V to ? V.[[GetPrototypeOf]](). + b. If V is null, return false. + c. If SameValue(O, V) is true, return true. +---*/ + +function USER_FACTORY(name) { + this.name = name; + this.getName = function() { + return name; + }; +} + +function FORCEDUSER_FACTORY(name, grade) { + this.name = name; + this.grade = grade; + this.getGrade = function() { + return grade; + }; +} + +var proto = new USER_FACTORY("noname"); + +FORCEDUSER_FACTORY.prototype = proto; + +var luke = new FORCEDUSER_FACTORY("Luke Skywalker", 12); + +assert.sameValue(proto.isPrototypeOf(luke), true); +assert.sameValue(USER_FACTORY.prototype.isPrototypeOf(luke), true); +assert.sameValue(Number.isPrototypeOf(luke), false); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/undefined-this-and-object-arg-throws.js b/test/built-ins/Object/prototype/isPrototypeOf/undefined-this-and-object-arg-throws.js new file mode 100644 index 0000000000..75294d9f0c --- /dev/null +++ b/test/built-ins/Object/prototype/isPrototypeOf/undefined-this-and-object-arg-throws.js @@ -0,0 +1,19 @@ +// Copyright (C) 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.isprototypeof +description: > + The ordering of steps 1 and 2 preserves the behaviour specified by previous + editions of this specification for the case where V is not an object and + the this value is undefined or null. +info: | + Object.prototype.isPrototypeOf ( V ) + + 1. If Type(V) is not Object, return false. + 2. Let O be ? ToObject(this value). +---*/ + +assert.throws(TypeError, function() { + Object.prototype.isPrototypeOf.call(undefined, {}); +}); diff --git a/test/built-ins/Object/prototype/isPrototypeOf/undefined-this-and-primitive-arg-returns-false.js b/test/built-ins/Object/prototype/isPrototypeOf/undefined-this-and-primitive-arg-returns-false.js new file mode 100644 index 0000000000..3aa0f3e573 --- /dev/null +++ b/test/built-ins/Object/prototype/isPrototypeOf/undefined-this-and-primitive-arg-returns-false.js @@ -0,0 +1,23 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.isprototypeof +description: > + The ordering of steps 1 and 2 preserves the behaviour specified by previous + editions of this specification for the case where V is not an object and + the this value is undefined or null. +info: | + Object.prototype.isPrototypeOf ( V ) + + 1. If Type(V) is not Object, return false. + 2. Let O be ? ToObject(this value). +features: [Symbol] +---*/ + +assert.sameValue(Object.prototype.isPrototypeOf.call(undefined, undefined), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(undefined, null), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(undefined, true), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(undefined, "str"), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(undefined, Symbol("desc")), false); +assert.sameValue(Object.prototype.isPrototypeOf.call(undefined, 3.14), false);