Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Oct 5, 2023
1 parent dc6d385 commit ab0abf9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 115 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"dependencies": {
"@stdlib/array-buffer": "^0.1.0",
"@stdlib/assert-has-arraybuffer-support": "^0.1.0",
"@stdlib/assert-is-dataview": "^0.1.0",
"@stdlib/assert-is-function": "^0.1.0",
"@stdlib/assert-is-dataview": "^0.1.1",
"@stdlib/assert-is-function": "^0.1.1",
"@stdlib/assert-is-typed-array": "^0.1.0",
"@stdlib/utils-constant-function": "^0.1.0"
"@stdlib/utils-constant-function": "^0.1.1"
},
"devDependencies": {
"@stdlib/array-float32": "^0.1.0",
Expand All @@ -54,7 +54,7 @@
"@stdlib/array-uint32": "^0.1.0",
"@stdlib/array-uint8": "^0.1.0",
"@stdlib/array-uint8c": "^0.1.0",
"@stdlib/assert-is-boolean": "^0.1.0",
"@stdlib/assert-is-boolean": "^0.1.1",
"@stdlib/bench": "^0.1.0",
"proxyquire": "^2.0.0",
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
Expand Down
114 changes: 4 additions & 110 deletions test/dist/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2021 The Stdlib Authors.
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,119 +21,13 @@
// MODULES //

var tape = require( 'tape' );
var proxyquire = require( 'proxyquire' );
var Int8Array = require( '@stdlib/array-int8' );
var Int16Array = require( '@stdlib/array-int16' );
var Uint16Array = require( '@stdlib/array-uint16' );
var Int32Array = require( '@stdlib/array-int32' );
var Uint32Array = require( '@stdlib/array-uint32' );
var Float32Array = require( '@stdlib/array-float32' );
var Float64Array = require( '@stdlib/array-float64' );
var isArrayBufferView = require( './../../dist' );
var main = require( './../../dist' );


// TESTS //

tape( 'main export is a function', function test( t ) {
tape( 'main export is defined', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof isArrayBufferView, 'function', 'main export is a function' );
t.strictEqual( main !== void 0, true, 'main export is defined' );
t.end();
});

tape( 'if an environment does not support array buffers, the main export is a polyfill which always returns `false`', function test( t ) {
var isArrayBufferView;
var values;
var i;

isArrayBufferView = proxyquire( './../dist', {
'@stdlib/assert-has-arraybuffer-support': hasSupport
});

t.strictEqual( isArrayBufferView, require( './../../dist/no_arraybuffer.js' ), 'exports a polyfill' );

values = [
'5',
5,
NaN,
null,
void 0,
false,
true,
[],
{},
function noop() {}
];

for ( i = 0; i < values.length; i++ ) {
t.strictEqual( isArrayBufferView( values[ i ] ), false, 'returns false when provided '+values[ i ] );
}
t.end();

function hasSupport() {
return false;
}
});

tape( 'if an environment does support array buffers but not the `ArrayBuffer.isView` method, the main export is a polyfill checking for data views or typed arrays', function test( t ) {
var isArrayBufferView;
var values;
var i;

isArrayBufferView = proxyquire( './../dist', {
'@stdlib/array-buffer': {
'isView': null
}
});

t.strictEqual( isArrayBufferView, require( './../../dist/polyfill.js' ), 'exports a polyfill' );

values = [
'5',
5,
NaN,
null,
void 0,
false,
true,
[],
{},
function noop() {}
];

for ( i = 0; i < values.length; i++ ) {
t.strictEqual( isArrayBufferView( values[ i ] ), false, 'returns false when provided '+values[ i ] );
}

values = [
new Float64Array( 10 ),
new Float32Array( 10 ),
new Int32Array( 10 ),
new Uint32Array( 10 ),
new Int16Array( 10 ),
new Uint16Array( 10 ),
new Int8Array( 10 )
];
for ( i = 0; i < values.length; i++ ) {
t.strictEqual( isArrayBufferView( values[ i ] ), true, 'returns true when provided '+values[ i ] );
}

t.end();
});

tape( 'if an environment does support array buffers and the `ArrayBuffer.isView` method, the main export is not any of the polyfills', function test( t ) {
var isArrayBufferView = proxyquire( './../dist', {
'@stdlib/assert-has-arraybuffer-support': hasSupport,
'./main.js': main
});

t.strictEqual( isArrayBufferView, isArrayBufferView, 'exports expected function' );
t.end();

function hasSupport() {
return true;
}

function main() {
return false;
}
});

0 comments on commit ab0abf9

Please sign in to comment.