OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 aa = a.subarray(0,-8); | 533 aa = a.subarray(0,-8); |
534 assertInstance(aa, Uint16Array); | 534 assertInstance(aa, Uint16Array); |
535 assertEquals(0, aa.length); | 535 assertEquals(0, aa.length); |
536 assertEquals(0, aa.byteLength); | 536 assertEquals(0, aa.byteLength); |
537 assertEquals(2, aa.BYTES_PER_ELEMENT); | 537 assertEquals(2, aa.BYTES_PER_ELEMENT); |
538 assertSame(a.buffer, aa.buffer); | 538 assertSame(a.buffer, aa.buffer); |
539 | 539 |
540 assertThrows(function(){ a.subarray.call({}, 0) }); | 540 assertThrows(function(){ a.subarray.call({}, 0) }); |
541 assertThrows(function(){ a.subarray.call([], 0) }); | 541 assertThrows(function(){ a.subarray.call([], 0) }); |
542 assertThrows(function(){ a.subarray.call(a) }); | 542 assertThrows(function(){ a.subarray.call(a) }); |
| 543 |
| 544 |
| 545 // Call constructors directly and through .call and .apply |
| 546 |
| 547 b = ArrayBuffer(100) |
| 548 a = Int8Array(b, 5, 77) |
| 549 assertInstance(b, ArrayBuffer) |
| 550 assertInstance(a, Int8Array) |
| 551 assertSame(b, a.buffer) |
| 552 assertEquals(5, a.byteOffset) |
| 553 assertEquals(77, a.byteLength) |
| 554 b = ArrayBuffer.call(null, 10) |
| 555 a = Uint16Array.call(null, b, 2, 4) |
| 556 assertInstance(b, ArrayBuffer) |
| 557 assertInstance(a, Uint16Array) |
| 558 assertSame(b, a.buffer) |
| 559 assertEquals(2, a.byteOffset) |
| 560 assertEquals(8, a.byteLength) |
| 561 b = ArrayBuffer.apply(null, [1000]) |
| 562 a = Float32Array.apply(null, [b, 128, 1]) |
| 563 assertInstance(b, ArrayBuffer) |
| 564 assertInstance(a, Float32Array) |
| 565 assertSame(b, a.buffer) |
| 566 assertEquals(128, a.byteOffset) |
| 567 assertEquals(4, a.byteLength) |
OLD | NEW |