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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 var aNoParam = new constr(); | 263 var aNoParam = new constr(); |
264 assertSame(elementSize, aNoParam.BYTES_PER_ELEMENT); | 264 assertSame(elementSize, aNoParam.BYTES_PER_ELEMENT); |
265 assertSame(0, aNoParam.length); | 265 assertSame(0, aNoParam.length); |
266 assertSame(0, aNoParam.byteLength); | 266 assertSame(0, aNoParam.byteLength); |
267 assertSame(0, aNoParam.byteOffset); | 267 assertSame(0, aNoParam.byteOffset); |
268 | 268 |
269 var a = new constr(ab, 64*elementSize, 128); | 269 var a = new constr(ab, 64*elementSize, 128); |
270 assertEquals("[object " + constr.name + "]", | 270 assertEquals("[object " + constr.name + "]", |
271 Object.prototype.toString.call(a)); | 271 Object.prototype.toString.call(a)); |
272 var desc = Object.getOwnPropertyDescriptor( | 272 var desc = Object.getOwnPropertyDescriptor( |
273 constr.prototype, Symbol.toStringTag); | 273 constr.prototype.__proto__, Symbol.toStringTag); |
274 assertTrue(desc.configurable); | 274 assertTrue(desc.configurable); |
275 assertFalse(desc.enumerable); | 275 assertFalse(desc.enumerable); |
276 assertFalse(!!desc.writable); | 276 assertFalse(!!desc.writable); |
277 assertFalse(!!desc.set); | 277 assertFalse(!!desc.set); |
278 assertEquals("function", typeof desc.get); | 278 assertEquals("function", typeof desc.get); |
279 | 279 |
280 // Test that the constructor can be called with an iterable | 280 // Test that the constructor can be called with an iterable |
281 function* gen() { for (var i = 0; i < 10; i++) yield i; } | 281 function* gen() { for (var i = 0; i < 10; i++) yield i; } |
282 var genArr = new constr(gen()); | 282 var genArr = new constr(gen()); |
283 assertEquals(10, genArr.length); | 283 assertEquals(10, genArr.length); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 Int16Array, | 411 Int16Array, |
412 Uint32Array, | 412 Uint32Array, |
413 Int32Array, | 413 Int32Array, |
414 Uint8ClampedArray, | 414 Uint8ClampedArray, |
415 Float32Array, | 415 Float32Array, |
416 Float64Array]; | 416 Float64Array]; |
417 | 417 |
418 function TestPropertyTypeChecks(constructor) { | 418 function TestPropertyTypeChecks(constructor) { |
419 function CheckProperty(name) { | 419 function CheckProperty(name) { |
420 assertThrows(function() { 'use strict'; new constructor(10)[name] = 0; }) | 420 assertThrows(function() { 'use strict'; new constructor(10)[name] = 0; }) |
421 var d = Object.getOwnPropertyDescriptor(constructor.prototype, name); | 421 var d = Object.getOwnPropertyDescriptor(constructor.prototype.__proto__, nam
e); |
422 var o = {}; | 422 var o = {}; |
423 assertThrows(function() {d.get.call(o);}, TypeError); | 423 assertThrows(function() {d.get.call(o);}, TypeError); |
424 for (var i = 0; i < typedArrayConstructors.length; i++) { | 424 for (var i = 0; i < typedArrayConstructors.length; i++) { |
425 var ctor = typedArrayConstructors[i]; | 425 var ctor = typedArrayConstructors[i]; |
426 var a = new ctor(10); | 426 var a = new ctor(10); |
427 if (ctor === constructor) { | 427 d.get.call(a); // shouldn't throw |
428 d.get.call(a); // shouldn't throw | |
429 } else { | |
430 assertThrows(function() {d.get.call(a);}, TypeError); | |
431 } | |
432 } | 428 } |
433 } | 429 } |
434 | 430 |
435 CheckProperty("buffer"); | 431 CheckProperty("buffer"); |
436 CheckProperty("byteOffset"); | 432 CheckProperty("byteOffset"); |
437 CheckProperty("byteLength"); | 433 CheckProperty("byteLength"); |
438 CheckProperty("length"); | 434 CheckProperty("length"); |
439 } | 435 } |
440 | 436 |
441 for(i = 0; i < typedArrayConstructors.length; i++) { | 437 for(i = 0; i < typedArrayConstructors.length; i++) { |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 755 |
760 function TestNonConfigurableProperties(constructor) { | 756 function TestNonConfigurableProperties(constructor) { |
761 var arr = new constructor([100]) | 757 var arr = new constructor([100]) |
762 assertFalse(Object.getOwnPropertyDescriptor(arr,"0").configurable) | 758 assertFalse(Object.getOwnPropertyDescriptor(arr,"0").configurable) |
763 assertFalse(delete arr[0]) | 759 assertFalse(delete arr[0]) |
764 } | 760 } |
765 | 761 |
766 for(i = 0; i < typedArrayConstructors.length; i++) { | 762 for(i = 0; i < typedArrayConstructors.length; i++) { |
767 TestNonConfigurableProperties(typedArrayConstructors[i]); | 763 TestNonConfigurableProperties(typedArrayConstructors[i]); |
768 } | 764 } |
OLD | NEW |