init-zero.js (1204B)
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 10 24.1.1.1 AllocateArrayBuffer 11 12 3. Let block be ? CreateByteDataBlock(byteLength). 13 14 6.2.6.1 CreateByteDataBlock 15 16 1. Assert: sizeā„0. 17 2. Let db be a new Data Block value consisting of size bytes. If it is 18 impossible to create such a Data Block, throw a RangeError exception. 19 3. Set all of the bytes of db to 0. 20 4. Return db. 21 features: [DataView] 22 ---*/ 23 24 var view = new DataView(new ArrayBuffer(9)); 25 26 assert.sameValue(view.getUint8(0), 0, 'index 0'); 27 assert.sameValue(view.getUint8(1), 0, 'index 1'); 28 assert.sameValue(view.getUint8(2), 0, 'index 2'); 29 assert.sameValue(view.getUint8(3), 0, 'index 3'); 30 assert.sameValue(view.getUint8(4), 0, 'index 4'); 31 assert.sameValue(view.getUint8(5), 0, 'index 5'); 32 assert.sameValue(view.getUint8(6), 0, 'index 6'); 33 assert.sameValue(view.getUint8(7), 0, 'index 7'); 34 assert.sameValue(view.getUint8(8), 0, 'index 8'); 35 36 reportCompare(0, 0);