init-zero.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (C) 2016 the V8 project authors. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-arraybuffer-length
  5. description: All bytes are initialized to zero
  6. info: |
  7. [...]
  8. 5. Return ? AllocateArrayBuffer(NewTarget, byteLength).
  9. 24.1.1.1 AllocateArrayBuffer
  10. 3. Let block be ? CreateByteDataBlock(byteLength).
  11. 6.2.6.1 CreateByteDataBlock
  12. 1. Assert: size≥0.
  13. 2. Let db be a new Data Block value consisting of size bytes. If it is
  14. impossible to create such a Data Block, throw a RangeError exception.
  15. 3. Set all of the bytes of db to 0.
  16. 4. Return db.
  17. features: [DataView]
  18. ---*/
  19. var view = new DataView(new ArrayBuffer(9));
  20. assert.sameValue(view.getUint8(0), 0, 'index 0');
  21. assert.sameValue(view.getUint8(1), 0, 'index 1');
  22. assert.sameValue(view.getUint8(2), 0, 'index 2');
  23. assert.sameValue(view.getUint8(3), 0, 'index 3');
  24. assert.sameValue(view.getUint8(4), 0, 'index 4');
  25. assert.sameValue(view.getUint8(5), 0, 'index 5');
  26. assert.sameValue(view.getUint8(6), 0, 'index 6');
  27. assert.sameValue(view.getUint8(7), 0, 'index 7');
  28. assert.sameValue(view.getUint8(8), 0, 'index 8');