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

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

Issue 546803003: Update ObjectToString to Harmony-draft algorithm (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add @@toStringTag to some objects + tests 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
« test/mjsunit/es6/promises.js ('K') | « test/mjsunit/es6/promises.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 assertThrows(function() { new ArrayBuffer(-2.567); }, RangeError); 45 assertThrows(function() { new ArrayBuffer(-2.567); }, RangeError);
46 46
47 /* TODO[dslomov]: Reenable the test 47 /* TODO[dslomov]: Reenable the test
48 assertThrows(function() { 48 assertThrows(function() {
49 var ab1 = new ArrayBuffer(0xFFFFFFFFFFFF) 49 var ab1 = new ArrayBuffer(0xFFFFFFFFFFFF)
50 }, RangeError); 50 }, RangeError);
51 */ 51 */
52 52
53 var ab = new ArrayBuffer(); 53 var ab = new ArrayBuffer();
54 assertSame(0, ab.byteLength); 54 assertSame(0, ab.byteLength);
55 assertEquals("[object ArrayBuffer]",
56 Object.prototype.toString.call(ab));
55 } 57 }
56 58
57 TestArrayBufferCreation(); 59 TestArrayBufferCreation();
58 60
59 function TestByteLengthNotWritable() { 61 function TestByteLengthNotWritable() {
60 var ab = new ArrayBuffer(1024); 62 var ab = new ArrayBuffer(1024);
61 assertSame(1024, ab.byteLength); 63 assertSame(1024, ab.byteLength);
62 64
63 assertThrows(function() { "use strict"; ab.byteLength = 42; }, TypeError); 65 assertThrows(function() { "use strict"; ab.byteLength = 42; }, TypeError);
64 } 66 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 TestArrayBufferSlice(); 118 TestArrayBufferSlice();
117 119
118 // Typed arrays 120 // Typed arrays
119 121
120 function TestTypedArray(constr, elementSize, typicalElement) { 122 function TestTypedArray(constr, elementSize, typicalElement) {
121 assertSame(elementSize, constr.BYTES_PER_ELEMENT); 123 assertSame(elementSize, constr.BYTES_PER_ELEMENT);
122 124
123 var ab = new ArrayBuffer(256*elementSize); 125 var ab = new ArrayBuffer(256*elementSize);
124 126
125 var a0 = new constr(30); 127 var a0 = new constr(30);
128 assertEquals("[object " + constr.name + "]",
129 Object.prototype.toString.call(a0));
130
126 assertTrue(ArrayBuffer.isView(a0)); 131 assertTrue(ArrayBuffer.isView(a0));
127 assertSame(elementSize, a0.BYTES_PER_ELEMENT); 132 assertSame(elementSize, a0.BYTES_PER_ELEMENT);
128 assertSame(30, a0.length); 133 assertSame(30, a0.length);
129 assertSame(30*elementSize, a0.byteLength); 134 assertSame(30*elementSize, a0.byteLength);
130 assertSame(0, a0.byteOffset); 135 assertSame(0, a0.byteOffset);
131 assertSame(30*elementSize, a0.buffer.byteLength); 136 assertSame(30*elementSize, a0.buffer.byteLength);
132 137
133 var aLen0 = new constr(0); 138 var aLen0 = new constr(0);
134 assertSame(elementSize, aLen0.BYTES_PER_ELEMENT); 139 assertSame(elementSize, aLen0.BYTES_PER_ELEMENT);
135 assertSame(0, aLen0.length); 140 assertSame(0, aLen0.length);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 TestArbitrary(new ArrayBuffer(256)); 585 TestArbitrary(new ArrayBuffer(256));
581 for(i = 0; i < typedArrayConstructors.lenght; i++) { 586 for(i = 0; i < typedArrayConstructors.lenght; i++) {
582 TestArbitary(new typedArrayConstructors[i](10)); 587 TestArbitary(new typedArrayConstructors[i](10));
583 } 588 }
584 TestArbitrary(new DataView(new ArrayBuffer(256))); 589 TestArbitrary(new DataView(new ArrayBuffer(256)));
585 590
586 591
587 // Test direct constructor call 592 // Test direct constructor call
588 assertThrows(function() { ArrayBuffer(); }, TypeError); 593 assertThrows(function() { ArrayBuffer(); }, TypeError);
589 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError); 594 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError);
OLDNEW
« test/mjsunit/es6/promises.js ('K') | « test/mjsunit/es6/promises.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698