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 FAIL currentHolder.hasOwnProperty(0) should be false. Was true. 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 FAIL currentHolder.length should be 3. Was 4. 80 81 Ensure that we always get the same holder 82 PASS currentHolder is lastHolder 83 FAIL Did not call reviver for deleted property 84 85 Ensure that we created the root holder as specified in ES5 86 PASS '' in lastHolder is true 87 PASS result is lastHolder[''] 88 89 Ensure that a deleted value is revived if the reviver function returns a value 90 FAIL result.hasOwnProperty(3) should be true. Was false. 91 92 Test behaviour of revivor used in conjunction with an object 93 PASS currentHolder != globalObject is true 94 95 Ensure that the holder already has all the properties present at the start of filtering 96 PASS currentHolder['a property'] is "a value" 97 PASS currentHolder['another property'] is "another value" 98 PASS currentHolder['and another property'] is "and another value" 99 PASS currentHolder['to delete'] is "will be deleted" 100 PASS currentHolder != globalObject is true 101 102 Ensure that we get the same holder object for each property 103 PASS currentHolder is lastHolder 104 105 Ensure that returning undefined has correctly removed the property 'a property' from the holder object 106 PASS currentHolder.hasOwnProperty('a property') is false 107 PASS currentHolder != globalObject is true 108 109 Ensure that we get the same holder object for each property 110 PASS currentHolder is lastHolder 111 Ensure that changing the value of a property is reflected while filtering. 112 PASS currentHolder['and another property'] is "a replaced value" 113 114 Ensure that the changed value is reflected in the arguments passed to the reviver 115 PASS value is "a replaced value" 116 117 Ensure that we created the root holder as specified in ES5 118 PASS lastHolder.hasOwnProperty('') is true 119 PASS result.hasOwnProperty('a property') is false 120 FAIL result.hasOwnProperty('to delete') should be true. Was false. 121 PASS result is lastHolder[''] 122 123 Test behaviour of revivor that introduces a cycle 124 PASS JSON.parse("[0,1]", reviveAddsCycle) threw exception RangeError: Maximum call stack size exceeded. 125 126 Test behaviour of revivor that introduces a new array classed object (the result of a regex) 127 PASS JSON.stringify(JSON.parse("[0,1]", reviveIntroducesNewArrayLikeObject)) is '[0,["a","a"]]' 128 PASS successfullyParsed is true 129 130 TEST COMPLETE 131 132