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

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

Issue 20030004: Make DataView setters throw when only offset is provided. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | « src/typedarray.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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 TestOutOfRange(); 382 TestOutOfRange();
383 383
384 function TestGeneralAccessors() { 384 function TestGeneralAccessors() {
385 var a = new DataView(new ArrayBuffer(256)); 385 var a = new DataView(new ArrayBuffer(256));
386 function CheckAccessor(name) { 386 function CheckAccessor(name) {
387 var f = a[name]; 387 var f = a[name];
388 assertThrows(function() { f(); }, TypeError); 388 assertThrows(function() { f(); }, TypeError);
389 f.call(a, 0, 0); // should not throw 389 f.call(a, 0, 0); // should not throw
390 assertThrows(function() { f.call({}, 0, 0); }, TypeError); 390 assertThrows(function() { f.call({}, 0, 0); }, TypeError);
391 assertThrows(function() { f.call(a); }, TypeError); 391 assertThrows(function() { f.call(a); }, TypeError);
392 if (name.indexOf("set") == 0) {
393 assertThrows(function() { f.call(a, 1); }, TypeError);
394 } else {
395 f.call(a, 1); // should not throw
396 }
392 } 397 }
393 CheckAccessor("getUint8"); 398 CheckAccessor("getUint8");
394 CheckAccessor("setUint8"); 399 CheckAccessor("setUint8");
395 CheckAccessor("getInt8"); 400 CheckAccessor("getInt8");
396 CheckAccessor("setInt8"); 401 CheckAccessor("setInt8");
397 CheckAccessor("getUint16"); 402 CheckAccessor("getUint16");
398 CheckAccessor("setUint16"); 403 CheckAccessor("setUint16");
399 CheckAccessor("getInt16"); 404 CheckAccessor("getInt16");
400 CheckAccessor("setInt16"); 405 CheckAccessor("setInt16");
401 CheckAccessor("getUint32"); 406 CheckAccessor("getUint32");
402 CheckAccessor("setUint32"); 407 CheckAccessor("setUint32");
403 CheckAccessor("getInt32"); 408 CheckAccessor("getInt32");
404 CheckAccessor("setInt32"); 409 CheckAccessor("setInt32");
405 CheckAccessor("getFloat32"); 410 CheckAccessor("getFloat32");
406 CheckAccessor("setFloat32"); 411 CheckAccessor("setFloat32");
407 CheckAccessor("getFloat64"); 412 CheckAccessor("getFloat64");
408 CheckAccessor("setFloat64"); 413 CheckAccessor("setFloat64");
409 } 414 }
410 415
411 TestGeneralAccessors(); 416 TestGeneralAccessors();
417
418 function TestInsufficientArguments() {
419 var a = new DataView(new ArrayBuffer(256));
420
421 assertThrows(function() { a.getUint8(); }, TypeError);
422 assertThrows(function() { a.getInt8(); }, TypeError);
423 assertThrows(function() { a.getUint16(); }, TypeError);
424 assertThrows(function() { a.getInt16(); }, TypeError);
425 assertThrows(function() { a.getUint32(); }, TypeError);
426 assertThrows(function() { a.getInt32(); }, TypeError);
427 assertThrows(function() { a.getFloat32(); }, TypeError);
428 assertThrows(function() { a.getFloat64(); }, TypeError);
429
430 assertThrows(function() { a.setUint8(); }, TypeError);
431 assertThrows(function() { a.setInt8(); }, TypeError);
432 assertThrows(function() { a.setUint16(); }, TypeError);
433 assertThrows(function() { a.setInt16(); }, TypeError);
434 assertThrows(function() { a.setUint32(); }, TypeError);
435 assertThrows(function() { a.setInt32(); }, TypeError);
436 assertThrows(function() { a.setFloat32(); }, TypeError);
437 assertThrows(function() { a.setFloat64(); }, TypeError);
438
439 assertThrows(function() { a.setUint8(1) }, TypeError);
440 assertThrows(function() { a.setInt8(1) }, TypeError);
441 assertThrows(function() { a.setUint16(1) }, TypeError);
442 assertThrows(function() { a.setInt16(1) }, TypeError);
443 assertThrows(function() { a.setUint32(1) }, TypeError);
444 assertThrows(function() { a.setInt32(1) }, TypeError);
445 assertThrows(function() { a.setFloat32(1) }, TypeError);
446 assertThrows(function() { a.setFloat64(1) }, TypeError);
447 }
448
449 TestInsufficientArguments();
OLDNEW
« no previous file with comments | « src/typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698