JSON-parse-reviver-expected.txt 5.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1.  Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Test behaviour of JSON reviver function.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".



Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 5

Ensure that the holder already has all the properties present at the start of filtering
PASS currentHolder[0] is "a value"
PASS currentHolder[1] is "another value"
PASS currentHolder[2] is "and another value"
PASS currentHolder[3] is "to delete"
PASS currentHolder[4] is "extra value"

Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 5

Ensure that we always get the same holder
PASS currentHolder is lastHolder

Ensure that returning undefined has removed the property 0 from the holder during filtering.
49
PASS currentHolder.hasOwnProperty(0) is false
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 5

Ensure that we always get the same holder
PASS currentHolder is lastHolder

Ensure that changing the value of a property is reflected while filtering.
PASS currentHolder[2] is "a replaced value"

Ensure that the changed value is reflected in the arguments passed to the reviver
PASS value is currentHolder[2]

Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
PASS currentHolder.length is 5

Ensure that we always get the same holder
PASS currentHolder is lastHolder

Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering.
PASS currentHolder.hasOwnProperty(3) is false

Ensure that when visiting a deleted property value is undefined
PASS value is undefined.

Ensure the holder for our array is indeed an array
PASS Array.isArray(currentHolder) is true
79
PASS currentHolder.length is 4
80 81 82

Ensure that we always get the same holder
PASS currentHolder is lastHolder
83 84
PASS Ensured that property was visited despite Array length being reduced.
PASS value is undefined.
85 86 87 88 89 90

Ensure that we created the root holder as specified in ES5
PASS '' in lastHolder is true
PASS result is lastHolder['']

Ensure that a deleted value is revived if the reviver function returns a value
91
PASS result.hasOwnProperty(3) is true
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116

Test behaviour of revivor used in conjunction with an object
PASS currentHolder != globalObject is true

Ensure that the holder already has all the properties present at the start of filtering
PASS currentHolder['a property'] is "a value"
PASS currentHolder['another property'] is "another value"
PASS currentHolder['and another property'] is "and another value"
PASS currentHolder['to delete'] is "will be deleted"
PASS currentHolder != globalObject is true

Ensure that we get the same holder object for each property
PASS currentHolder is lastHolder

Ensure that returning undefined has correctly removed the property 'a property' from the holder object
PASS currentHolder.hasOwnProperty('a property') is false
PASS currentHolder != globalObject is true

Ensure that we get the same holder object for each property
PASS currentHolder is lastHolder
Ensure that changing the value of a property is reflected while filtering.
PASS currentHolder['and another property'] is "a replaced value"

Ensure that the changed value is reflected in the arguments passed to the reviver
PASS value is "a replaced value"
117 118 119 120 121 122 123 124 125 126
PASS currentHolder != globalObject is true

Ensure that we get the same holder object for each property
PASS currentHolder is lastHolder

Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering.
PASS currentHolder.hasOwnProperty('to delete') is false

Ensure that when visiting a deleted property value is undefined
PASS value is undefined.
127 128 129 130

Ensure that we created the root holder as specified in ES5
PASS lastHolder.hasOwnProperty('') is true
PASS result.hasOwnProperty('a property') is false
131
PASS result.hasOwnProperty('to delete') is true
132 133 134 135 136 137 138 139 140 141 142
PASS result is lastHolder['']

Test behaviour of revivor that introduces a cycle
PASS JSON.parse("[0,1]", reviveAddsCycle) threw exception RangeError: Maximum call stack size exceeded.

Test behaviour of revivor that introduces a new array classed object (the result of a regex)
PASS JSON.stringify(JSON.parse("[0,1]", reviveIntroducesNewArrayLikeObject)) is '[0,["a","a"]]'
PASS successfullyParsed is true

TEST COMPLETE