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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 assertEquals(1, a[0]); | 468 assertEquals(1, a[0]); |
469 assertEquals(3, a[2]); | 469 assertEquals(3, a[2]); |
470 a = new Uint32Array(a); | 470 a = new Uint32Array(a); |
471 assertInstance(a, Uint32Array); | 471 assertInstance(a, Uint32Array); |
472 assertEquals(3, a.length); | 472 assertEquals(3, a.length); |
473 assertEquals(12, a.byteLength); | 473 assertEquals(12, a.byteLength); |
474 assertEquals(12, a.buffer.byteLength); | 474 assertEquals(12, a.buffer.byteLength); |
475 assertEquals(4, a.BYTES_PER_ELEMENT); | 475 assertEquals(4, a.BYTES_PER_ELEMENT); |
476 assertEquals(1, a[0]); | 476 assertEquals(1, a[0]); |
477 assertEquals(3, a[2]); | 477 assertEquals(3, a[2]); |
478 | 478 assertTrue(a.buffer instanceof ArrayBuffer); |
479 assertEquals(ArrayBuffer, a.buffer.constructor); | |
rossberg
2012/06/29 11:29:44
You can use the assertInstance helper that is defi
Yang
2012/06/29 15:06:05
Done.
| |
479 | 480 |
480 // Check subarrays. | 481 // Check subarrays. |
481 a = new Uint16Array([1,2,3,4,5,6]); | 482 a = new Uint16Array([1,2,3,4,5,6]); |
482 aa = a.subarray(3); | 483 aa = a.subarray(3); |
483 assertInstance(aa, Uint16Array); | 484 assertInstance(aa, Uint16Array); |
484 assertEquals(3, aa.length); | 485 assertEquals(3, aa.length); |
485 assertEquals(6, aa.byteLength); | 486 assertEquals(6, aa.byteLength); |
486 assertEquals(2, aa.BYTES_PER_ELEMENT); | 487 assertEquals(2, aa.BYTES_PER_ELEMENT); |
487 assertSame(a.buffer, aa.buffer); | 488 assertSame(a.buffer, aa.buffer); |
488 aa = a.subarray(3,5); | 489 aa = a.subarray(3,5); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 aa = a.subarray(0,-8); | 531 aa = a.subarray(0,-8); |
531 assertInstance(aa, Uint16Array); | 532 assertInstance(aa, Uint16Array); |
532 assertEquals(0, aa.length); | 533 assertEquals(0, aa.length); |
533 assertEquals(0, aa.byteLength); | 534 assertEquals(0, aa.byteLength); |
534 assertEquals(2, aa.BYTES_PER_ELEMENT); | 535 assertEquals(2, aa.BYTES_PER_ELEMENT); |
535 assertSame(a.buffer, aa.buffer); | 536 assertSame(a.buffer, aa.buffer); |
536 | 537 |
537 assertThrows(function(){ a.subarray.call({}, 0) }); | 538 assertThrows(function(){ a.subarray.call({}, 0) }); |
538 assertThrows(function(){ a.subarray.call([], 0) }); | 539 assertThrows(function(){ a.subarray.call([], 0) }); |
539 assertThrows(function(){ a.subarray.call(a) }); | 540 assertThrows(function(){ a.subarray.call(a) }); |
541 | |
542 var a = new Int32Array(10) | |
543 var b = a.buffer | |
544 print(b instanceof ArrayBuffer) | |
545 print(b.constructor) | |
rossberg
2012/06/29 11:29:44
This probably fits better with the tests following
rossberg
2012/06/29 14:14:50
Please don't just delete this test, but have it in
Yang
2012/06/29 15:06:05
Done.
| |
OLD | NEW |