Add types of BufferSource

This commit is contained in:
Christoph Diehl 2017-09-13 21:04:58 +02:00
parent 81ec8a9891
commit 6303c66f51
1 changed files with 5 additions and 5 deletions

View File

@ -79,21 +79,21 @@ make.typed = {
])
return random.chance(10) ? -value : value
},
arrayBuffer: function(byteLength = null) {
arrayBuffer: function (byteLength = null) {
let length = (byteLength !== null) ? byteLength : this.unsignedShort()
return 'new ArrayBuffer(' + length + ')'
},
dataView: function(byteLength = null) {
dataView: function (byteLength = null) {
let length = (byteLength !== null) ? byteLength : this.unsignedShort()
return 'new DataView(' + this.arrayBuffer(length) + ')'
},
typedArray: function(byteLength = null) {
typedArray: function (byteLength = null) {
let length = (byteLength !== null) ? byteLength : this.unsignedShort()
let arrType = random.item([
'Int8', 'Uint8', 'Uint8Clamped',
'Int16', 'Uint16',
'Int32', 'Uint32',
'Float32', 'Float64',
'Float32', 'Float64'
])
let method = 'new ' + arrType + 'Array'
switch (random.number(16)) {
@ -105,7 +105,7 @@ make.typed = {
return method + '(' + length + ')'
}
},
bufferSource: function() {
bufferSource: function () {
return random.choose([
[1, [this.arrayBuffer, this.dataView]],
[1, [this.typedArray]]