diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/this-value-is-in-prototype-chain-of-arg.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/this-value-is-in-prototype-chain-of-arg.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/this-value-is-in-prototype-chain-of-arg.js b/js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/this-value-is-in-prototype-chain-of-arg.js new file mode 100644 index 0000000000..fe5773032a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/this-value-is-in-prototype-chain-of-arg.js @@ -0,0 +1,44 @@ +// 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); + +reportCompare(0, 0); |