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

Side by Side Diff: test/mjsunit/harmony/dataview-accessors.js

Issue 74583003: Fix data view accessors to throw execptions on offsets bigger than size_t. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix after a bad merge Created 7 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 | « src/v8conversions.h ('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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 array.reverse(); // restore the array. 107 array.reverse(); // restore the array.
108 } 108 }
109 109
110 function runIntegerTestCases(isTestingGet, array, start, length) { 110 function runIntegerTestCases(isTestingGet, array, start, length) {
111 createDataView(array, 0, true, start, length); 111 createDataView(array, 0, true, start, length);
112 112
113 test(isTestingGet, "Int8", 0, 0); 113 test(isTestingGet, "Int8", 0, 0);
114 test(isTestingGet, "Int8", undefined, 0); 114 test(isTestingGet, "Int8", undefined, 0);
115 test(isTestingGet, "Int8", 8, -128); 115 test(isTestingGet, "Int8", 8, -128);
116 test(isTestingGet, "Int8", 15, -1); 116 test(isTestingGet, "Int8", 15, -1);
117 test(isTestingGet, "Int8", 1e12, undefined);
117 118
118 test(isTestingGet, "Uint8", 0, 0); 119 test(isTestingGet, "Uint8", 0, 0);
119 test(isTestingGet, "Uint8", undefined, 0); 120 test(isTestingGet, "Uint8", undefined, 0);
120 test(isTestingGet, "Uint8", 8, 128); 121 test(isTestingGet, "Uint8", 8, 128);
121 test(isTestingGet, "Uint8", 15, 255); 122 test(isTestingGet, "Uint8", 15, 255);
123 test(isTestingGet, "Uint8", 1e12, undefined);
122 124
123 // Little endian. 125 // Little endian.
124 test(isTestingGet, "Int16", 0, 256, true); 126 test(isTestingGet, "Int16", 0, 256, true);
125 test(isTestingGet, "Int16", undefined, 256, true); 127 test(isTestingGet, "Int16", undefined, 256, true);
126 test(isTestingGet, "Int16", 5, 26213, true); 128 test(isTestingGet, "Int16", 5, 26213, true);
127 test(isTestingGet, "Int16", 9, -32127, true); 129 test(isTestingGet, "Int16", 9, -32127, true);
128 test(isTestingGet, "Int16", 14, -2, true); 130 test(isTestingGet, "Int16", 14, -2, true);
131 test(isTestingGet, "Int16", 1e12, undefined, true);
129 132
130 // Big endian. 133 // Big endian.
131 test(isTestingGet, "Int16", 0, 1); 134 test(isTestingGet, "Int16", 0, 1);
132 test(isTestingGet, "Int16", undefined, 1); 135 test(isTestingGet, "Int16", undefined, 1);
133 test(isTestingGet, "Int16", 5, 25958); 136 test(isTestingGet, "Int16", 5, 25958);
134 test(isTestingGet, "Int16", 9, -32382); 137 test(isTestingGet, "Int16", 9, -32382);
135 test(isTestingGet, "Int16", 14, -257); 138 test(isTestingGet, "Int16", 14, -257);
139 test(isTestingGet, "Int16", 1e12, undefined);
136 140
137 // Little endian. 141 // Little endian.
138 test(isTestingGet, "Uint16", 0, 256, true); 142 test(isTestingGet, "Uint16", 0, 256, true);
139 test(isTestingGet, "Uint16", undefined, 256, true); 143 test(isTestingGet, "Uint16", undefined, 256, true);
140 test(isTestingGet, "Uint16", 5, 26213, true); 144 test(isTestingGet, "Uint16", 5, 26213, true);
141 test(isTestingGet, "Uint16", 9, 33409, true); 145 test(isTestingGet, "Uint16", 9, 33409, true);
142 test(isTestingGet, "Uint16", 14, 65534, true); 146 test(isTestingGet, "Uint16", 14, 65534, true);
147 test(isTestingGet, "Uint16", 1e12, undefined, true);
143 148
144 // Big endian. 149 // Big endian.
145 test(isTestingGet, "Uint16", 0, 1); 150 test(isTestingGet, "Uint16", 0, 1);
146 test(isTestingGet, "Uint16", undefined, 1); 151 test(isTestingGet, "Uint16", undefined, 1);
147 test(isTestingGet, "Uint16", 5, 25958); 152 test(isTestingGet, "Uint16", 5, 25958);
148 test(isTestingGet, "Uint16", 9, 33154); 153 test(isTestingGet, "Uint16", 9, 33154);
149 test(isTestingGet, "Uint16", 14, 65279); 154 test(isTestingGet, "Uint16", 14, 65279);
155 test(isTestingGet, "Uint16", 1e12, undefined);
150 156
151 // Little endian. 157 // Little endian.
152 test(isTestingGet, "Int32", 0, 50462976, true); 158 test(isTestingGet, "Int32", 0, 50462976, true);
153 test(isTestingGet, "Int32", undefined, 50462976, true); 159 test(isTestingGet, "Int32", undefined, 50462976, true);
154 test(isTestingGet, "Int32", 3, 1717920771, true); 160 test(isTestingGet, "Int32", 3, 1717920771, true);
155 test(isTestingGet, "Int32", 6, -2122291354, true); 161 test(isTestingGet, "Int32", 6, -2122291354, true);
156 test(isTestingGet, "Int32", 9, -58490239, true); 162 test(isTestingGet, "Int32", 9, -58490239, true);
157 test(isTestingGet, "Int32", 12,-66052, true); 163 test(isTestingGet, "Int32", 12,-66052, true);
164 test(isTestingGet, "Int32", 1e12, undefined, true);
158 165
159 // Big endian. 166 // Big endian.
160 test(isTestingGet, "Int32", 0, 66051); 167 test(isTestingGet, "Int32", 0, 66051);
161 test(isTestingGet, "Int32", undefined, 66051); 168 test(isTestingGet, "Int32", undefined, 66051);
162 test(isTestingGet, "Int32", 3, 56911206); 169 test(isTestingGet, "Int32", 3, 56911206);
163 test(isTestingGet, "Int32", 6, 1718059137); 170 test(isTestingGet, "Int32", 6, 1718059137);
164 test(isTestingGet, "Int32", 9, -2122152964); 171 test(isTestingGet, "Int32", 9, -2122152964);
165 test(isTestingGet, "Int32", 12, -50462977); 172 test(isTestingGet, "Int32", 12, -50462977);
173 test(isTestingGet, "Int32", 1e12, undefined);
166 174
167 // Little endian. 175 // Little endian.
168 test(isTestingGet, "Uint32", 0, 50462976, true); 176 test(isTestingGet, "Uint32", 0, 50462976, true);
169 test(isTestingGet, "Uint32", undefined, 50462976, true); 177 test(isTestingGet, "Uint32", undefined, 50462976, true);
170 test(isTestingGet, "Uint32", 3, 1717920771, true); 178 test(isTestingGet, "Uint32", 3, 1717920771, true);
171 test(isTestingGet, "Uint32", 6, 2172675942, true); 179 test(isTestingGet, "Uint32", 6, 2172675942, true);
172 test(isTestingGet, "Uint32", 9, 4236477057, true); 180 test(isTestingGet, "Uint32", 9, 4236477057, true);
173 test(isTestingGet, "Uint32", 12,4294901244, true); 181 test(isTestingGet, "Uint32", 12,4294901244, true);
182 test(isTestingGet, "Uint32", 1e12, undefined, true);
174 183
175 // Big endian. 184 // Big endian.
176 test(isTestingGet, "Uint32", 0, 66051); 185 test(isTestingGet, "Uint32", 0, 66051);
177 test(isTestingGet, "Uint32", undefined, 66051); 186 test(isTestingGet, "Uint32", undefined, 66051);
178 test(isTestingGet, "Uint32", 3, 56911206); 187 test(isTestingGet, "Uint32", 3, 56911206);
179 test(isTestingGet, "Uint32", 6, 1718059137); 188 test(isTestingGet, "Uint32", 6, 1718059137);
180 test(isTestingGet, "Uint32", 9, 2172814332); 189 test(isTestingGet, "Uint32", 9, 2172814332);
181 test(isTestingGet, "Uint32", 12, 4244504319); 190 test(isTestingGet, "Uint32", 12, 4244504319);
191 test(isTestingGet, "Uint32", 1e12, undefined);
182 } 192 }
183 193
184 function testFloat(isTestingGet, func, array, start, expected) { 194 function testFloat(isTestingGet, func, array, start, expected) {
185 // Little endian. 195 // Little endian.
186 createDataView(array, 0, true, start); 196 createDataView(array, 0, true, start);
187 test(isTestingGet, func, 0, expected, true); 197 test(isTestingGet, func, 0, expected, true);
188 test(isTestingGet, func, undefined, expected, true); 198 test(isTestingGet, func, undefined, expected, true);
189 createDataView(array, 3, true, start); 199 createDataView(array, 3, true, start);
190 test(isTestingGet, func, 3, expected, true); 200 test(isTestingGet, func, 3, expected, true);
191 createDataView(array, 7, true, start); 201 createDataView(array, 7, true, start);
192 test(isTestingGet, func, 7, expected, true); 202 test(isTestingGet, func, 7, expected, true);
193 createDataView(array, 10, true, start); 203 createDataView(array, 10, true, start);
194 test(isTestingGet, func, 10, expected, true); 204 test(isTestingGet, func, 10, expected, true);
205 test(isTestingGet, func, 1e12, undefined, true);
195 206
196 // Big endian. 207 // Big endian.
197 createDataView(array, 0, false); 208 createDataView(array, 0, false);
198 test(isTestingGet, func, 0, expected, false); 209 test(isTestingGet, func, 0, expected, false);
199 test(isTestingGet, func, undefined, expected, false); 210 test(isTestingGet, func, undefined, expected, false);
200 createDataView(array, 3, false); 211 createDataView(array, 3, false);
201 test(isTestingGet, func, 3, expected, false); 212 test(isTestingGet, func, 3, expected, false);
202 createDataView(array, 7, false); 213 createDataView(array, 7, false);
203 test(isTestingGet, func, 7, expected, false); 214 test(isTestingGet, func, 7, expected, false);
204 createDataView(array, 10, false); 215 createDataView(array, 10, false);
205 test(isTestingGet, func, 10, expected, false); 216 test(isTestingGet, func, 10, expected, false);
217 test(isTestingGet, func, 1e12, undefined, false);
206 } 218 }
207 219
208 function runFloatTestCases(isTestingGet, start) { 220 function runFloatTestCases(isTestingGet, start) {
209 testFloat(isTestingGet, "Float32", 221 testFloat(isTestingGet, "Float32",
210 isTestingGet ? [0, 0, 32, 65] : initialArray, start, 10); 222 isTestingGet ? [0, 0, 32, 65] : initialArray, start, 10);
211 223
212 testFloat(isTestingGet, "Float32", 224 testFloat(isTestingGet, "Float32",
213 isTestingGet ? [164, 112, 157, 63] : initialArray, 225 isTestingGet ? [164, 112, 157, 63] : initialArray,
214 start, 1.2300000190734863); 226 start, 1.2300000190734863);
215 testFloat(isTestingGet, "Float32", 227 testFloat(isTestingGet, "Float32",
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 assertThrows(function() { a.setInt8(1) }, TypeError); 452 assertThrows(function() { a.setInt8(1) }, TypeError);
441 assertThrows(function() { a.setUint16(1) }, TypeError); 453 assertThrows(function() { a.setUint16(1) }, TypeError);
442 assertThrows(function() { a.setInt16(1) }, TypeError); 454 assertThrows(function() { a.setInt16(1) }, TypeError);
443 assertThrows(function() { a.setUint32(1) }, TypeError); 455 assertThrows(function() { a.setUint32(1) }, TypeError);
444 assertThrows(function() { a.setInt32(1) }, TypeError); 456 assertThrows(function() { a.setInt32(1) }, TypeError);
445 assertThrows(function() { a.setFloat32(1) }, TypeError); 457 assertThrows(function() { a.setFloat32(1) }, TypeError);
446 assertThrows(function() { a.setFloat64(1) }, TypeError); 458 assertThrows(function() { a.setFloat64(1) }, TypeError);
447 } 459 }
448 460
449 TestInsufficientArguments(); 461 TestInsufficientArguments();
OLDNEW
« no previous file with comments | « src/v8conversions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698