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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 TestSlice(10, 100, -10); | 106 TestSlice(10, 100, -10); |
107 } | 107 } |
108 | 108 |
109 TestArrayBufferSlice(); | 109 TestArrayBufferSlice(); |
110 | 110 |
111 // Typed arrays | 111 // Typed arrays |
112 | 112 |
113 function TestTypedArray(proto, elementSize, typicalElement) { | 113 function TestTypedArray(proto, elementSize, typicalElement) { |
114 var ab = new ArrayBuffer(256*elementSize); | 114 var ab = new ArrayBuffer(256*elementSize); |
115 | 115 |
| 116 var a0 = new proto(30); |
| 117 assertSame(elementSize, a0.BYTES_PER_ELEMENT); |
| 118 assertSame(30, a0.length); |
| 119 assertSame(30*elementSize, a0.byteLength); |
| 120 assertSame(0, a0.byteOffset); |
| 121 assertSame(30*elementSize, a0.buffer.byteLength); |
| 122 |
116 var a1 = new proto(ab, 128*elementSize, 128); | 123 var a1 = new proto(ab, 128*elementSize, 128); |
117 assertSame(ab, a1.buffer); | 124 assertSame(ab, a1.buffer); |
118 assertSame(elementSize, a1.BYTES_PER_ELEMENT); | 125 assertSame(elementSize, a1.BYTES_PER_ELEMENT); |
119 assertSame(128, a1.length); | 126 assertSame(128, a1.length); |
120 assertSame(128*elementSize, a1.byteLength); | 127 assertSame(128*elementSize, a1.byteLength); |
121 assertSame(128*elementSize, a1.byteOffset); | 128 assertSame(128*elementSize, a1.byteOffset); |
122 | 129 |
123 | 130 |
124 var a2 = new proto(ab, 64*elementSize, 128); | 131 var a2 = new proto(ab, 64*elementSize, 128); |
125 assertSame(ab, a2.buffer); | 132 assertSame(ab, a2.buffer); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 229 } |
223 for (var i = 0; i < 20; i++) { | 230 for (var i = 0; i < 20; i++) { |
224 TestProperty(m, i, 'val' + i); | 231 TestProperty(m, i, 'val' + i); |
225 TestProperty(m, 'foo' + i, 'bar' + i); | 232 TestProperty(m, 'foo' + i, 'bar' + i); |
226 } | 233 } |
227 } | 234 } |
228 TestArbitrary(new ArrayBuffer(256)); | 235 TestArbitrary(new ArrayBuffer(256)); |
229 | 236 |
230 // Test direct constructor call | 237 // Test direct constructor call |
231 assertTrue(ArrayBuffer() instanceof ArrayBuffer); | 238 assertTrue(ArrayBuffer() instanceof ArrayBuffer); |
OLD | NEW |