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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 var keys = [0, 10]; | 243 var keys = [0, 10]; |
244 var str = 'ab', arr = ['a', undefined]; | 244 var str = 'ab', arr = ['a', undefined]; |
245 for (var i = 0; i < 100; ++i) { | 245 for (var i = 0; i < 100; ++i) { |
246 var index = Math.floor(i / 50); | 246 var index = Math.floor(i / 50); |
247 var key = keys[index]; | 247 var key = keys[index]; |
248 var expected = arr[index]; | 248 var expected = arr[index]; |
249 var actual = str[key]; | 249 var actual = str[key]; |
250 assertEquals(expected, actual); | 250 assertEquals(expected, actual); |
251 } | 251 } |
252 | 252 |
253 // Test out of range with a heap number case. | |
254 Math.abs(-343.2); | |
255 var keys = [0, Math.abs(2)]; | |
Yang
2015/03/23 14:23:59
You probably should check that this is not a smi v
mvstanton
2015/03/23 15:54:45
Done. And the Math.floor(x) * 0.5 trick seems to w
| |
256 var str = 'ab', arr = ['a', undefined]; | |
257 for (var i = 0; i < 100; ++i) { | |
258 var index = Math.floor(i / 50); | |
259 var key = keys[index]; | |
260 var expected = arr[index]; | |
261 var actual = str[key]; | |
262 assertEquals(expected, actual); | |
263 } | |
264 | |
253 // Test two byte string. | 265 // Test two byte string. |
254 var str = '\u0427', arr = ['\u0427']; | 266 var str = '\u0427', arr = ['\u0427']; |
255 for (var i = 0; i < 50; ++i) { | 267 for (var i = 0; i < 50; ++i) { |
256 var expected = arr[0]; | 268 var expected = arr[0]; |
257 var actual = str[0]; | 269 var actual = str[0]; |
258 assertEquals(expected, actual); | 270 assertEquals(expected, actual); |
259 } | 271 } |
OLD | NEW |