1# Copyright 2013 the V8 project authors. All rights reserved. 2# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions 6# are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# 2. Redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution. 12# 13# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY 14# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 24Test prototypes of various objects and the various means to access them. 25 26On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 27 28 29PASS ('').__proto__ is String.prototype 30PASS (0).__proto__ is Number.prototype 31PASS ([]).__proto__ is Array.prototype 32PASS ({}).__proto__ is Object.prototype 33PASS (new Date).__proto__ is Date.prototype 34PASS (new Number).__proto__ is Number.prototype 35PASS (new Object).__proto__ is Object.prototype 36PASS (new String).__proto__ is String.prototype 37PASS Array.prototype.__proto__ is Object.prototype 38PASS Date.prototype.__proto__ is Object.prototype 39PASS Number.prototype.__proto__ is Object.prototype 40PASS Object.prototype.__proto__ is null 41PASS String.prototype.__proto__ is Object.prototype 42PASS Array.__proto__ is Object.__proto__ 43PASS Date.__proto__ is Object.__proto__ 44PASS Number.__proto__ is Object.__proto__ 45PASS String.__proto__ is Object.__proto__ 46PASS Object.getPrototypeOf('') is String.prototype 47PASS Object.getPrototypeOf(0) is Number.prototype 48PASS Object.getPrototypeOf([]) is Array.prototype 49PASS Object.getPrototypeOf({}) is Object.prototype 50PASS Object.getPrototypeOf(new Date) is Date.prototype 51PASS Object.getPrototypeOf(new Number) is Number.prototype 52PASS Object.getPrototypeOf(new Object) is Object.prototype 53PASS Object.getPrototypeOf(new String) is String.prototype 54PASS Object.getPrototypeOf(Array.prototype) is Object.prototype 55PASS Object.getPrototypeOf(Date.prototype) is Object.prototype 56PASS Object.getPrototypeOf(Number.prototype) is Object.prototype 57PASS Object.getPrototypeOf(Object.prototype) is null 58PASS Object.getPrototypeOf(String.prototype) is Object.prototype 59PASS Object.getPrototypeOf(Array) is Object.__proto__ 60PASS Object.getPrototypeOf(Date) is Object.__proto__ 61PASS Object.getPrototypeOf(Number) is Object.__proto__ 62PASS Object.getPrototypeOf(String) is Object.__proto__ 63PASS String.prototype.isPrototypeOf('') is false 64PASS Number.prototype.isPrototypeOf(0) is false 65PASS Array.prototype.isPrototypeOf([]) is true 66PASS Object.prototype.isPrototypeOf({}) is true 67PASS Date.prototype.isPrototypeOf(new Date) is true 68PASS Number.prototype.isPrototypeOf(new Number) is true 69PASS Object.prototype.isPrototypeOf(new Object) is true 70PASS String.prototype.isPrototypeOf(new String) is true 71PASS Object.prototype.isPrototypeOf(Array.prototype) is true 72PASS Object.prototype.isPrototypeOf(Date.prototype) is true 73PASS Object.prototype.isPrototypeOf(Number.prototype) is true 74PASS Object.prototype.isPrototypeOf(String.prototype) is true 75PASS Object.__proto__.isPrototypeOf(Array) is true 76PASS Object.__proto__.isPrototypeOf(Date) is true 77PASS Object.__proto__.isPrototypeOf(Number) is true 78PASS Object.__proto__.isPrototypeOf(String) is true 79PASS var wasSet = false; var o = { }; o.__defineGetter__("__proto__", function() { wasSet = true }); o.__proto__; wasSet; is true 80PASS var wasSet = false; var o = { }; o.__defineSetter__("__proto__", function() { wasSet = true }); o.__proto__ = {}; wasSet; is true 81PASS var wasSet = false; var o = { }; Object.defineProperty(o, "__proto__", { "get": function() { wasSet = true } }); o.__proto__; wasSet; is true 82PASS var wasSet = false; var o = { }; Object.defineProperty(o, "__proto__", { "__proto__": function(x) { wasSet = true } }); o.__proto__ = {}; wasSet; is false 83PASS var o = {}; o.__proto__ = { x:true }; o.x is true 84PASS var o = {}; o.__proto__ = { x:true }; o.hasOwnProperty('__proto__') is false 85PASS var o = {}; o.__proto__ = { x:true }; o.x is undefined. 86PASS var o = {}; o.__proto__ = { x:true }; o.hasOwnProperty('__proto__') is true 87PASS successfullyParsed is true 88 89TEST COMPLETE 90 91