| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 var poses = [0, 10, 50, 69]; | 67 var poses = [0, 10, 50, 69]; |
| 68 | 68 |
| 69 | 69 |
| 70 // Fuzzing test of reverse on sparse array. | 70 // Fuzzing test of reverse on sparse array. |
| 71 for (var iterations = 0; iterations < 20; iterations++) { | 71 for (var iterations = 0; iterations < 20; iterations++) { |
| 72 for (var size_pos = 0; size_pos < sizes.length; size_pos++) { | 72 for (var size_pos = 0; size_pos < sizes.length; size_pos++) { |
| 73 var size = sizes[size_pos]; | 73 var size = sizes[size_pos]; |
| 74 | 74 |
| 75 var to_delete = []; | 75 var to_delete = []; |
| 76 | 76 |
| 77 var a = new Array(size); | 77 var a; |
| 78 // Make sure we test both array-backed and hash-table backed |
| 79 // arrays. |
| 80 if (size < 1000) { |
| 81 a = new Array(size); |
| 82 } else { |
| 83 a = new Array(); |
| 84 a.length = size; |
| 85 } |
| 78 | 86 |
| 79 var expected = ''; | 87 var expected = ''; |
| 80 var expected_reversed = ''; | 88 var expected_reversed = ''; |
| 81 | 89 |
| 82 for (var pos_pos = 0; pos_pos < poses.length; pos_pos++) { | 90 for (var pos_pos = 0; pos_pos < poses.length; pos_pos++) { |
| 83 var pos = poses[pos_pos]; | 91 var pos = poses[pos_pos]; |
| 84 var letter = String.fromCharCode(97 + pos_pos); | 92 var letter = String.fromCharCode(97 + pos_pos); |
| 85 if (DoOrDont()) { | 93 if (DoOrDont()) { |
| 86 a[pos] = letter; | 94 a[pos] = letter; |
| 87 expected += letter; | 95 expected += letter; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 114 a.reverse(); | 122 a.reverse(); |
| 115 | 123 |
| 116 while (to_delete.length != 0) { | 124 while (to_delete.length != 0) { |
| 117 var pos = to_delete.pop(); | 125 var pos = to_delete.pop(); |
| 118 delete(Array.prototype[pos]); | 126 delete(Array.prototype[pos]); |
| 119 } | 127 } |
| 120 | 128 |
| 121 assertEquals(expected_reversed2 + expected_reversed, a.join(''), 'reverse th
en join' + size); | 129 assertEquals(expected_reversed2 + expected_reversed, a.join(''), 'reverse th
en join' + size); |
| 122 } | 130 } |
| 123 } | 131 } |
| OLD | NEW |