diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/README.md b/lib/node_modules/@stdlib/assert/has-float16array-support/README.md new file mode 100644 index 000000000000..1e0745943641 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/README.md @@ -0,0 +1,123 @@ + + +# Float16Array Support + +> Detect native [`Float16Array`][mdn-float16array] support. + +
+ +## Usage + +```javascript +var hasFloat16ArraySupport = require( '@stdlib/assert/has-float16array-support' ); +``` + +#### hasFloat16ArraySupport() + +Detects if a runtime environment supports [`Float16Array`][mdn-float16array]. + +```javascript +var bool = hasFloat16ArraySupport(); +// returns +``` + +
+ + + +
+ +## Examples + + + +```javascript +var hasFloat16ArraySupport = require( '@stdlib/assert/has-float16array-support' ); + +var bool = hasFloat16ArraySupport(); +if ( bool ) { + console.log( 'Environment has Float16Array support.' ); +} else { + console.log( 'Environment lacks Float16Array support.' ); +} +``` + +
+ + + +* * * + +
+ +## CLI + +
+ +### Usage + +```text +Usage: has-float16array-support [options] + +Options: + + -h, --help Print this message. + -V, --version Print the package version. +``` + +
+ + + +
+ +### Examples + +```bash +$ has-float16array-support + +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/has-float16array-support/benchmark/benchmark.js new file mode 100644 index 000000000000..9808661f514b --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/benchmark/benchmark.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var hasFloat16ArraySupport = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following *could* be optimized away via loop-invariant code motion. If so, the entire loop will disappear. + bool = hasFloat16ArraySupport(); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/bin/cli b/lib/node_modules/@stdlib/assert/has-float16array-support/bin/cli new file mode 100644 index 000000000000..8520ae55bf89 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/bin/cli @@ -0,0 +1,60 @@ +#!/usr/bin/env node + +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var readFileSync = require( '@stdlib/fs/read-file' ).sync; +var CLI = require( '@stdlib/cli/ctor' ); +var detect = require( './../lib' ); + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var flags; + var cli; + + // Create a command-line interface: + cli = new CLI({ + 'pkg': require( './../package.json' ), + 'options': require( './../etc/cli_opts.json' ), + 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { + 'encoding': 'utf8' + }) + }); + + // Get any provided command-line options: + flags = cli.flags(); + if ( flags.help || flags.version ) { + return; + } + + console.log( detect() ); // eslint-disable-line no-console +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/docs/repl.txt b/lib/node_modules/@stdlib/assert/has-float16array-support/docs/repl.txt new file mode 100644 index 000000000000..f1a03da90e60 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/docs/repl.txt @@ -0,0 +1,17 @@ + +{{alias}}() + Tests for native `Float16Array` support. + + Returns + ------- + bool: boolean + Boolean indicating if an environment has `Float16Array` support. + + Examples + -------- + > var bool = {{alias}}() + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/has-float16array-support/docs/types/index.d.ts new file mode 100644 index 000000000000..144600c2139f --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/docs/types/index.d.ts @@ -0,0 +1,35 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests for native `Float16Array` support. +* +* @returns boolean indicating if an environment has `Float16Array` support +* +* @example +* var bool = hasFloat16ArraySupport(); +* // returns +*/ +declare function hasFloat16ArraySupport(): boolean; + + +// EXPORTS // + +export = hasFloat16ArraySupport; diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/docs/types/test.ts b/lib/node_modules/@stdlib/assert/has-float16array-support/docs/types/test.ts new file mode 100644 index 000000000000..73e758e17015 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/docs/types/test.ts @@ -0,0 +1,33 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import hasFloat16ArraySupport = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + hasFloat16ArraySupport(); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided arguments... +{ + hasFloat16ArraySupport( true ); // $ExpectError + hasFloat16ArraySupport( [], 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/docs/usage.txt b/lib/node_modules/@stdlib/assert/has-float16array-support/docs/usage.txt new file mode 100644 index 000000000000..a982ba896460 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/docs/usage.txt @@ -0,0 +1,8 @@ + +Usage: has-float16array-support [options] + +Options: + + -h, --help Print this message. + -V, --version Print the package version. + diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/etc/cli_opts.json b/lib/node_modules/@stdlib/assert/has-float16array-support/etc/cli_opts.json new file mode 100644 index 000000000000..f245a17e6317 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/etc/cli_opts.json @@ -0,0 +1,14 @@ +{ + "boolean": [ + "help", + "version" + ], + "alias": { + "help": [ + "h" + ], + "version": [ + "V" + ] + } +} diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/examples/index.js b/lib/node_modules/@stdlib/assert/has-float16array-support/examples/index.js new file mode 100644 index 000000000000..b316e6ad9628 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/examples/index.js @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var hasFloat16ArraySupport = require( './../lib' ); + +var bool = hasFloat16ArraySupport(); +if ( bool ) { + console.log( 'Environment has Float16Array support.' ); +} else { + console.log( 'Environment lacks Float16Array support.' ); +} diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/lib/float16array.js b/lib/node_modules/@stdlib/assert/has-float16array-support/lib/float16array.js new file mode 100644 index 000000000000..816539c5a43d --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/lib/float16array.js @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +var main = ( typeof Float16Array === 'function' ) ? Float16Array : null; // eslint-disable-line no-undef, stdlib/require-globals + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/lib/index.js b/lib/node_modules/@stdlib/assert/has-float16array-support/lib/index.js new file mode 100644 index 000000000000..528001f17292 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/lib/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Test for native `Float16Array` support. +* +* @module @stdlib/assert/has-float16array-support +* +* @example +* var hasFloat16ArraySupport = require( '@stdlib/assert/has-float16array-support' ); +* +* var bool = hasFloat16ArraySupport(); +* // returns +*/ + +// MODULES // + +var hasFloat16ArraySupport = require( './main.js' ); + + +// EXPORTS // + +module.exports = hasFloat16ArraySupport; diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/lib/main.js b/lib/node_modules/@stdlib/assert/has-float16array-support/lib/main.js new file mode 100644 index 000000000000..94445e799009 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/lib/main.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isFloat16Array = require( '@stdlib/assert/is-float16array' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); // TODO: replace with `constants/float16/pinf` +var GlobalFloat16Array = require( './float16array.js' ); + + +// MAIN // + +/** +* Tests for native `Float16Array` support. +* +* @returns {boolean} boolean indicating if an environment has `Float16Array` support +* +* @example +* var bool = hasFloat16ArraySupport(); +* // returns +*/ +function hasFloat16ArraySupport() { + var bool; + var arr; + + if ( typeof GlobalFloat16Array !== 'function' ) { + return false; + } + // Test basic support... + try { + arr = new GlobalFloat16Array( [ 1.0, 3.14, -3.14, 5.0e40 ] ); + bool = ( + isFloat16Array( arr ) && + arr[ 0 ] === 1.0 && + arr[ 1 ] !== 3.14 && + arr[ 2 ] !== -3.14 && + arr[ 3 ] === PINF + ); + } catch ( err ) { // eslint-disable-line no-unused-vars + bool = false; + } + return bool; +} + + +// EXPORTS // + +module.exports = hasFloat16ArraySupport; diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/package.json b/lib/node_modules/@stdlib/assert/has-float16array-support/package.json new file mode 100644 index 000000000000..db270955f1a3 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/assert/has-float16array-support", + "version": "0.0.0", + "description": "Detect native Float16Array support.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "bin": { + "has-float16array-support": "./bin/cli" + }, + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdutils", + "stdutil", + "utilities", + "utility", + "utils", + "util", + "detect", + "feature", + "float16array", + "es2025", + "typed array", + "typed-array", + "support", + "has", + "native", + "issupported", + "cli" + ] +} diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/test/test.cli.js b/lib/node_modules/@stdlib/assert/has-float16array-support/test/test.cli.js new file mode 100644 index 000000000000..bbfbb40255b2 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/test/test.cli.js @@ -0,0 +1,162 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var exec = require( 'child_process' ).exec; +var tape = require( 'tape' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var IS_WINDOWS = require( '@stdlib/assert/is-windows' ); +var EXEC_PATH = require( '@stdlib/process/exec-path' ); +var readFileSync = require( '@stdlib/fs/read-file' ).sync; + + +// VARIABLES // + +var fpath = resolve( __dirname, '..', 'bin', 'cli' ); +var opts = { + 'skip': IS_BROWSER || IS_WINDOWS +}; + + +// FIXTURES // + +var PKG_VERSION = require( './../package.json' ).version; + + +// TESTS // + +tape( 'command-line interface', function test( t ) { + t.ok( true, __filename ); + t.end(); +}); + +tape( 'when invoked with a `--help` flag, the CLI prints the help text to `stderr`', opts, function test( t ) { + var expected; + var cmd; + + expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { + 'encoding': 'utf8' + }); + cmd = [ + EXEC_PATH, + fpath, + '--help' + ]; + + exec( cmd.join( ' ' ), done ); + + function done( error, stdout, stderr ) { + if ( error ) { + t.fail( error.message ); + } else { + t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); + t.strictEqual( stderr.toString(), expected+'\n', 'prints expected help text' ); + } + t.end(); + } +}); + +tape( 'when invoked with a `-h` flag, the CLI prints the help text to `stderr`', opts, function test( t ) { + var expected; + var cmd; + + expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { + 'encoding': 'utf8' + }); + cmd = [ + EXEC_PATH, + fpath, + '-h' + ]; + + exec( cmd.join( ' ' ), done ); + + function done( error, stdout, stderr ) { + if ( error ) { + t.fail( error.message ); + } else { + t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); + t.strictEqual( stderr.toString(), expected+'\n', 'prints expected help text' ); + } + t.end(); + } +}); + +tape( 'when invoked with a `--version` flag, the CLI prints the version to `stderr`', opts, function test( t ) { + var cmd = [ + EXEC_PATH, + fpath, + '--version' + ]; + + exec( cmd.join( ' ' ), done ); + + function done( error, stdout, stderr ) { + if ( error ) { + t.fail( error.message ); + } else { + t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); + t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'prints version to `stderr`' ); + } + t.end(); + } +}); + +tape( 'when invoked with a `-V` flag, the CLI prints the version to `stderr`', opts, function test( t ) { + var cmd = [ + EXEC_PATH, + fpath, + '-V' + ]; + + exec( cmd.join( ' ' ), done ); + + function done( error, stdout, stderr ) { + if ( error ) { + t.fail( error.message ); + } else { + t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); + t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'prints version to `stderr`' ); + } + t.end(); + } +}); + +tape( 'the CLI prints either `true` or `false` to `stdout` indicating native `Float16Array` support', opts, function test( t ) { + var cmd = [ + EXEC_PATH, + fpath + ]; + + exec( cmd.join( ' ' ), done ); + + function done( error, stdout, stderr ) { + var out = stdout.toString(); + if ( error ) { + t.fail( error.message ); + } else { + t.strictEqual( out === 'true\n' || out === 'false\n', true, 'prints either `true` or `false` to `stdout`' ); + t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); + } + t.end(); + } +}); diff --git a/lib/node_modules/@stdlib/assert/has-float16array-support/test/test.js b/lib/node_modules/@stdlib/assert/has-float16array-support/test/test.js new file mode 100644 index 000000000000..6c766f2b7edd --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-float16array-support/test/test.js @@ -0,0 +1,134 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var Number = require( '@stdlib/number/ctor' ); +var detect = require( './../lib' ); + + +// VARIABLES // + +var hasFloat16Array = ( typeof Float16Array === 'function' ); // eslint-disable-line stdlib/require-globals + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof detect, 'function', 'main export is a function' ); + 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 `Float16Array` is supported, detection result is `true`', function test( t ) { + var mocked; + if ( hasFloat16Array ) { + t.strictEqual( detect(), true, 'detection result is `true`' ); + } else { + t.strictEqual( detect(), false, 'detection result is `false`' ); + } + mocked = proxyquire( './../lib/main.js', { + './float16array.js': Mock, + '@stdlib/assert/is-float16array': isArray + }); + t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' ); + + t.end(); + + function isArray() { + return true; + } + + function Mock() { + return [ + 1.0, + 3.0, + -3.0, + Number.POSITIVE_INFINITY + ]; + } +}); + +tape( 'if `Float16Array` is not supported, detection result is `false`', function test( t ) { + var mocked; + if ( hasFloat16Array ) { + t.strictEqual( detect(), true, 'detection result is `true`' ); + } else { + t.strictEqual( detect(), false, 'detection result is `false`' ); + } + mocked = proxyquire( './../lib/main.js', { + './float16array.js': {} + }); + t.strictEqual( mocked(), false, 'detection result is `false`' ); + + mocked = proxyquire( './../lib/main.js', { + './float16array.js': Mock1 + }); + t.strictEqual( mocked(), false, 'detection result is `false`' ); + + mocked = proxyquire( './../lib/main.js', { + './float16array.js': Mock2, + '@stdlib/assert/is-float16array': isArray + }); + t.strictEqual( mocked(), false, 'detection result is `false`' ); + + mocked = proxyquire( './../lib/main.js', { + './float16array.js': Mock3, + '@stdlib/assert/is-float16array': isArray + }); + t.strictEqual( mocked(), false, 'detection result is `false`' ); + + mocked = proxyquire( './../lib/main.js', { + './float16array.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 lose precision... + return [ 1.0, 3.14, -3.14, Number.POSITIVE_INFINITY ]; + } + + function Mock3() { + // Does not overflow... + return [ 1.0, 3.140625, -3.140625, 5.0e40 ]; + } + + function Mock4() { + throw new Error( 'beep' ); + } +});