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

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

Issue 1541233002: Use ES2015-style TypedArray prototype chain (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test of prototype property descriptor Created 4 years, 12 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 assertSame(abLen0, aOverAbLen0.buffer); 197 assertSame(abLen0, aOverAbLen0.buffer);
198 assertSame(elementSize, aOverAbLen0.BYTES_PER_ELEMENT); 198 assertSame(elementSize, aOverAbLen0.BYTES_PER_ELEMENT);
199 assertSame(0, aOverAbLen0.length); 199 assertSame(0, aOverAbLen0.length);
200 assertSame(0, aOverAbLen0.byteLength); 200 assertSame(0, aOverAbLen0.byteLength);
201 assertSame(0, aOverAbLen0.byteOffset); 201 assertSame(0, aOverAbLen0.byteOffset);
202 202
203 var a = new constr(sab, 64*elementSize, 128); 203 var a = new constr(sab, 64*elementSize, 128);
204 assertEquals("[object " + constr.name + "]", 204 assertEquals("[object " + constr.name + "]",
205 Object.prototype.toString.call(a)); 205 Object.prototype.toString.call(a));
206 var desc = Object.getOwnPropertyDescriptor( 206 var desc = Object.getOwnPropertyDescriptor(
207 constr.prototype, Symbol.toStringTag); 207 constr.prototype.__proto__, Symbol.toStringTag);
208 assertTrue(desc.configurable); 208 assertTrue(desc.configurable);
209 assertFalse(desc.enumerable); 209 assertFalse(desc.enumerable);
210 assertFalse(!!desc.writable); 210 assertFalse(!!desc.writable);
211 assertFalse(!!desc.set); 211 assertFalse(!!desc.set);
212 assertEquals("function", typeof desc.get); 212 assertEquals("function", typeof desc.get);
213 } 213 }
214 214
215 TestTypedArray(Uint8Array, 1, 0xFF); 215 TestTypedArray(Uint8Array, 1, 0xFF);
216 TestTypedArray(Int8Array, 1, -0x7F); 216 TestTypedArray(Int8Array, 1, -0x7F);
217 TestTypedArray(Uint16Array, 2, 0xFFFF); 217 TestTypedArray(Uint16Array, 2, 0xFFFF);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 Uint16Array, 303 Uint16Array,
304 Int16Array, 304 Int16Array,
305 Uint32Array, 305 Uint32Array,
306 Int32Array, 306 Int32Array,
307 Uint8ClampedArray, 307 Uint8ClampedArray,
308 Float32Array, 308 Float32Array,
309 Float64Array]; 309 Float64Array];
310 310
311 function TestPropertyTypeChecks(constructor) { 311 function TestPropertyTypeChecks(constructor) {
312 function CheckProperty(name) { 312 function CheckProperty(name) {
313 var d = Object.getOwnPropertyDescriptor(constructor.prototype, name); 313 var d = Object.getOwnPropertyDescriptor(constructor.prototype.__proto__,
314 name);
314 var o = {}; 315 var o = {};
315 assertThrows(function() {d.get.call(o);}, TypeError); 316 assertThrows(function() {d.get.call(o);}, TypeError);
316 for (var i = 0; i < typedArrayConstructors.length; i++) { 317 for (var i = 0; i < typedArrayConstructors.length; i++) {
317 var ctor = typedArrayConstructors[i]; 318 var ctor = typedArrayConstructors[i];
318 var a = MakeSharedTypedArray(ctor, 10); 319 var a = MakeSharedTypedArray(ctor, 10);
319 if (ctor === constructor) { 320 d.get.call(a); // shouldn't throw
320 d.get.call(a); // shouldn't throw
321 } else {
322 assertThrows(function() {d.get.call(a);}, TypeError);
323 }
324 } 321 }
325 } 322 }
326 323
327 CheckProperty("buffer"); 324 CheckProperty("buffer");
328 CheckProperty("byteOffset"); 325 CheckProperty("byteOffset");
329 CheckProperty("byteLength"); 326 CheckProperty("byteLength");
330 CheckProperty("length"); 327 CheckProperty("length");
331 } 328 }
332 329
333 for(i = 0; i < typedArrayConstructors.length; i++) { 330 for(i = 0; i < typedArrayConstructors.length; i++) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 for(i = 0; i < typedArrayConstructors.length; i++) { 565 for(i = 0; i < typedArrayConstructors.length; i++) {
569 TestArbitrary(MakeSharedTypedArray(typedArrayConstructors[i], 10)); 566 TestArbitrary(MakeSharedTypedArray(typedArrayConstructors[i], 10));
570 } 567 }
571 568
572 // Test direct constructor call 569 // Test direct constructor call
573 assertThrows(function() { SharedArrayBuffer(); }, TypeError); 570 assertThrows(function() { SharedArrayBuffer(); }, TypeError);
574 for(i = 0; i < typedArrayConstructors.length; i++) { 571 for(i = 0; i < typedArrayConstructors.length; i++) {
575 assertThrows(function(i) { typedArrayConstructors[i](); }.bind(this, i), 572 assertThrows(function(i) { typedArrayConstructors[i](); }.bind(this, i),
576 TypeError); 573 TypeError);
577 } 574 }
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/reflect-get-prototype-of.js ('k') | test/mjsunit/regress/regress-typedarray-length.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698