Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: test/mjsunit/harmony/typedarrays.js

Issue 14460008: TypedArray(length) constructor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/typedarray.js ('K') | « src/typedarray.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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);
OLDNEW
« src/typedarray.js ('K') | « src/typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698