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 512 matching lines...) Loading... |
523 // and .apply. Should fail. | 523 // and .apply. Should fail. |
524 | 524 |
525 assertThrows(function() { ArrayBuffer(100); }, TypeError); | 525 assertThrows(function() { ArrayBuffer(100); }, TypeError); |
526 assertThrows(function() { Int8Array(b, 5, 77); }, TypeError); | 526 assertThrows(function() { Int8Array(b, 5, 77); }, TypeError); |
527 assertThrows(function() { ArrayBuffer.call(null, 10); }, TypeError); | 527 assertThrows(function() { ArrayBuffer.call(null, 10); }, TypeError); |
528 assertThrows(function() { Uint16Array.call(null, b, 2, 4); }, TypeError); | 528 assertThrows(function() { Uint16Array.call(null, b, 2, 4); }, TypeError); |
529 assertThrows(function() { ArrayBuffer.apply(null, [1000]); }, TypeError); | 529 assertThrows(function() { ArrayBuffer.apply(null, [1000]); }, TypeError); |
530 assertThrows(function() { Float32Array.apply(null, [b, 128, 1]); }, TypeError); | 530 assertThrows(function() { Float32Array.apply(null, [b, 128, 1]); }, TypeError); |
531 | 531 |
532 // Test array.set in different combinations. | 532 // Test array.set in different combinations. |
| 533 var b = new ArrayBuffer(4) |
533 | 534 |
534 function assertArrayPrefix(expected, array) { | 535 function assertArrayPrefix(expected, array) { |
535 for (var i = 0; i < expected.length; ++i) { | 536 for (var i = 0; i < expected.length; ++i) { |
536 assertEquals(expected[i], array[i]); | 537 assertEquals(expected[i], array[i]); |
537 } | 538 } |
538 } | 539 } |
539 | 540 |
540 var a11 = new Int16Array([1, 2, 3, 4, 0, -1]) | 541 var a11 = new Int16Array([1, 2, 3, 4, 0, -1]) |
541 var a12 = new Uint16Array(15) | 542 var a12 = new Uint16Array(15) |
542 a12.set(a11, 3) | 543 a12.set(a11, 3) |
(...skipping 162 matching lines...) Loading... |
705 if (j < e15) { assertEquals(a73[1], j); } else { assertEquals(a73[1], -1); } | 706 if (j < e15) { assertEquals(a73[1], j); } else { assertEquals(a73[1], -1); } |
706 | 707 |
707 if (i < e8) { assertEquals(a74[0], i); } else { assertEquals(a74[0], 0); } | 708 if (i < e8) { assertEquals(a74[0], i); } else { assertEquals(a74[0], 0); } |
708 if (j < e8) { assertEquals(a74[1], j); } else { assertEquals(a74[1], e8-1);
} | 709 if (j < e8) { assertEquals(a74[1], j); } else { assertEquals(a74[1], e8-1);
} |
709 if (i < e7) { assertEquals(a75[0], i); } else { | 710 if (i < e7) { assertEquals(a75[0], i); } else { |
710 assertEquals(a75[0], (i < e8) ? -e7 : 0); } | 711 assertEquals(a75[0], (i < e8) ? -e7 : 0); } |
711 if (j < e7) { assertEquals(a75[1], j); } else { assertEquals(a75[1], -1); } | 712 if (j < e7) { assertEquals(a75[1], j); } else { assertEquals(a75[1], -1); } |
712 } | 713 } |
713 } | 714 } |
714 checkRange(); | 715 checkRange(); |
OLD | NEW |