Skip to content

Commit 958e1ad

Browse files
committed
Auto-generated commit
1 parent bba1691 commit 958e1ad

File tree

3 files changed

+8
-123
lines changed

3 files changed

+8
-123
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838
},
3939
"dependencies": {
4040
"@stdlib/assert-is-collection": "^0.1.0",
41-
"@stdlib/assert-is-function": "^0.1.0",
42-
"@stdlib/buffer-ctor": "^0.1.0",
43-
"@stdlib/string-format": "^0.1.0",
41+
"@stdlib/assert-is-function": "^0.1.1",
42+
"@stdlib/buffer-ctor": "^0.1.1",
43+
"@stdlib/string-format": "^0.1.1",
4444
"@stdlib/types": "^0.1.0"
4545
},
4646
"devDependencies": {
4747
"@stdlib/array-uint8": "^0.1.0",
48-
"@stdlib/assert-is-buffer": "^0.1.0",
48+
"@stdlib/assert-is-buffer": "^0.1.1",
4949
"@stdlib/bench": "^0.1.0",
5050
"@stdlib/math-base-special-pow": "^0.1.0",
5151
"proxyquire": "^2.0.0",

test/dist/test.js

Lines changed: 4 additions & 118 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,127 +21,13 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var proxyquire = require( 'proxyquire' );
25-
var Buffer = require( '@stdlib/buffer-ctor' );
26-
var Uint8Array = require( '@stdlib/array-uint8' );
27-
var isBuffer = require( '@stdlib/assert-is-buffer' );
28-
var polyfill = require( './../../dist/polyfill.js' );
29-
var nonPolyfill = require( './../../dist/main.js' );
30-
var array2buffer = require( './../../dist' );
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 array2buffer, 'function', 'main export is a function' );
38-
t.end();
39-
});
40-
41-
tape( 'in older environments, the main export is a polyfill', function test( t ) {
42-
var array2buffer = proxyquire( './../dist', {
43-
'./has_from.js': false
44-
});
45-
t.strictEqual( array2buffer, polyfill, 'returns polyfill' );
46-
t.end();
47-
});
48-
49-
tape( 'in newer environments, the main export is not a polyfill', function test( t ) {
50-
var array2buffer = proxyquire( './../dist', {
51-
'./has_from.js': true
52-
});
53-
t.strictEqual( array2buffer, nonPolyfill, 'does not return polyfill' );
54-
t.end();
55-
});
56-
57-
tape( 'the function throws an error if not provided an array-like object', function test( t ) {
58-
var values;
59-
var i;
60-
61-
values = [
62-
'5',
63-
5,
64-
NaN,
65-
true,
66-
false,
67-
null,
68-
void 0,
69-
{},
70-
Array,
71-
Buffer,
72-
Uint8Array,
73-
function noop() {}
74-
];
75-
76-
for ( i = 0; i < values.length; i++ ) {
77-
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
78-
}
79-
t.end();
80-
81-
function badValue( value ) {
82-
return function badValue() {
83-
array2buffer( value );
84-
};
85-
}
86-
});
87-
88-
tape( 'the function allocates a buffer using an octet array (array)', function test( t ) {
89-
var buf;
90-
var arr;
91-
var i;
92-
93-
arr = [ 1, 2, 3, 4 ];
94-
buf = array2buffer( arr );
95-
96-
t.strictEqual( isBuffer( buf ), true, 'returns a buffer' );
97-
98-
for ( i = 0; i < arr.length; i++ ) {
99-
t.strictEqual( buf[ i ], arr[ i ], 'returns expected value for element ' + i );
100-
}
101-
t.end();
102-
});
103-
104-
tape( 'the function allocates a buffer using an octet array (typed array)', function test( t ) {
105-
var buf;
106-
var arr;
107-
var i;
108-
109-
arr = new Uint8Array( [ 1, 2, 3, 4 ] );
110-
buf = array2buffer( arr );
111-
112-
t.strictEqual( isBuffer( buf ), true, 'returns a buffer' );
113-
114-
for ( i = 0; i < arr.length; i++ ) {
115-
t.strictEqual( buf[ i ], arr[ i ], 'returns expected value for element ' + i );
116-
}
117-
t.end();
118-
});
119-
120-
tape( 'the function allocates a buffer using an octet array (array-like)', function test( t ) {
121-
var buf;
122-
var arr;
123-
var i;
124-
125-
arr = {
126-
'length': 4,
127-
'0': 1,
128-
'1': 2,
129-
'2': 3,
130-
'3': 4
131-
};
132-
buf = array2buffer( arr );
133-
134-
t.strictEqual( isBuffer( buf ), true, 'returns a buffer' );
135-
136-
for ( i = 0; i < arr.length; i++ ) {
137-
t.strictEqual( buf[ i ], arr[ i ], 'returns expected value for element ' + i );
138-
}
139-
t.end();
140-
});
141-
142-
tape( 'if provided an empty array, the function returns an empty buffer', function test( t ) {
143-
var buf = array2buffer( [] );
144-
t.strictEqual( isBuffer( buf ), true, 'returns a buffer' );
145-
t.strictEqual( buf.length, 0, 'has expected length' );
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
14632
t.end();
14733
});

0 commit comments

Comments
 (0)