Spaces:
Configuration error
Configuration error
File size: 1,348 Bytes
5641073 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
'use strict';
var test = require('tape');
var inspect = require('object-inspect');
var forEach = require('for-each');
var v = require('es-value-fixtures');
var availableTypedArrays = require('available-typed-arrays')();
var isArrayBuffer = require('..');
test('isArrayBuffer', function (t) {
t.equal(typeof isArrayBuffer, 'function', 'is a function');
var nonABs = v.primitives.concat(
v.objects,
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer() : []
);
forEach(nonABs, function (nonAB) {
t.equal(isArrayBuffer(nonAB), false, inspect(nonAB) + ' is not an ArrayBuffer');
});
t.test('actual ArrayBuffer instances', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
var ab = new ArrayBuffer();
st.equal(isArrayBuffer(ab), true, inspect(ab) + ' is an ArrayBuffer');
var ab42 = new ArrayBuffer(42);
st.equal(isArrayBuffer(ab42), true, inspect(ab42) + ' is an ArrayBuffer');
st.end();
});
t.test('Typed Arrays', { skip: availableTypedArrays.length === 0 }, function (st) {
forEach(availableTypedArrays, function (TypedArray) {
var ta = new global[TypedArray](0);
st.equal(isArrayBuffer(ta.buffer), true, inspect(ta.buffer) + ', the TA\'s buffer, is an ArrayBuffer');
st.equal(isArrayBuffer(ta), false, inspect(ta) + ' is not an ArrayBuffer');
});
st.end();
});
t.end();
});
|