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 a5e5cf9 commit 8ef50ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 115 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@
"url": "https://github.com/stdlib-js/stdlib/issues"
},
"dependencies": {
"@stdlib/assert-is-int8array": "^0.1.0",
"@stdlib/cli-ctor": "^0.1.0",
"@stdlib/constants-int8-max": "^0.1.0",
"@stdlib/constants-int8-min": "^0.1.0",
"@stdlib/fs-read-file": "^0.1.0"
"@stdlib/assert-is-int8array": "^0.1.1",
"@stdlib/cli-ctor": "^0.1.1",
"@stdlib/constants-int8-max": "^0.1.1",
"@stdlib/constants-int8-min": "^0.1.1",
"@stdlib/fs-read-file": "^0.1.1"
},
"devDependencies": {
"@stdlib/array-int8": "^0.1.0",
"@stdlib/assert-is-boolean": "^0.1.0",
"@stdlib/assert-is-browser": "^0.1.0",
"@stdlib/assert-is-windows": "^0.1.0",
"@stdlib/assert-is-boolean": "^0.1.1",
"@stdlib/assert-is-browser": "^0.1.1",
"@stdlib/assert-is-windows": "^0.1.1",
"@stdlib/bench": "^0.1.0",
"@stdlib/process-exec-path": "^0.1.0",
"@stdlib/process-exec-path": "^0.1.1",
"proxyquire": "^2.0.0",
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
"istanbul": "^0.4.1",
Expand Down
109 changes: 4 additions & 105 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) 2018 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,114 +21,13 @@
// MODULES //

var tape = require( 'tape' );
var proxyquire = require( 'proxyquire' );
var Int8Array = require( '@stdlib/array-int8' );
var detect = require( './../../dist' );


// VARIABLES //

var hasInt8Array = ( typeof Int8Array === 'function' );
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 detect, 'function', 'main export is a function' );
t.strictEqual( main !== void 0, true, 'main export is defined' );
t.end();
});

tape( 'feature detection result is a boolean', function test( t ) {
t.strictEqual( typeof detect(), 'boolean', 'detection result is a boolean' );
t.end();
});

tape( 'if `Int8Array` is supported, detection result is `true`', function test( t ) {
var mocked;
if ( hasInt8Array ) {
t.strictEqual( detect(), true, 'detection result is `true`' );
} else {
t.strictEqual( detect(), false, 'detection result is `false`' );
}
mocked = proxyquire( './../dist/main.js', {
'./int8array.js': Mock,
'@stdlib/assert-is-int8array': isArray
});
t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' );

t.end();

function isArray() {
return true;
}

function Mock() {
return [
1,
3,
-3,
-128
];
}
});

tape( 'if `Int8Array` is not supported, detection result is `false`', function test( t ) {
var mocked;
if ( hasInt8Array ) {
t.strictEqual( detect(), true, 'detection result is `true`' );
} else {
t.strictEqual( detect(), false, 'detection result is `false`' );
}
mocked = proxyquire( './../dist/main.js', {
'./int8array.js': {}
});
t.strictEqual( mocked(), false, 'detection result is `false`' );

mocked = proxyquire( './../dist/main.js', {
'./int8array.js': Mock1
});
t.strictEqual( mocked(), false, 'detection result is `false`' );

mocked = proxyquire( './../dist/main.js', {
'./int8array.js': Mock2,
'@stdlib/assert-is-int8array': isArray
});
t.strictEqual( mocked(), false, 'detection result is `false`' );

mocked = proxyquire( './../dist/main.js', {
'./int8array.js': Mock3,
'@stdlib/assert-is-int8array': isArray
});
t.strictEqual( mocked(), false, 'detection result is `false`' );

mocked = proxyquire( './../dist/main.js', {
'./int8array.js': Mock4
});
t.strictEqual( mocked(), false, 'detection result is `false`' );

t.end();

function isArray() {
return true;
}

function Mock1() {
// Not a typed array:
return [];
}

function Mock2() {
// Does not truncate...
return [ 1, 3.14, -3.14, -128 ];
}

function Mock3() {
// Does not wrap around...
return [ 1, 3, -3, 128 ];
}

function Mock4() {
throw new Error( 'beep' );
}
});

0 comments on commit 8ef50ca

Please sign in to comment.