OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 var keys = [0, '1', 2, 3.0, -1, 10]; | 189 var keys = [0, '1', 2, 3.0, -1, 10]; |
190 var str = 'abcd', arr = ['a', 'b', 'c', 'd', undefined, undefined]; | 190 var str = 'abcd', arr = ['a', 'b', 'c', 'd', undefined, undefined]; |
191 for (var i = 0; i < 300; ++i) { | 191 for (var i = 0; i < 300; ++i) { |
192 var index = Math.floor(i / 50); | 192 var index = Math.floor(i / 50); |
193 var key = keys[index]; | 193 var key = keys[index]; |
194 var expected = arr[index]; | 194 var expected = arr[index]; |
195 var actual = str[key]; | 195 var actual = str[key]; |
196 assertEquals(expected, actual); | 196 assertEquals(expected, actual); |
197 } | 197 } |
| 198 |
| 199 // Test heap number case. |
| 200 var keys = [0, Math.floor(2) * 0.5]; |
| 201 var str = 'ab', arr = ['a', 'b']; |
| 202 for (var i = 0; i < 100; ++i) { |
| 203 var index = Math.floor(i / 50); |
| 204 var key = keys[index]; |
| 205 var expected = arr[index]; |
| 206 var actual = str[key]; |
| 207 assertEquals(expected, actual); |
| 208 } |
| 209 |
| 210 // Test out of range case. |
| 211 var keys = [0, -1]; |
| 212 var str = 'ab', arr = ['a', undefined]; |
| 213 for (var i = 0; i < 100; ++i) { |
| 214 var index = Math.floor(i / 50); |
| 215 var key = keys[index]; |
| 216 var expected = arr[index]; |
| 217 var actual = str[key]; |
| 218 assertEquals(expected, actual); |
| 219 } |
| 220 |
| 221 var keys = [0, 10]; |
| 222 var str = 'ab', arr = ['a', undefined]; |
| 223 for (var i = 0; i < 100; ++i) { |
| 224 var index = Math.floor(i / 50); |
| 225 var key = keys[index]; |
| 226 var expected = arr[index]; |
| 227 var actual = str[key]; |
| 228 assertEquals(expected, actual); |
| 229 } |
OLD | NEW |