| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 a.reverse(); | 122 a.reverse(); |
| 123 | 123 |
| 124 while (to_delete.length != 0) { | 124 while (to_delete.length != 0) { |
| 125 var pos = to_delete.pop(); | 125 var pos = to_delete.pop(); |
| 126 delete(Array.prototype[pos]); | 126 delete(Array.prototype[pos]); |
| 127 } | 127 } |
| 128 | 128 |
| 129 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); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 |
| 133 |
| 134 function GetSparseArray() { |
| 135 var a = []; |
| 136 a.length = 2000; |
| 137 a[15] = 'a'; |
| 138 a[30] = 'b'; |
| 139 a[40] = 'c'; |
| 140 a[1959] = 'd'; |
| 141 a[1999] = 'e'; |
| 142 |
| 143 return a; |
| 144 } |
| 145 |
| 146 var tests = [ |
| 147 "a.reverse()", |
| 148 "Array.prototype.reverse.call(a)", |
| 149 "Array.prototype.reverse.apply(a)" |
| 150 ]; |
| 151 |
| 152 for (var i = 0; i < tests; i++) { |
| 153 var a = GetSparseArray(); |
| 154 a[1000] = '1'; |
| 155 Object.defineProperty(a, 1000, {configurable: false}); |
| 156 assertThrows(tests[i], TypeError); |
| 157 } |
| 158 |
| 159 for (var i = 0; i < tests; i++) { |
| 160 var a = GetSparseArray(); |
| 161 Object.defineProperty(a, 0, {writable: false}); |
| 162 assertThrows(tests[i], TypeError); |
| 163 } |
| 164 |
| 165 for (var i = 0; i < tests; i++) { |
| 166 var a = GetSparseArray(); |
| 167 Object.freeze(a); |
| 168 assertThrows(tests[i], TypeError); |
| 169 } |
| 170 |
| 171 for (var i = 0; i < tests; i++) { |
| 172 var a = [1, 2, 3]; |
| 173 Object.defineProperty(a, 0, {writable: false}); |
| 174 } |
| 175 |
| 176 for (var i = 0; i < tests; i++) { |
| 177 var a = [1, 2, , 4]; |
| 178 Object.defineProperty(a, 1, {configurable: false}); |
| 179 assertThrows(tests[i], TypeError); |
| 180 } |
| 181 |
| 182 for (var i = 0; i < tests; i++) { |
| 183 var a = [1, 2, 3]; |
| 184 Object.freeze(a); |
| 185 assertThrows(tests[i], TypeError); |
| 186 } |
| OLD | NEW |