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