| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 for (i = 0; i < 128; i++) { | 186 for (i = 0; i < 128; i++) { |
| 187 assertSame(0, a4[i]); | 187 assertSame(0, a4[i]); |
| 188 } | 188 } |
| 189 | 189 |
| 190 for (i = 128; i < 256; i++) { | 190 for (i = 128; i < 256; i++) { |
| 191 assertSame(typicalElement, a4[i]); | 191 assertSame(typicalElement, a4[i]); |
| 192 } | 192 } |
| 193 | 193 |
| 194 assertThrows(function () { new proto(ab, 256*elementSize); }, RangeError); | 194 assertThrows(function () { new proto(ab, 256*elementSize); }, RangeError); |
| 195 assertThrows( |
| 196 function () { new proto(ab, 128*elementSize, 192); }, |
| 197 RangeError); |
| 195 | 198 |
| 196 if (elementSize !== 1) { | 199 if (elementSize !== 1) { |
| 197 assertThrows(function() { new proto(ab, 128*elementSize - 1, 10); }, | 200 assertThrows(function() { new proto(ab, 128*elementSize - 1, 10); }, |
| 198 RangeError); | 201 RangeError); |
| 199 var unalignedArrayBuffer = new ArrayBuffer(10*elementSize + 1); | 202 var unalignedArrayBuffer = new ArrayBuffer(10*elementSize + 1); |
| 200 var goodArray = new proto(unalignedArrayBuffer, 0, 10); | 203 var goodArray = new proto(unalignedArrayBuffer, 0, 10); |
| 201 assertSame(10, goodArray.length); | 204 assertSame(10, goodArray.length); |
| 202 assertSame(10*elementSize, goodArray.byteLength); | 205 assertSame(10*elementSize, goodArray.byteLength); |
| 203 assertThrows(function() { new proto(unalignedArrayBuffer)}, RangeError); | 206 assertThrows(function() { new proto(unalignedArrayBuffer)}, RangeError); |
| 204 assertThrows(function() { new proto(unalignedArrayBuffer, 5*elementSize)}, | 207 assertThrows(function() { new proto(unalignedArrayBuffer, 5*elementSize)}, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 295 } |
| 293 for (var i = 0; i < 20; i++) { | 296 for (var i = 0; i < 20; i++) { |
| 294 TestProperty(m, i, 'val' + i); | 297 TestProperty(m, i, 'val' + i); |
| 295 TestProperty(m, 'foo' + i, 'bar' + i); | 298 TestProperty(m, 'foo' + i, 'bar' + i); |
| 296 } | 299 } |
| 297 } | 300 } |
| 298 TestArbitrary(new ArrayBuffer(256)); | 301 TestArbitrary(new ArrayBuffer(256)); |
| 299 | 302 |
| 300 // Test direct constructor call | 303 // Test direct constructor call |
| 301 assertTrue(ArrayBuffer() instanceof ArrayBuffer); | 304 assertTrue(ArrayBuffer() instanceof ArrayBuffer); |
| OLD | NEW |