Skip to content

Commit 9b9a905

Browse files
committed
Auto-generated commit
1 parent bc022fe commit 9b9a905

File tree

3 files changed

+10
-171
lines changed

3 files changed

+10
-171
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
217217
[npm-image]: http://img.shields.io/npm/v/@stdlib/assert-has-sharedarraybuffer-support.svg
218218
[npm-url]: https://npmjs.org/package/@stdlib/assert-has-sharedarraybuffer-support
219219

220-
[test-image]: https://github.com/stdlib-js/assert-has-sharedarraybuffer-support/actions/workflows/test.yml/badge.svg?branch=v0.1.1
221-
[test-url]: https://github.com/stdlib-js/assert-has-sharedarraybuffer-support/actions/workflows/test.yml?query=branch:v0.1.1
220+
[test-image]: https://github.com/stdlib-js/assert-has-sharedarraybuffer-support/actions/workflows/test.yml/badge.svg?branch=main
221+
[test-url]: https://github.com/stdlib-js/assert-has-sharedarraybuffer-support/actions/workflows/test.yml?query=branch:main
222222

223223
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert-has-sharedarraybuffer-support/main.svg
224224
[coverage-url]: https://codecov.io/github/stdlib-js/assert-has-sharedarraybuffer-support?branch=main

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
"@stdlib/fs-read-file": "^0.1.1"
4646
},
4747
"devDependencies": {
48-
"@stdlib/assert-is-boolean": "^0.1.0",
49-
"@stdlib/assert-is-browser": "^0.1.0",
50-
"@stdlib/assert-is-windows": "^0.1.0",
48+
"@stdlib/assert-is-boolean": "^0.1.1",
49+
"@stdlib/assert-is-browser": "^0.1.1",
50+
"@stdlib/assert-is-windows": "^0.1.1",
5151
"@stdlib/bench": "^0.1.0",
52-
"@stdlib/process-exec-path": "^0.1.0",
52+
"@stdlib/process-exec-path": "^0.1.1",
5353
"proxyquire": "^2.0.0",
5454
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
5555
"istanbul": "^0.4.1",

test/dist/test.js

Lines changed: 4 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,174 +21,13 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var proxyquire = require( 'proxyquire' );
25-
var detect = require( './../../dist' );
26-
27-
28-
// VARIABLES //
29-
30-
var hasSharedArrayBuffer = ( typeof SharedArrayBuffer === 'function' ); // eslint-disable-line stdlib/require-globals
24+
var main = require( './../../dist' );
3125

3226

3327
// TESTS //
3428

35-
tape( 'main export is a function', function test( t ) {
29+
tape( 'main export is defined', function test( t ) {
3630
t.ok( true, __filename );
37-
t.strictEqual( typeof detect, 'function', 'main export is a function' );
38-
t.end();
39-
});
40-
41-
tape( 'feature detection result is a boolean', function test( t ) {
42-
t.strictEqual( typeof detect(), 'boolean', 'detection result is a boolean' );
43-
t.end();
44-
});
45-
46-
tape( 'if `SharedArrayBuffer` is supported, detection result is `true`', function test( t ) {
47-
var mocked;
48-
if ( hasSharedArrayBuffer ) {
49-
t.strictEqual( detect(), true, 'detection result is `true`' );
50-
} else {
51-
t.strictEqual( detect(), false, 'detection result is `false`' );
52-
}
53-
function Mock( len ) {
54-
var out;
55-
var i;
56-
57-
out = new Array( len/8 ); // we assume evenly divisible
58-
for ( i = 0; i < out.length; i++ ) {
59-
out[ i ] = 0;
60-
}
61-
out.byteLength = len;
62-
out.slice = slice;
63-
return out;
64-
65-
function slice( start, end ) {
66-
var arr;
67-
var i;
68-
69-
arr = [];
70-
for ( i = start; i < end; i++ ) {
71-
arr.push( out[ i ] );
72-
}
73-
arr.byteLength = arr.length;
74-
arr.slice = slice;
75-
return arr;
76-
}
77-
}
78-
79-
mocked = proxyquire( './../dist/main.js', {
80-
'./sharedarraybuffer.js': Mock,
81-
'@stdlib/assert-is-sharedarraybuffer': isBuffer
82-
});
83-
t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' );
84-
85-
t.end();
86-
87-
function isBuffer() {
88-
return true;
89-
}
90-
});
91-
92-
tape( 'if `SharedArrayBuffer` is not supported, detection result is `false` (no SharedArrayBuffer global function)', function test( t ) {
93-
var mocked;
94-
if ( hasSharedArrayBuffer ) {
95-
t.strictEqual( detect(), true, 'detection result is `true`' );
96-
} else {
97-
t.strictEqual( detect(), false, 'detection result is `false`' );
98-
}
99-
mocked = proxyquire( './../dist/main.js', {
100-
'./sharedarraybuffer.js': {}
101-
});
102-
t.strictEqual( mocked(), false, 'detection result is `false`' );
103-
t.end();
104-
});
105-
106-
tape( 'if `SharedArrayBuffer` is not supported, detected result is `false` (constructor throws)', function test( t ) {
107-
var mocked;
108-
if ( hasSharedArrayBuffer ) {
109-
t.strictEqual( detect(), true, 'detection result is `true`' );
110-
} else {
111-
t.strictEqual( detect(), false, 'detection result is `false`' );
112-
}
113-
mocked = proxyquire( './../dist/main.js', {
114-
'./sharedarraybuffer.js': mock
115-
});
116-
t.strictEqual( mocked(), false, 'detection result is `false`' );
117-
t.end();
118-
119-
function mock() {
120-
throw new Error( 'beep' );
121-
}
122-
});
123-
124-
tape( 'if `SharedArrayBuffer` is not supported, detected result is `false` (no slice method)', function test( t ) {
125-
var mocked;
126-
if ( hasSharedArrayBuffer ) {
127-
t.strictEqual( detect(), true, 'detection result is `true`' );
128-
} else {
129-
t.strictEqual( detect(), false, 'detection result is `false`' );
130-
}
131-
function Mock( len ) {
132-
var out;
133-
var i;
134-
135-
out = new Array( len/8 ); // we assume evenly divisible
136-
for ( i = 0; i < out.length; i++ ) {
137-
out[ i ] = 0;
138-
}
139-
out.byteLength = len;
140-
return out;
141-
}
142-
mocked = proxyquire( './../dist/main.js', {
143-
'./sharedarraybuffer.js': Mock,
144-
'@stdlib/assert-is-sharedarraybuffer': isBuffer
145-
});
146-
t.strictEqual( mocked(), false, 'detection result is `false`' );
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
14732
t.end();
148-
149-
function isBuffer() {
150-
return true;
151-
}
152-
});
153-
154-
tape( 'if `SharedArrayBuffer` is not supported, detected result is `false` (no byteLength property)', function test( t ) {
155-
var mocked;
156-
if ( hasSharedArrayBuffer ) {
157-
t.strictEqual( detect(), true, 'detection result is `true`' );
158-
} else {
159-
t.strictEqual( detect(), false, 'detection result is `false`' );
160-
}
161-
function Mock( len ) {
162-
var out;
163-
var i;
164-
165-
out = new Array( len/8 ); // we assume evenly divisible
166-
for ( i = 0; i < out.length; i++ ) {
167-
out[ i ] = 0;
168-
}
169-
out.slice = slice;
170-
return out;
171-
172-
function slice( start, end ) {
173-
var arr;
174-
var i;
175-
176-
arr = [];
177-
for ( i = start; i < end; i++ ) {
178-
arr.push( out[ i ] );
179-
}
180-
arr.slice = slice;
181-
return arr;
182-
}
183-
}
184-
mocked = proxyquire( './../dist/main.js', {
185-
'./sharedarraybuffer.js': Mock,
186-
'@stdlib/assert-is-sharedarraybuffer': isBuffer
187-
});
188-
t.strictEqual( mocked(), false, 'detection result is `false`' );
189-
t.end();
190-
191-
function isBuffer() {
192-
return true;
193-
}
19433
});

0 commit comments

Comments
 (0)