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

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

Issue 652603002: Fix typedarray tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 Int8Array, 354 Int8Array,
355 Uint16Array, 355 Uint16Array,
356 Int16Array, 356 Int16Array,
357 Uint32Array, 357 Uint32Array,
358 Int32Array, 358 Int32Array,
359 Uint8ClampedArray, 359 Uint8ClampedArray,
360 Float32Array, 360 Float32Array,
361 Float64Array]; 361 Float64Array];
362 362
363 function TestPropertyTypeChecks(constructor) { 363 function TestPropertyTypeChecks(constructor) {
364 var a = new constructor();
365 function CheckProperty(name) { 364 function CheckProperty(name) {
366 var d = Object.getOwnPropertyDescriptor(constructor.prototype, name); 365 var d = Object.getOwnPropertyDescriptor(constructor.prototype, name);
367 var o = {} 366 var o = {};
368 assertThrows(function() {d.get.call(o);}, TypeError); 367 assertThrows(function() {d.get.call(o);}, TypeError);
369 d.get.call(a); // shouldn't throw 368 for (var i = 0; i < typedArrayConstructors.length; i++) {
370 for (var i = 0 ; i < typedArrayConstructors.length; i++) { 369 var ctor = typedArrayConstructors[i];
371 d.get.call(new typedArrayConstructors[i](10)); 370 var a = new ctor(10);
371 if (ctor === constructor) {
372 d.get.call(a); // shouldn't throw
373 } else {
374 assertThrows(function() {d.get.call(a);}, TypeError);
375 }
372 } 376 }
373 } 377 }
374 378
375 CheckProperty("buffer"); 379 CheckProperty("buffer");
376 CheckProperty("byteOffset"); 380 CheckProperty("byteOffset");
377 CheckProperty("byteLength"); 381 CheckProperty("byteLength");
378 CheckProperty("length"); 382 CheckProperty("length");
379 } 383 }
380 384
381 for(i = 0; i < typedArrayConstructors.lenght; i++) { 385 for(i = 0; i < typedArrayConstructors.length; i++) {
382 TestPropertyTypeChecks(typedArrayConstructors[i]); 386 TestPropertyTypeChecks(typedArrayConstructors[i]);
383 } 387 }
384 388
385 389
386 function TestTypedArraySet() { 390 function TestTypedArraySet() {
387 // Test array.set in different combinations. 391 // Test array.set in different combinations.
388 392
389 function assertArrayPrefix(expected, array) { 393 function assertArrayPrefix(expected, array) {
390 for (var i = 0; i < expected.length; ++i) { 394 for (var i = 0; i < expected.length; ++i) {
391 assertEquals(expected[i], array[i]); 395 assertEquals(expected[i], array[i]);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 var array = []; 558 var array = [];
555 for (var p in x) array.push(p); 559 for (var p in x) array.push(p);
556 return array.sort(); 560 return array.sort();
557 } 561 }
558 assertArrayEquals([], props(func)); 562 assertArrayEquals([], props(func));
559 assertArrayEquals([], props(func.prototype)); 563 assertArrayEquals([], props(func.prototype));
560 if (obj) 564 if (obj)
561 assertArrayEquals([], props(obj)); 565 assertArrayEquals([], props(obj));
562 } 566 }
563 TestEnumerable(ArrayBuffer, new ArrayBuffer()); 567 TestEnumerable(ArrayBuffer, new ArrayBuffer());
564 for(i = 0; i < typedArrayConstructors.lenght; i++) { 568 for(i = 0; i < typedArrayConstructors.length; i++) {
565 TestEnumerable(typedArrayConstructors[i]); 569 TestEnumerable(typedArrayConstructors[i]);
566 } 570 }
567 TestEnumerable(DataView, new DataView(new ArrayBuffer())); 571 TestEnumerable(DataView, new DataView(new ArrayBuffer()));
568 572
569 // Test arbitrary properties on ArrayBuffer 573 // Test arbitrary properties on ArrayBuffer
570 function TestArbitrary(m) { 574 function TestArbitrary(m) {
571 function TestProperty(map, property, value) { 575 function TestProperty(map, property, value) {
572 map[property] = value; 576 map[property] = value;
573 assertEquals(value, map[property]); 577 assertEquals(value, map[property]);
574 } 578 }
575 for (var i = 0; i < 20; i++) { 579 for (var i = 0; i < 20; i++) {
576 TestProperty(m, i, 'val' + i); 580 TestProperty(m, 'key' + i, 'val' + i);
577 TestProperty(m, 'foo' + i, 'bar' + i); 581 TestProperty(m, 'foo' + i, 'bar' + i);
578 } 582 }
579 } 583 }
580 TestArbitrary(new ArrayBuffer(256)); 584 TestArbitrary(new ArrayBuffer(256));
581 for(i = 0; i < typedArrayConstructors.lenght; i++) { 585 for(i = 0; i < typedArrayConstructors.length; i++) {
582 TestArbitary(new typedArrayConstructors[i](10)); 586 TestArbitrary(new typedArrayConstructors[i](10));
583 } 587 }
584 TestArbitrary(new DataView(new ArrayBuffer(256))); 588 TestArbitrary(new DataView(new ArrayBuffer(256)));
585 589
586 590
587 // Test direct constructor call 591 // Test direct constructor call
588 assertThrows(function() { ArrayBuffer(); }, TypeError); 592 assertThrows(function() { ArrayBuffer(); }, TypeError);
589 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError); 593 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698