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 Test behaviour of JSON reviver function. 25 26 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 27 28 29 30 Ensure the holder for our array is indeed an array 31 PASS Array.isArray(currentHolder) is true 32 PASS currentHolder.length is 5 33 34 Ensure that the holder already has all the properties present at the start of filtering 35 PASS currentHolder[0] is "a value" 36 PASS currentHolder[1] is "another value" 37 PASS currentHolder[2] is "and another value" 38 PASS currentHolder[3] is "to delete" 39 PASS currentHolder[4] is "extra value" 40 41 Ensure the holder for our array is indeed an array 42 PASS Array.isArray(currentHolder) is true 43 PASS currentHolder.length is 5 44 45 Ensure that we always get the same holder 46 PASS currentHolder is lastHolder 47 48 Ensure that returning undefined has removed the property 0 from the holder during filtering. 49 PASS currentHolder.hasOwnProperty(0) is false 50 51 Ensure the holder for our array is indeed an array 52 PASS Array.isArray(currentHolder) is true 53 PASS currentHolder.length is 5 54 55 Ensure that we always get the same holder 56 PASS currentHolder is lastHolder 57 58 Ensure that changing the value of a property is reflected while filtering. 59 PASS currentHolder[2] is "a replaced value" 60 61 Ensure that the changed value is reflected in the arguments passed to the reviver 62 PASS value is currentHolder[2] 63 64 Ensure the holder for our array is indeed an array 65 PASS Array.isArray(currentHolder) is true 66 PASS currentHolder.length is 5 67 68 Ensure that we always get the same holder 69 PASS currentHolder is lastHolder 70 71 Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering. 72 PASS currentHolder.hasOwnProperty(3) is false 73 74 Ensure that when visiting a deleted property value is undefined 75 PASS value is undefined. 76 77 Ensure the holder for our array is indeed an array 78 PASS Array.isArray(currentHolder) is true 79 PASS currentHolder.length is 4 80 81 Ensure that we always get the same holder 82 PASS currentHolder is lastHolder 83 PASS Ensured that property was visited despite Array length being reduced. 84 PASS value is undefined. 85 86 Ensure that we created the root holder as specified in ES5 87 PASS '' in lastHolder is true 88 PASS result is lastHolder[''] 89 90 Ensure that a deleted value is revived if the reviver function returns a value 91 PASS result.hasOwnProperty(3) is true 92 93 Test behaviour of revivor used in conjunction with an object 94 PASS currentHolder != globalObject is true 95 96 Ensure that the holder already has all the properties present at the start of filtering 97 PASS currentHolder['a property'] is "a value" 98 PASS currentHolder['another property'] is "another value" 99 PASS currentHolder['and another property'] is "and another value" 100 PASS currentHolder['to delete'] is "will be deleted" 101 PASS currentHolder != globalObject is true 102 103 Ensure that we get the same holder object for each property 104 PASS currentHolder is lastHolder 105 106 Ensure that returning undefined has correctly removed the property 'a property' from the holder object 107 PASS currentHolder.hasOwnProperty('a property') is false 108 PASS currentHolder != globalObject is true 109 110 Ensure that we get the same holder object for each property 111 PASS currentHolder is lastHolder 112 Ensure that changing the value of a property is reflected while filtering. 113 PASS currentHolder['and another property'] is "a replaced value" 114 115 Ensure that the changed value is reflected in the arguments passed to the reviver 116 PASS value is "a replaced value" 117 PASS currentHolder != globalObject is true 118 119 Ensure that we get the same holder object for each property 120 PASS currentHolder is lastHolder 121 122 Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering. 123 PASS currentHolder.hasOwnProperty('to delete') is false 124 125 Ensure that when visiting a deleted property value is undefined 126 PASS value is undefined. 127 128 Ensure that we created the root holder as specified in ES5 129 PASS lastHolder.hasOwnProperty('') is true 130 PASS result.hasOwnProperty('a property') is false 131 PASS result.hasOwnProperty('to delete') is true 132 PASS result is lastHolder[''] 133 134 Test behaviour of revivor that introduces a cycle 135 PASS JSON.parse("[0,1]", reviveAddsCycle) threw exception RangeError: Maximum call stack size exceeded. 136 137 Test behaviour of revivor that introduces a new array classed object (the result of a regex) 138 PASS JSON.stringify(JSON.parse("[0,1]", reviveIntroducesNewArrayLikeObject)) is '[0,["a","a"]]' 139 PASS successfullyParsed is true 140 141 TEST COMPLETE 142 143