| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 TestArrayBufferSlice(); | 116 TestArrayBufferSlice(); |
| 117 | 117 |
| 118 // Typed arrays | 118 // Typed arrays |
| 119 | 119 |
| 120 function TestTypedArray(constr, elementSize, typicalElement) { | 120 function TestTypedArray(constr, elementSize, typicalElement) { |
| 121 assertSame(elementSize, constr.BYTES_PER_ELEMENT); | 121 assertSame(elementSize, constr.BYTES_PER_ELEMENT); |
| 122 | 122 |
| 123 var ab = new ArrayBuffer(256*elementSize); | 123 var ab = new ArrayBuffer(256*elementSize); |
| 124 | 124 |
| 125 var a0 = new constr(30); | 125 var a0 = new constr(30); |
| 126 assertTrue(ArrayBuffer.isView(a0)); |
| 126 assertSame(elementSize, a0.BYTES_PER_ELEMENT); | 127 assertSame(elementSize, a0.BYTES_PER_ELEMENT); |
| 127 assertSame(30, a0.length); | 128 assertSame(30, a0.length); |
| 128 assertSame(30*elementSize, a0.byteLength); | 129 assertSame(30*elementSize, a0.byteLength); |
| 129 assertSame(0, a0.byteOffset); | 130 assertSame(0, a0.byteOffset); |
| 130 assertSame(30*elementSize, a0.buffer.byteLength); | 131 assertSame(30*elementSize, a0.buffer.byteLength); |
| 131 | 132 |
| 132 var aLen0 = new constr(0); | 133 var aLen0 = new constr(0); |
| 133 assertSame(elementSize, aLen0.BYTES_PER_ELEMENT); | 134 assertSame(elementSize, aLen0.BYTES_PER_ELEMENT); |
| 134 assertSame(0, aLen0.length); | 135 assertSame(0, aLen0.length); |
| 135 assertSame(0, aLen0.byteLength); | 136 assertSame(0, aLen0.byteLength); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 assertThrows(function() { a.set(0, 1); }, TypeError); | 470 assertThrows(function() { a.set(0, 1); }, TypeError); |
| 470 } | 471 } |
| 471 | 472 |
| 472 TestTypedArraySet(); | 473 TestTypedArraySet(); |
| 473 | 474 |
| 474 // DataView | 475 // DataView |
| 475 function TestDataViewConstructor() { | 476 function TestDataViewConstructor() { |
| 476 var ab = new ArrayBuffer(256); | 477 var ab = new ArrayBuffer(256); |
| 477 | 478 |
| 478 var d1 = new DataView(ab, 1, 255); | 479 var d1 = new DataView(ab, 1, 255); |
| 480 assertTrue(ArrayBuffer.isView(d1)); |
| 479 assertSame(ab, d1.buffer); | 481 assertSame(ab, d1.buffer); |
| 480 assertSame(1, d1.byteOffset); | 482 assertSame(1, d1.byteOffset); |
| 481 assertSame(255, d1.byteLength); | 483 assertSame(255, d1.byteLength); |
| 482 | 484 |
| 483 var d2 = new DataView(ab, 2); | 485 var d2 = new DataView(ab, 2); |
| 484 assertSame(ab, d2.buffer); | 486 assertSame(ab, d2.buffer); |
| 485 assertSame(2, d2.byteOffset); | 487 assertSame(2, d2.byteOffset); |
| 486 assertSame(254, d2.byteLength); | 488 assertSame(254, d2.byteLength); |
| 487 | 489 |
| 488 var d3 = new DataView(ab); | 490 var d3 = new DataView(ab); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 TestArbitrary(new ArrayBuffer(256)); | 575 TestArbitrary(new ArrayBuffer(256)); |
| 574 for(i = 0; i < typedArrayConstructors.lenght; i++) { | 576 for(i = 0; i < typedArrayConstructors.lenght; i++) { |
| 575 TestArbitary(new typedArrayConstructors[i](10)); | 577 TestArbitary(new typedArrayConstructors[i](10)); |
| 576 } | 578 } |
| 577 TestArbitrary(new DataView(new ArrayBuffer(256))); | 579 TestArbitrary(new DataView(new ArrayBuffer(256))); |
| 578 | 580 |
| 579 | 581 |
| 580 // Test direct constructor call | 582 // Test direct constructor call |
| 581 assertThrows(function() { ArrayBuffer(); }, TypeError); | 583 assertThrows(function() { ArrayBuffer(); }, TypeError); |
| 582 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError); | 584 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError); |
| OLD | NEW |