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

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: Rebase, rename ObjectToString Created 6 years, 1 month 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 | « test/mjsunit/es6/symbols.js ('k') | tools/gyp/v8.gyp » ('j') | 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --harmony-tostring
29
28 // ArrayBuffer 30 // ArrayBuffer
29 31
30 function TestByteLength(param, expectedByteLength) { 32 function TestByteLength(param, expectedByteLength) {
31 var ab = new ArrayBuffer(param); 33 var ab = new ArrayBuffer(param);
32 assertSame(expectedByteLength, ab.byteLength); 34 assertSame(expectedByteLength, ab.byteLength);
33 } 35 }
34 36
35 function TestArrayBufferCreation() { 37 function TestArrayBufferCreation() {
36 TestByteLength(1, 1); 38 TestByteLength(1, 1);
37 TestByteLength(256, 256); 39 TestByteLength(256, 256);
38 TestByteLength(2.567, 2); 40 TestByteLength(2.567, 2);
39 41
40 TestByteLength("abc", 0); 42 TestByteLength("abc", 0);
41 43
42 TestByteLength(0, 0); 44 TestByteLength(0, 0);
43 45
44 assertThrows(function() { new ArrayBuffer(-10); }, RangeError); 46 assertThrows(function() { new ArrayBuffer(-10); }, RangeError);
45 assertThrows(function() { new ArrayBuffer(-2.567); }, RangeError); 47 assertThrows(function() { new ArrayBuffer(-2.567); }, RangeError);
46 48
47 /* TODO[dslomov]: Reenable the test 49 /* TODO[dslomov]: Reenable the test
48 assertThrows(function() { 50 assertThrows(function() {
49 var ab1 = new ArrayBuffer(0xFFFFFFFFFFFF) 51 var ab1 = new ArrayBuffer(0xFFFFFFFFFFFF)
50 }, RangeError); 52 }, RangeError);
51 */ 53 */
52 54
53 var ab = new ArrayBuffer(); 55 var ab = new ArrayBuffer();
54 assertSame(0, ab.byteLength); 56 assertSame(0, ab.byteLength);
57 assertEquals("[object ArrayBuffer]",
58 Object.prototype.toString.call(ab));
55 } 59 }
56 60
57 TestArrayBufferCreation(); 61 TestArrayBufferCreation();
58 62
59 function TestByteLengthNotWritable() { 63 function TestByteLengthNotWritable() {
60 var ab = new ArrayBuffer(1024); 64 var ab = new ArrayBuffer(1024);
61 assertSame(1024, ab.byteLength); 65 assertSame(1024, ab.byteLength);
62 66
63 assertThrows(function() { "use strict"; ab.byteLength = 42; }, TypeError); 67 assertThrows(function() { "use strict"; ab.byteLength = 42; }, TypeError);
64 } 68 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 TestArrayBufferSlice(); 120 TestArrayBufferSlice();
117 121
118 // Typed arrays 122 // Typed arrays
119 123
120 function TestTypedArray(constr, elementSize, typicalElement) { 124 function TestTypedArray(constr, elementSize, typicalElement) {
121 assertSame(elementSize, constr.BYTES_PER_ELEMENT); 125 assertSame(elementSize, constr.BYTES_PER_ELEMENT);
122 126
123 var ab = new ArrayBuffer(256*elementSize); 127 var ab = new ArrayBuffer(256*elementSize);
124 128
125 var a0 = new constr(30); 129 var a0 = new constr(30);
130 assertEquals("[object " + constr.name + "]",
131 Object.prototype.toString.call(a0));
132
126 assertTrue(ArrayBuffer.isView(a0)); 133 assertTrue(ArrayBuffer.isView(a0));
127 assertSame(elementSize, a0.BYTES_PER_ELEMENT); 134 assertSame(elementSize, a0.BYTES_PER_ELEMENT);
128 assertSame(30, a0.length); 135 assertSame(30, a0.length);
129 assertSame(30*elementSize, a0.byteLength); 136 assertSame(30*elementSize, a0.byteLength);
130 assertSame(0, a0.byteOffset); 137 assertSame(0, a0.byteOffset);
131 assertSame(30*elementSize, a0.buffer.byteLength); 138 assertSame(30*elementSize, a0.buffer.byteLength);
132 139
133 var aLen0 = new constr(0); 140 var aLen0 = new constr(0);
134 assertSame(elementSize, aLen0.BYTES_PER_ELEMENT); 141 assertSame(elementSize, aLen0.BYTES_PER_ELEMENT);
135 assertSame(0, aLen0.length); 142 assertSame(0, aLen0.length);
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 TestArbitrary(new ArrayBuffer(256)); 688 TestArbitrary(new ArrayBuffer(256));
682 for(i = 0; i < typedArrayConstructors.length; i++) { 689 for(i = 0; i < typedArrayConstructors.length; i++) {
683 TestArbitrary(new typedArrayConstructors[i](10)); 690 TestArbitrary(new typedArrayConstructors[i](10));
684 } 691 }
685 TestArbitrary(new DataView(new ArrayBuffer(256))); 692 TestArbitrary(new DataView(new ArrayBuffer(256)));
686 693
687 694
688 // Test direct constructor call 695 // Test direct constructor call
689 assertThrows(function() { ArrayBuffer(); }, TypeError); 696 assertThrows(function() { ArrayBuffer(); }, TypeError);
690 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError); 697 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/symbols.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698