1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 assertFalse('x' in o);
34 assertFalse('y' in o);
35 assertTrue('toString' in o, "toString");
40 assertFalse('y' in o);
41 assertTrue('toString' in o, "toString");
43 var o = { x: 12, y: 15 };
47 assertTrue('toString' in o, "toString");
56 assertFalse('0' in a);
57 assertFalse('1' in a);
58 assertTrue('toString' in a, "toString");
64 assertFalse('1' in a);
65 assertTrue('toString' in a, "toString");
72 assertTrue('toString' in a, "toString");
75 assertFalse(0.001 in a);
78 assertFalse('0.0' in a);
79 assertFalse('1.0' in a);
80 assertFalse(NaN in a);
81 assertFalse(Infinity in a);
82 assertFalse(-Infinity in a);
89 assertFalse('0' in a);
91 assertFalse('2' in a);
92 assertTrue('toString' in a, "toString");
96 // Check dictionary ("normalized") objects
99 for (var i = 0x0020; i < 0x02ff; i += 2) {
100 o['char:' + String.fromCharCode(i)] = i;
102 for (var i = 0x0020; i < 0x02ff; i += 2) {
103 assertTrue('char:' + String.fromCharCode(i) in o);
104 assertFalse('char:' + String.fromCharCode(i + 1) in o);
106 assertTrue('toString' in o, "toString");
109 o[Math.pow(2,30)-1] = 0;
110 o[Math.pow(2,31)-1] = 0;
115 assertFalse(Math.pow(2,30)-2 in o);
116 assertTrue(Math.pow(2,30)-1 in o);
117 assertFalse(Math.pow(2,30)-0 in o);
118 assertTrue(Math.pow(2,31)-1 in o);
119 assertFalse(0.001 in o);
120 assertFalse('0.0' in o);
121 assertFalse('1.0' in o);
122 assertFalse(NaN in o);
123 assertFalse(Infinity in o);
124 assertFalse(-Infinity in o);
125 assertFalse(-0 in o);
126 assertFalse(+0 in o);
127 assertTrue('toString' in o, "toString");
131 // Check sparse arrays
134 a[Math.pow(2,30)-1] = 0;
135 a[Math.pow(2,31)-1] = 0;
137 assertFalse(0 in a, "0 in a");
138 assertTrue(1 in a, "1 in a");
139 assertFalse(2 in a, "2 in a");
140 assertFalse(Math.pow(2,30)-2 in a, "Math.pow(2,30)-2 in a");
141 assertTrue(Math.pow(2,30)-1 in a, "Math.pow(2,30)-1 in a");
142 assertFalse(Math.pow(2,30)-0 in a, "Math.pow(2,30)-0 in a");
143 assertTrue(Math.pow(2,31)-1 in a, "Math.pow(2,31)-1 in a");
144 assertFalse(0.001 in a, "0.001 in a");
145 assertFalse('0.0' in a,"'0.0' in a");
146 assertFalse('1.0' in a,"'1.0' in a");
147 assertFalse(NaN in a,"NaN in a");
148 assertFalse(Infinity in a,"Infinity in a");
149 assertFalse(-Infinity in a,"-Infinity in a");
150 assertFalse(-0 in a,"-0 in a");
151 assertFalse(+0 in a,"+0 in a");
152 assertTrue('toString' in a, "toString");
155 // Check negative indices in arrays.
157 assertFalse(-1 in a);