source: imaps-frontend/node_modules/is-shared-array-buffer/test/index.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[d565449]1'use strict';
2
3var test = require('tape');
4var inspect = require('object-inspect');
5var forEach = require('for-each');
6var v = require('es-value-fixtures');
7var availableTypedArrays = require('available-typed-arrays')();
8
9var isSharedArrayBuffer = require('..');
10
11test('isSharedArrayBuffer', function (t) {
12 t.equal(typeof isSharedArrayBuffer, 'function', 'is a function');
13
14 // @ts-expect-error TS sucks with concat
15 var nonSABs = [].concat(v.primitives, v.objects);
16 forEach(nonSABs, function (nonSAB) {
17 t.equal(isSharedArrayBuffer(nonSAB), false, inspect(nonSAB) + ' is not a SharedArrayBuffer');
18 });
19
20 t.test('actual SharedArrayBuffer instances', { skip: typeof SharedArrayBuffer === 'undefined' }, function (st) {
21 var sab = new SharedArrayBuffer(0);
22
23 st.equal(isSharedArrayBuffer(sab), true, inspect(sab) + ' is a SharedArrayBuffer');
24
25 st.end();
26 });
27
28 t.test('Typed Arrays', { skip: availableTypedArrays.length === 0 }, function (st) {
29 forEach(availableTypedArrays, function (TypedArray) {
30 var ta = new global[TypedArray](0);
31 st.equal(isSharedArrayBuffer(ta.buffer), false, inspect(ta.buffer) + ', the TA\'s buffer, is not a SharedArrayBuffer');
32 st.equal(isSharedArrayBuffer(ta), false, inspect(ta) + ' is not a SharedArrayBuffer');
33 });
34
35 st.end();
36 });
37
38 t.end();
39});
Note: See TracBrowser for help on using the repository browser.