OLD | NEW |
---|---|
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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 | 393 |
394 TestOutOfRange(); | 394 TestOutOfRange(); |
395 | 395 |
396 function TestGeneralAccessors() { | 396 function TestGeneralAccessors() { |
397 var a = new DataView(new ArrayBuffer(256)); | 397 var a = new DataView(new ArrayBuffer(256)); |
398 function CheckAccessor(name) { | 398 function CheckAccessor(name) { |
399 var f = a[name]; | 399 var f = a[name]; |
400 assertThrows(function() { f(); }, TypeError); | 400 assertThrows(function() { f(); }, TypeError); |
401 f.call(a, 0, 0); // should not throw | 401 f.call(a, 0, 0); // should not throw |
402 assertThrows(function() { f.call({}, 0, 0); }, TypeError); | 402 assertThrows(function() { f.call({}, 0, 0); }, TypeError); |
403 assertThrows(function() { f.call(a); }, TypeError); | 403 f.call(a); |
404 if (name.indexOf("set") == 0) { | 404 f.call(a, 1); // should not throw |
405 assertThrows(function() { f.call(a, 1); }, TypeError); | |
406 } else { | |
407 f.call(a, 1); // should not throw | |
408 } | |
409 } | 405 } |
410 CheckAccessor("getUint8"); | 406 CheckAccessor("getUint8"); |
411 CheckAccessor("setUint8"); | 407 CheckAccessor("setUint8"); |
412 CheckAccessor("getInt8"); | 408 CheckAccessor("getInt8"); |
413 CheckAccessor("setInt8"); | 409 CheckAccessor("setInt8"); |
414 CheckAccessor("getUint16"); | 410 CheckAccessor("getUint16"); |
415 CheckAccessor("setUint16"); | 411 CheckAccessor("setUint16"); |
416 CheckAccessor("getInt16"); | 412 CheckAccessor("getInt16"); |
417 CheckAccessor("setInt16"); | 413 CheckAccessor("setInt16"); |
418 CheckAccessor("getUint32"); | 414 CheckAccessor("getUint32"); |
419 CheckAccessor("setUint32"); | 415 CheckAccessor("setUint32"); |
420 CheckAccessor("getInt32"); | 416 CheckAccessor("getInt32"); |
421 CheckAccessor("setInt32"); | 417 CheckAccessor("setInt32"); |
422 CheckAccessor("getFloat32"); | 418 CheckAccessor("getFloat32"); |
423 CheckAccessor("setFloat32"); | 419 CheckAccessor("setFloat32"); |
424 CheckAccessor("getFloat64"); | 420 CheckAccessor("getFloat64"); |
425 CheckAccessor("setFloat64"); | 421 CheckAccessor("setFloat64"); |
426 } | 422 } |
427 | 423 |
428 TestGeneralAccessors(); | 424 TestGeneralAccessors(); |
429 | 425 |
430 function TestInsufficientArguments() { | 426 function TestInsufficientArguments() { |
431 var a = new DataView(new ArrayBuffer(256)); | 427 var a = new DataView(new ArrayBuffer(256)); |
432 | 428 |
433 assertThrows(function() { a.getUint8(); }, TypeError); | 429 a.getUint8(); |
434 assertThrows(function() { a.getInt8(); }, TypeError); | 430 a.getInt8(); |
435 assertThrows(function() { a.getUint16(); }, TypeError); | 431 a.getUint16(); |
436 assertThrows(function() { a.getInt16(); }, TypeError); | 432 a.getInt16(); |
437 assertThrows(function() { a.getUint32(); }, TypeError); | 433 a.getUint32(); |
438 assertThrows(function() { a.getInt32(); }, TypeError); | 434 a.getInt32(); |
439 assertThrows(function() { a.getFloat32(); }, TypeError); | 435 a.getFloat32(); |
440 assertThrows(function() { a.getFloat64(); }, TypeError); | 436 a.getFloat64(); |
441 | 437 |
442 assertThrows(function() { a.setUint8(); }, TypeError); | 438 a.setUint8(); |
443 assertThrows(function() { a.setInt8(); }, TypeError); | 439 a.setInt8(); |
444 assertThrows(function() { a.setUint16(); }, TypeError); | 440 a.setUint16(); |
445 assertThrows(function() { a.setInt16(); }, TypeError); | 441 a.setInt16(); |
446 assertThrows(function() { a.setUint32(); }, TypeError); | 442 a.setUint32(); |
447 assertThrows(function() { a.setInt32(); }, TypeError); | 443 a.setInt32(); |
448 assertThrows(function() { a.setFloat32(); }, TypeError); | 444 a.setFloat32(); |
449 assertThrows(function() { a.setFloat64(); }, TypeError); | 445 a.setFloat64(); |
450 | 446 |
451 assertThrows(function() { a.setUint8(1) }, TypeError); | 447 a.setUint8(1); |
452 assertThrows(function() { a.setInt8(1) }, TypeError); | 448 a.setInt8(1); |
453 assertThrows(function() { a.setUint16(1) }, TypeError); | 449 a.setUint16(1); |
454 assertThrows(function() { a.setInt16(1) }, TypeError); | 450 a.setInt16(1); |
455 assertThrows(function() { a.setUint32(1) }, TypeError); | 451 a.setUint32(1); |
456 assertThrows(function() { a.setInt32(1) }, TypeError); | 452 a.setInt32(1); |
457 assertThrows(function() { a.setFloat32(1) }, TypeError); | 453 a.setFloat32(1); |
458 assertThrows(function() { a.setFloat64(1) }, TypeError); | 454 a.setFloat64(1); |
Dan Ehrenberg
2016/06/23 21:45:32
Can you assert that these get values that make sen
bakkot
2016/06/28 23:41:07
Done.
| |
459 } | 455 } |
460 | 456 |
461 TestInsufficientArguments(); | 457 TestInsufficientArguments(); |
OLD | NEW |