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...) Expand 10 before | Expand all | Expand 10 after 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) | |
534 | 533 |
535 function assertArrayPrefix(expected, array) { | 534 function assertArrayPrefix(expected, array) { |
536 for (var i = 0; i < expected.length; ++i) { | 535 for (var i = 0; i < expected.length; ++i) { |
537 assertEquals(expected[i], array[i]); | 536 assertEquals(expected[i], array[i]); |
538 } | 537 } |
539 } | 538 } |
540 | 539 |
541 var a11 = new Int16Array([1, 2, 3, 4, 0, -1]) | 540 var a11 = new Int16Array([1, 2, 3, 4, 0, -1]) |
542 var a12 = new Uint16Array(15) | 541 var a12 = new Uint16Array(15) |
543 a12.set(a11, 3) | 542 a12.set(a11, 3) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 if (j < e15) { assertEquals(a73[1], j); } else { assertEquals(a73[1], -1); } | 705 if (j < e15) { assertEquals(a73[1], j); } else { assertEquals(a73[1], -1); } |
707 | 706 |
708 if (i < e8) { assertEquals(a74[0], i); } else { assertEquals(a74[0], 0); } | 707 if (i < e8) { assertEquals(a74[0], i); } else { assertEquals(a74[0], 0); } |
709 if (j < e8) { assertEquals(a74[1], j); } else { assertEquals(a74[1], e8-1);
} | 708 if (j < e8) { assertEquals(a74[1], j); } else { assertEquals(a74[1], e8-1);
} |
710 if (i < e7) { assertEquals(a75[0], i); } else { | 709 if (i < e7) { assertEquals(a75[0], i); } else { |
711 assertEquals(a75[0], (i < e8) ? -e7 : 0); } | 710 assertEquals(a75[0], (i < e8) ? -e7 : 0); } |
712 if (j < e7) { assertEquals(a75[1], j); } else { assertEquals(a75[1], -1); } | 711 if (j < e7) { assertEquals(a75[1], j); } else { assertEquals(a75[1], -1); } |
713 } | 712 } |
714 } | 713 } |
715 checkRange(); | 714 checkRange(); |
OLD | NEW |