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

Side by Side Diff: LayoutTests/fast/canvas/webgl/data-view-test.html

Issue 6469012: Merge 77433 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/648/
Patch Set: Created 9 years, 10 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
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/webgl/data-view-test-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <link rel="stylesheet" href="../../js/resources/js-test-style.css"/> 3 <link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
4 <script src="../../js/resources/js-test-pre.js"></script> 4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <div id="description"></div> 7 <div id="description"></div>
8 <div id="console"></div> 8 <div id="console"></div>
9 9
10 <script> 10 <script>
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 function checkGet(func, index, expected, littleEndian) 42 function checkGet(func, index, expected, littleEndian)
43 { 43 {
44 var expr = "view.get" + func + "(" + index; 44 var expr = "view.get" + func + "(" + index;
45 if (littleEndian != undefined) { 45 if (littleEndian != undefined) {
46 expr += ", "; 46 expr += ", ";
47 expr += littleEndian ? "true" : "false"; 47 expr += littleEndian ? "true" : "false";
48 } 48 }
49 expr += ")"; 49 expr += ")";
50 if (index + getElementSize(func) - 1 < view.byteLength) 50 if (index >= 0 && index + getElementSize(func) - 1 < view.byteLength)
51 shouldBe(expr, expected); 51 shouldBe(expr, expected);
52 else 52 else
53 shouldThrow(expr); 53 shouldThrow(expr);
54 } 54 }
55 55
56 function checkSet(func, index, value, littleEndian) 56 function checkSet(func, index, value, littleEndian)
57 { 57 {
58 var expr = "view.set" + func + "(" + index + ", " + value; 58 var expr = "view.set" + func + "(" + index + ", " + value;
59 if (littleEndian != undefined) { 59 if (littleEndian != undefined) {
60 expr += ", "; 60 expr += ", ";
61 expr += littleEndian ? "true" : "false"; 61 expr += littleEndian ? "true" : "false";
62 } 62 }
63 expr += ")"; 63 expr += ")";
64 if (index + getElementSize(func) - 1 < view.byteLength) { 64 if (index >= 0 && index + getElementSize(func) - 1 < view.byteLength) {
65 shouldBeUndefined(expr); 65 shouldBeUndefined(expr);
66 checkGet(func, index, value, littleEndian); 66 checkGet(func, index, value, littleEndian);
67 } else 67 } else
68 shouldThrow(expr); 68 shouldThrow(expr);
69 } 69 }
70 70
71 function test(isTestingGet, func, index, value, littleEndian) 71 function test(isTestingGet, func, index, value, littleEndian)
72 { 72 {
73 if (isTestingGet) 73 if (isTestingGet)
74 checkGet(func, index, value, littleEndian); 74 checkGet(func, index, value, littleEndian);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 testFloat(isTestingGet, "Float32", isTestingGet ? [255, 255, 255, 127] : emp tyArray, start, "NaN"); 185 testFloat(isTestingGet, "Float32", isTestingGet ? [255, 255, 255, 127] : emp tyArray, start, "NaN");
186 testFloat(isTestingGet, "Float32", isTestingGet ? [255, 255, 255, 255] : emp tyArray, start, "-NaN"); 186 testFloat(isTestingGet, "Float32", isTestingGet ? [255, 255, 255, 255] : emp tyArray, start, "-NaN");
187 187
188 testFloat(isTestingGet, "Float64", isTestingGet ? [0, 0, 0, 0, 0, 0, 36, 64] : emptyArray, start, "10"); 188 testFloat(isTestingGet, "Float64", isTestingGet ? [0, 0, 0, 0, 0, 0, 36, 64] : emptyArray, start, "10");
189 testFloat(isTestingGet, "Float64", isTestingGet ? [174, 71, 225, 122, 20, 17 4, 243, 63] : emptyArray, start, "1.23"); 189 testFloat(isTestingGet, "Float64", isTestingGet ? [174, 71, 225, 122, 20, 17 4, 243, 63] : emptyArray, start, "1.23");
190 testFloat(isTestingGet, "Float64", isTestingGet ? [181, 55, 248, 30, 242, 17 9, 87, 193] : emptyArray, start, "-6213576.4839"); 190 testFloat(isTestingGet, "Float64", isTestingGet ? [181, 55, 248, 30, 242, 17 9, 87, 193] : emptyArray, start, "-6213576.4839");
191 testFloat(isTestingGet, "Float64", isTestingGet ? [255, 255, 255, 255, 255, 255, 255, 127] : emptyArray, start, "NaN"); 191 testFloat(isTestingGet, "Float64", isTestingGet ? [255, 255, 255, 255, 255, 255, 255, 127] : emptyArray, start, "NaN");
192 testFloat(isTestingGet, "Float64", isTestingGet ? [255, 255, 255, 255, 255, 255, 255, 255] : emptyArray, start, "-NaN"); 192 testFloat(isTestingGet, "Float64", isTestingGet ? [255, 255, 255, 255, 255, 255, 255, 255] : emptyArray, start, "-NaN");
193 } 193 }
194 194
195 function runNegativeIndexTests(isTestingGet)
196 {
197 createDataView(intArray1, 0, true, 0, 16);
198
199 test(isTestingGet, "Int8", -1, "0");
200 test(isTestingGet, "Int8", -2, "0");
201
202 test(isTestingGet, "Uint8", -1, "0");
203 test(isTestingGet, "Uint8", -2, "0");
204
205 test(isTestingGet, "Int16", -1, "0");
206 test(isTestingGet, "Int16", -2, "0");
207 test(isTestingGet, "Int16", -3, "0");
208
209 test(isTestingGet, "Uint16", -1, "0");
210 test(isTestingGet, "Uint16", -2, "0");
211 test(isTestingGet, "Uint16", -3, "0");
212
213 test(isTestingGet, "Int32", -1, "0");
214 test(isTestingGet, "Int32", -3, "0");
215 test(isTestingGet, "Int32", -5, "0");
216
217 test(isTestingGet, "Uint32", -1, "0");
218 test(isTestingGet, "Uint32", -3, "0");
219 test(isTestingGet, "Uint32", -5, "0");
220
221 createDataView([0, 0, 0, 0, 0, 0, 36, 64], 0, true, 0, 8);
222
223 test(isTestingGet, "Float32", -1, "0");
224 test(isTestingGet, "Float32", -3, "0");
225 test(isTestingGet, "Float32", -5, "0");
226
227 test(isTestingGet, "Float64", -1, "0");
228 test(isTestingGet, "Float64", -5, "0");
229 test(isTestingGet, "Float64", -9, "0");
230 }
231
195 function runConstructorTests() 232 function runConstructorTests()
196 { 233 {
197 arayBuffer = (new Uint8Array([1, 2])).buffer; 234 arayBuffer = (new Uint8Array([1, 2])).buffer;
198 235
199 debug(""); 236 debug("");
200 debug("Test for constructor taking 1 argument"); 237 debug("Test for constructor taking 1 argument");
201 shouldBeDefined("view = new DataView(arayBuffer)"); 238 shouldBeDefined("view = new DataView(arayBuffer)");
202 shouldBe("view.byteOffset", "0"); 239 shouldBe("view.byteOffset", "0");
203 shouldBe("view.byteLength", "2"); 240 shouldBe("view.byteLength", "2");
204 241
(...skipping 17 matching lines...) Expand all
222 } 259 }
223 260
224 function runGetTests() 261 function runGetTests()
225 { 262 {
226 debug(""); 263 debug("");
227 debug("Test for get methods that work"); 264 debug("Test for get methods that work");
228 runIntegerTestCases(true, intArray1, 0, 16); 265 runIntegerTestCases(true, intArray1, 0, 16);
229 runFloatTestCases(true, 0); 266 runFloatTestCases(true, 0);
230 267
231 debug(""); 268 debug("");
232 debug("Test for get methods that might read beyound range"); 269 debug("Test for get methods that might read beyond range");
233 runIntegerTestCases(true, intArray2, 3, 2); 270 runIntegerTestCases(true, intArray2, 3, 2);
234 runFloatTestCases(true, 3); 271 runFloatTestCases(true, 3);
235 272
236 debug(""); 273 debug("");
274 debug("Test for get methods that read from negative index");
275 runNegativeIndexTests(true);
276
277 debug("");
237 debug("Test for wrong arguments passed to get methods"); 278 debug("Test for wrong arguments passed to get methods");
238 view = new DataView((new Uint8Array([1, 2])).buffer); 279 view = new DataView((new Uint8Array([1, 2])).buffer);
239 shouldThrow("view.getInt8()"); 280 shouldThrow("view.getInt8()");
240 shouldThrow("view.getUint8()"); 281 shouldThrow("view.getUint8()");
241 shouldThrow("view.getInt16()"); 282 shouldThrow("view.getInt16()");
242 shouldThrow("view.getUint16()"); 283 shouldThrow("view.getUint16()");
243 shouldThrow("view.getInt32()"); 284 shouldThrow("view.getInt32()");
244 shouldThrow("view.getUint32()"); 285 shouldThrow("view.getUint32()");
245 shouldThrow("view.getFloat32()"); 286 shouldThrow("view.getFloat32()");
246 shouldThrow("view.getFloat64()"); 287 shouldThrow("view.getFloat64()");
247 } 288 }
248 289
249 function runSetTests() 290 function runSetTests()
250 { 291 {
251 debug(""); 292 debug("");
252 debug("Test for set methods that work"); 293 debug("Test for set methods that work");
253 runIntegerTestCases(false, emptyArray, 0, 16); 294 runIntegerTestCases(false, emptyArray, 0, 16);
254 runFloatTestCases(false); 295 runFloatTestCases(false);
255 296
256 debug(""); 297 debug("");
257 debug("Test for set methods that might write beyond the range"); 298 debug("Test for set methods that might write beyond the range");
258 runIntegerTestCases(false, emptyArray, 3, 2); 299 runIntegerTestCases(false, emptyArray, 3, 2);
259 runFloatTestCases(false, 7); 300 runFloatTestCases(false, 7);
260 301
261 debug(""); 302 debug("");
262 debug("Test for wrong arguments passed to get methods"); 303 debug("Test for set methods that write to negative index");
304 runNegativeIndexTests(false);
305
306 debug("");
307 debug("Test for wrong arguments passed to set methods");
263 view = new DataView((new Uint8Array([1, 2])).buffer); 308 view = new DataView((new Uint8Array([1, 2])).buffer);
264 shouldThrow("view.setInt8()"); 309 shouldThrow("view.setInt8()");
265 shouldThrow("view.setUint8()"); 310 shouldThrow("view.setUint8()");
266 shouldThrow("view.setInt16()"); 311 shouldThrow("view.setInt16()");
267 shouldThrow("view.setUint16()"); 312 shouldThrow("view.setUint16()");
268 shouldThrow("view.setInt32()"); 313 shouldThrow("view.setInt32()");
269 shouldThrow("view.setUint32()"); 314 shouldThrow("view.setUint32()");
270 shouldThrow("view.setFloat32()"); 315 shouldThrow("view.setFloat32()");
271 shouldThrow("view.setFloat64()"); 316 shouldThrow("view.setFloat64()");
272 shouldThrow("view.setInt8(1)"); 317 shouldThrow("view.setInt8(1)");
(...skipping 19 matching lines...) Expand all
292 runConstructorTests(); 337 runConstructorTests();
293 runGetTests(); 338 runGetTests();
294 runSetTests(); 339 runSetTests();
295 runIndexingTests(); 340 runIndexingTests();
296 successfullyParsed = true; 341 successfullyParsed = true;
297 </script> 342 </script>
298 343
299 <script src="../../js/resources/js-test-post.js"></script> 344 <script src="../../js/resources/js-test-post.js"></script>
300 </body> 345 </body>
301 </html> 346 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/webgl/data-view-test-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698