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 24 This test checks the behavior of [[DefineOwnProperty]] applied to Array objects (see ES5.1 15.4.5.1). 25 26 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 27 28 29 PASS Object.defineProperty([], 'x', { get:function(){return true;} }).x is true 30 PASS Object.defineProperty([], 'length', { value: 1 }).length is 1 31 PASS var a = Object.defineProperty([], 'length', { writable: false }); a[1] = 1; a.length is 0 32 PASS var a = Object.defineProperty([], 'length', { writable: false }); a.length = 1; a.length is 0 33 PASS var a = Object.defineProperty([], 'length', {}); a.length = 1; a.length is 1 34 PASS Object.defineProperty([], 'length', { get:function(){return true;} }) threw exception TypeError: Cannot redefine property: length. 35 PASS Object.defineProperty([], 'length', { enumerable: true }) threw exception TypeError: Cannot redefine property: length. 36 PASS Object.defineProperty([], 'length', { configurable: true }) threw exception TypeError: Cannot redefine property: length. 37 PASS Object.defineProperty(Object.defineProperty([], 'length', { writable: false }), 'length', { writable: true }) threw exception TypeError: Cannot redefine property: length. 38 PASS var a = Object.defineProperty([], '0', { value: 42 }); a[0] is 42 39 PASS var a = Object.defineProperty([42], '0', { writable: false }); a[0] = 1; a[0] is 42 40 PASS var a = Object.defineProperty([42], '0', { enumerable: false }); a[0] + Object.keys(a).length is 42 41 PASS var a = Object.defineProperty([42], '0', { configurable: false }); a.length = 0; a[0] is 42 42 PASS var foo = 0; Object.defineProperty([], '0', { set:function(x){foo = x;} })[0] = 42; foo is 42 43 PASS Object.defineProperty([], '0', { get:function(){return true;} })[0] is true 44 PASS Object.defineProperty(Object.defineProperty([true], '0', { configurable:true, writable: false }), '0', { writable: true })[0] is true 45 PASS Object.defineProperty(Object.defineProperty([true], '0', { configurable:false, writable: false }), '0', { writable: true })[0] threw exception TypeError: Cannot redefine property: 0. 46 PASS Object.defineProperty(Object.defineProperty([], '0', { value: 1, writable:true }), '0', { value: 2 })[0] is 2 47 PASS Object.defineProperty(Object.defineProperty([], '0', { value: 1 }), '0', { value: 1 })[0] is 1 48 PASS Object.defineProperty(Object.defineProperty([], '0', { value: Number.NaN }), '0', { value: -Number.NaN })[0] is Number.NaN 49 PASS Object.defineProperty(Object.defineProperty([], '0', { value: 'okay'.substring(0,2) }), '0', { value: 'not ok'.substring(4,6) })[0] is "ok" 50 PASS Object.defineProperty(Object.defineProperty([], '0', { value: true }), '0', { value: true })[0] is true 51 PASS Object.defineProperty(Object.defineProperty([], '0', { value: false }), '0', { value: false })[0] is false 52 PASS Object.defineProperty(Object.defineProperty([], '0', { value: null }), '0', { value: null })[0] is null 53 PASS Object.defineProperty(Object.defineProperty([], '0', { value: undefined }), '0', { value: undefined })[0] is undefined 54 PASS Object.defineProperty(Object.defineProperty([], '0', { value: Math }), '0', { value: Math })[0] is Math 55 PASS Object.defineProperty(Object.defineProperty([], '0', { value: 1 }), '0', { value: 2 })[0] threw exception TypeError: Cannot redefine property: 0. 56 PASS Object.defineProperty(Object.defineProperty([], '0', { value: 'okay' }), '0', { value: 'not ok' })[0] threw exception TypeError: Cannot redefine property: 0. 57 PASS Object.defineProperty(Object.defineProperty([], '0', { value: true }), '0', { value: false })[0] threw exception TypeError: Cannot redefine property: 0. 58 PASS Object.defineProperty(Object.defineProperty([], '0', { value: false }), '0', { value: true })[0] threw exception TypeError: Cannot redefine property: 0. 59 PASS Object.defineProperty(Object.defineProperty([], '0', { value: Math }), '0', { value: Object })[0] threw exception TypeError: Cannot redefine property: 0. 60 PASS Object.defineProperty(Object.defineProperty([], '0', { value: null }), '0', { value: undefined })[0] threw exception TypeError: Cannot redefine property: 0. 61 PASS Object.defineProperty(Object.defineProperty([], '0', { value: undefined }), '0', { value: null })[0] threw exception TypeError: Cannot redefine property: 0. 62 PASS arrObj[0] = 42; arrObj.set; is true 63 PASS arrObj[1] = true; arrObj[1]; is true 64 PASS successfullyParsed is true 65 66 TEST COMPLETE 67 68