From 8ca73f54eca7ac7efa7c0944e9339cbdb10d4eaf Mon Sep 17 00:00:00 2001 From: Uday Kakade Date: Mon, 13 Apr 2026 22:47:44 +0530 Subject: [PATCH] Add missing test files in array/float64 --- .../@stdlib/array/float64/test/test.at.js | 112 +++++++++++ .../array/float64/test/test.entries.js | 116 +++++++++++ .../@stdlib/array/float64/test/test.every.js | 174 ++++++++++++++++ .../@stdlib/array/float64/test/test.fill.js | 171 ++++++++++++++++ .../@stdlib/array/float64/test/test.filter.js | 182 +++++++++++++++++ .../@stdlib/array/float64/test/test.find.js | 174 ++++++++++++++++ .../array/float64/test/test.find_index.js | 174 ++++++++++++++++ .../array/float64/test/test.find_last.js | 174 ++++++++++++++++ .../float64/test/test.find_last_index.js | 174 ++++++++++++++++ .../array/float64/test/test.for_each.js | 175 ++++++++++++++++ .../@stdlib/array/float64/test/test.from.js | 178 +++++++++++++++++ .../array/float64/test/test.includes.js | 162 +++++++++++++++ .../array/float64/test/test.index_of.js | 162 +++++++++++++++ .../@stdlib/array/float64/test/test.join.js | 130 ++++++++++++ .../@stdlib/array/float64/test/test.keys.js | 149 ++++++++++++++ .../array/float64/test/test.last_index_of.js | 137 +++++++++++++ .../@stdlib/array/float64/test/test.map.js | 169 ++++++++++++++++ .../@stdlib/array/float64/test/test.of.js | 81 ++++++++ .../@stdlib/array/float64/test/test.reduce.js | 188 ++++++++++++++++++ .../array/float64/test/test.reduce_right.js | 184 +++++++++++++++++ .../array/float64/test/test.reverse.js | 110 ++++++++++ .../@stdlib/array/float64/test/test.set.js | 130 ++++++++++++ .../@stdlib/array/float64/test/test.slice.js | 141 +++++++++++++ .../@stdlib/array/float64/test/test.some.js | 174 ++++++++++++++++ .../@stdlib/array/float64/test/test.sort.js | 182 +++++++++++++++++ .../array/float64/test/test.subarray.js | 128 ++++++++++++ .../float64/test/test.to_locale_string.js | 95 +++++++++ .../array/float64/test/test.to_reversed.js | 128 ++++++++++++ .../array/float64/test/test.to_sorted.js | 178 +++++++++++++++++ .../array/float64/test/test.to_string.js | 67 +++++++ .../@stdlib/array/float64/test/test.values.js | 149 ++++++++++++++ .../@stdlib/array/float64/test/test.with.js | 153 ++++++++++++++ 32 files changed, 4801 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.at.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.entries.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.every.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.fill.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.filter.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.find.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.find_index.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.find_last.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.find_last_index.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.for_each.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.from.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.includes.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.index_of.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.join.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.keys.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.last_index_of.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.map.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.of.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.reduce.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.reduce_right.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.reverse.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.set.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.slice.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.some.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.sort.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.subarray.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.to_locale_string.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.to_reversed.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.to_sorted.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.to_string.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.values.js create mode 100644 lib/node_modules/@stdlib/array/float64/test/test.with.js diff --git a/lib/node_modules/@stdlib/array/float64/test/test.at.js b/lib/node_modules/@stdlib/array/float64/test/test.at.js new file mode 100644 index 000000000000..73c2466ff06e --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.at.js @@ -0,0 +1,112 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has an `at` method for returning an array element', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'at' ), true, 'has property' ); + t.strictEqual( isFunction( arr.at ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.at.call( value, 0 ); + }; + } +}); + +tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { + var arr; + var v; + var i; + + arr = new Float64Array( 10 ); + for ( i = -arr.length; i < arr.length; i++ ) { + if ( i < 0 ) { + v = arr.at( i - arr.length ); + t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); + } else { + v = arr.at( arr.length + i ); + t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); + } + } + t.end(); +}); + +tape( 'the method returns an array element', function test( t ) { + var arr; + var v; + var i; + + arr = new Float64Array( 10 ); + for ( i = 0; i < arr.length; i++ ) { + arr[ i ] = i * 2.0; + } + + for ( i = -arr.length; i < arr.length; i++ ) { + v = arr.at( i ); + if ( i < 0 ) { + t.strictEqual( v, ( arr.length + i ) * 2.0, 'returns expected value for index '+i ); + } else { + t.strictEqual( v, i * 2.0, 'returns expected value for index '+i ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.entries.js b/lib/node_modules/@stdlib/array/float64/test/test.entries.js new file mode 100644 index 000000000000..715adf6b5d92 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.entries.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isArray = require( '@stdlib/assert/is-array' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'entries' ), true, 'has property' ); + t.strictEqual( isFunction( arr.entries ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.entries.call( value ); + }; + } +}); + +tape( 'the method returns an iterator protocol-compliant object', function test( t ) { + var arr; + var it; + var v; + var i; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + it = arr.entries(); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < arr.length; i++ ) { + v = it.next(); + t.strictEqual( isArray( v.value ), true, 'returns expected value' ); + t.strictEqual( v.value[ 0 ], i, 'returns expected index' ); + t.strictEqual( v.value[ 1 ], arr[ i ], 'returns expected value' ); + t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); + } + t.end(); +}); + +tape( 'the method returns an iterator which indicates completion once all elements have been iterated', function test( t ) { + var arr; + var it; + var v; + + arr = new Float64Array( [ 1.0, 2.0 ] ); + it = arr.entries(); + + v = it.next(); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.done, true, 'returns expected value' ); + t.strictEqual( v.value, void 0, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.every.js b/lib/node_modules/@stdlib/array/float64/test/test.every.js new file mode 100644 index 000000000000..9098da8fea32 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.every.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has an `every` method for testing whether all elements pass a provided predicate function', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'every' ), true, 'has property' ); + t.strictEqual( isFunction( arr.every ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.every.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.every( value ); + }; + } +}); + +tape( 'the method returns `true` if operating on an empty typed array', function test( t ) { + var bool; + var arr; + + arr = new Float64Array(); + bool = arr.every( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `true` if all elements pass a test', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + bool = arr.every( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ 1.0, -2.0, 3.0 ] ); + bool = arr.every( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var bool; + var ctx; + var arr; + + ctx = { + 'count': 0 + }; + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + bool = arr.every( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( v > 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.fill.js b/lib/node_modules/@stdlib/array/float64/test/test.fill.js new file mode 100644 index 000000000000..ef9861d99e97 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.fill.js @@ -0,0 +1,171 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `fill` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'fill' ), true, 'has property' ); + t.strictEqual( isFunction( arr.fill ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.fill.call( value, 1.0 ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.fill( 1.0 ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new Float64Array( 10 ); + out = arr.fill( 1.0 ); + + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { + var arr; + var i; + + arr = new Float64Array( 3 ); + arr.fill( 5.0 ); + + for ( i = 0; i < arr.length; i++ ) { + t.strictEqual( arr[ i ], 5.0, 'returns expected value' ); + } + t.end(); +}); + +tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { + var arr; + + arr = new Float64Array( 3 ); + arr.fill( 5.0, 1 ); + + t.strictEqual( arr[ 0 ], 0.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 5.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 5.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with three arguments, the method sets each array element to the provided value from a start index (inclusive) to an end index (exclusive)', function test( t ) { + var arr; + + arr = new Float64Array( 3 ); + arr.fill( 5.0, 0, 2 ); + + t.strictEqual( arr[ 0 ], 5.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 5.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports negative indices', function test( t ) { + var arr; + + arr = new Float64Array( 3 ); + arr.fill( 5.0, -3, -1 ); + + t.strictEqual( arr[ 0 ], 5.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 5.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { + var arr; + var i; + + arr = new Float64Array( 3 ); + arr.fill( 5.0, -10 ); + + for ( i = 0; i < arr.length; i++ ) { + t.strictEqual( arr[ i ], 5.0, 'returns expected value' ); + } + t.end(); +}); + +tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills until the last element (inclusive)', function test( t ) { + var arr; + + arr = new Float64Array( 3 ); + arr.fill( 5.0, 1, 10 ); + + t.strictEqual( arr[ 0 ], 0.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 5.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 5.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.filter.js b/lib/node_modules/@stdlib/array/float64/test/test.filter.js new file mode 100644 index 000000000000..caa857db56ed --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.filter.js @@ -0,0 +1,182 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `filter` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'filter' ), true, 'has property' ); + t.strictEqual( isFunction( arr.filter ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.filter.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.filter( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.filter( predicate ); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method returns a new typed array containing only those elements which satisfy a test condition', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] ); + actual = arr.filter( predicate ); + + t.strictEqual( actual instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( actual.length, 2, 'returns expected value' ); + t.strictEqual( actual[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( actual[ 1 ], 3.0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + actual = arr.filter( predicate ); + + t.strictEqual( actual instanceof Float64Array, true, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + t.strictEqual( actual.length, 3, 'returns expected value' ); + t.strictEqual( actual[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( actual[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( actual[ 2 ], 3.0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var actual; + var arr; + var ctx; + + arr = new Float64Array( [ 1.0, -2.0, 3.0 ] ); + ctx = { + 'count': 0 + }; + actual = arr.filter( predicate, ctx ); + + t.strictEqual( actual instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( actual.length, 2, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( v > 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.find.js b/lib/node_modules/@stdlib/array/float64/test/test.find.js new file mode 100644 index 000000000000..ec547631a935 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.find.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `find` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'find' ), true, 'has property' ); + t.strictEqual( isFunction( arr.find ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.find.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( v > 2.0 ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.find( value ); + }; + } +}); + +tape( 'the method returns `undefined` if operating on an empty typed array', function test( t ) { + var arr; + var v; + + arr = new Float64Array(); + v = arr.find( predicate ); + + t.strictEqual( v, void 0, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the first element which passes a test', function test( t ) { + var arr; + var v; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + v = arr.find( predicate ); + + t.strictEqual( v, 3.0, 'returns expected value' ); + t.end(); + + function predicate( val ) { + return ( val > 2.0 ); + } +}); + +tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { + var arr; + var v; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + v = arr.find( predicate ); + + t.strictEqual( v, void 0, 'returns expected value' ); + t.end(); + + function predicate( val ) { + return ( val > 10.0 ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + var v; + + ctx = { + 'count': 0 + }; + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + v = arr.find( predicate, ctx ); + + t.strictEqual( v, 3.0, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function predicate( val ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( val > 2.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.find_index.js b/lib/node_modules/@stdlib/array/float64/test/test.find_index.js new file mode 100644 index 000000000000..25ab4716495a --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.find_index.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `findIndex` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'findIndex' ), true, 'has property' ); + t.strictEqual( isFunction( arr.findIndex ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findIndex.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( v > 2.0 ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findIndex( value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty typed array', function test( t ) { + var arr; + var idx; + + arr = new Float64Array(); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the index of the first element which passes a test', function test( t ) { + var arr; + var idx; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 2.0 ); + } +}); + +tape( 'the method returns `-1` if all elements fail a test', function test( t ) { + var arr; + var idx; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 10.0 ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + var idx; + + ctx = { + 'count': 0 + }; + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + idx = arr.findIndex( predicate, ctx ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( v > 2.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.find_last.js b/lib/node_modules/@stdlib/array/float64/test/test.find_last.js new file mode 100644 index 000000000000..7991c23c1d51 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.find_last.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `findLast` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'findLast' ), true, 'has property' ); + t.strictEqual( isFunction( arr.findLast ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findLast.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( v > 2.0 ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findLast( value ); + }; + } +}); + +tape( 'the method returns `undefined` if operating on an empty typed array', function test( t ) { + var arr; + var v; + + arr = new Float64Array(); + v = arr.findLast( predicate ); + + t.strictEqual( v, void 0, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the last element which passes a test', function test( t ) { + var arr; + var v; + + arr = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); + v = arr.findLast( predicate ); + + t.strictEqual( v, 4.0, 'returns expected value' ); + t.end(); + + function predicate( val ) { + return ( val > 2.0 ); + } +}); + +tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { + var arr; + var v; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + v = arr.findLast( predicate ); + + t.strictEqual( v, void 0, 'returns expected value' ); + t.end(); + + function predicate( val ) { + return ( val > 10.0 ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + var v; + + ctx = { + 'count': 0 + }; + arr = new Float64Array( [ 3.0, 1.0, 2.0, 1.0 ] ); + v = arr.findLast( predicate, ctx ); + + t.strictEqual( v, 3.0, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + t.end(); + + function predicate( val ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( val > 2.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.find_last_index.js b/lib/node_modules/@stdlib/array/float64/test/test.find_last_index.js new file mode 100644 index 000000000000..8c6a6a8849e1 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.find_last_index.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `findLastIndex` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'findLastIndex' ), true, 'has property' ); + t.strictEqual( isFunction( arr.findLastIndex ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findLastIndex.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( v > 2.0 ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findLastIndex( value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty typed array', function test( t ) { + var arr; + var idx; + + arr = new Float64Array(); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the index of the last element which passes a test', function test( t ) { + var arr; + var idx; + + arr = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 2.0 ); + } +}); + +tape( 'the method returns `-1` if all elements fail a test', function test( t ) { + var arr; + var idx; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 10.0 ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + var idx; + + ctx = { + 'count': 0 + }; + arr = new Float64Array( [ 3.0, 1.0, 2.0, 1.0 ] ); + idx = arr.findLastIndex( predicate, ctx ); + + t.strictEqual( idx, 0, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( v > 2.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.for_each.js b/lib/node_modules/@stdlib/array/float64/test/test.for_each.js new file mode 100644 index 000000000000..f8d6540fdc21 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.for_each.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `forEach` method for iterating over each element', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'forEach' ), true, 'has property' ); + t.strictEqual( isFunction( arr.forEach ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.forEach.call( value, fcn ); + }; + } + + function fcn() { + // no-op + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.forEach( value ); + }; + } +}); + +tape( 'the method should not invoke a provided callback function if operating on an empty typed array', function test( t ) { + var arr; + + arr = new Float64Array(); + arr.forEach( fcn ); + + t.end(); + + function fcn() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method invokes a provided function for each element', function test( t ) { + var count; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + count = 0; + + arr.forEach( function fcn( v, i ) { + t.strictEqual( typeof v, 'number', 'returns expected value' ); + t.strictEqual( v, arr[ i ], 'returns expected value' ); + count += 1; + }); + + t.strictEqual( count, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the method invokes a provided function with the correct arguments', function test( t ) { + var indices; + var values; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + indices = []; + values = []; + + arr.forEach( function fcn( v, i ) { + values.push( v ); + indices.push( i ); + }); + + t.deepEqual( values, [ 1.0, 2.0, 3.0 ], 'returns expected value' ); + t.deepEqual( indices, [ 0, 1, 2 ], 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + + ctx = { + 'count': 0 + }; + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + arr.forEach( fcn, ctx ); + + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function fcn() { + this.count += 1; // eslint-disable-line no-invalid-this + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.from.js b/lib/node_modules/@stdlib/array/float64/test/test.from.js new file mode 100644 index 000000000000..b7c23122b6e7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.from.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a `from` method for creating a typed array from an array-like object or iterable', function test( t ) { + t.strictEqual( hasProp( Float64Array, 'from' ), true, 'has property' ); + t.strictEqual( isFunction( Float64Array.from ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { + var values; + var i; + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return Float64Array.from( [], value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { + var values; + var i; + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return Float64Array.from( [], value, {} ); + }; + } +}); + +tape( 'the method returns an empty typed array if provided an empty array', function test( t ) { + var arr; + var out; + + arr = []; + out = Float64Array.from( arr ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method creates a typed array from an array-like object', function test( t ) { + var arr; + var out; + + arr = [ 1.0, 2.0, 3.0 ]; + out = Float64Array.from( arr ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method creates a typed array from another typed array', function test( t ) { + var src; + var out; + + src = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = Float64Array.from( src ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.notEqual( out, src, 'returns a new instance' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports a map function', function test( t ) { + var arr; + var out; + + arr = [ 1.0, 2.0, 3.0 ]; + out = Float64Array.from( arr, mapFn ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 4.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 6.0, 'returns expected value' ); + t.end(); + + function mapFn( v ) { + return v * 2.0; + } +}); + +tape( 'the method supports providing an execution context for the map function', function test( t ) { + var ctx; + var arr; + var out; + + arr = [ 1.0, 2.0, 3.0 ]; + ctx = { + 'multiplier': 3.0 + }; + out = Float64Array.from( arr, mapFn, ctx ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 6.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 9.0, 'returns expected value' ); + t.end(); + + function mapFn( v ) { + return v * this.multiplier; // eslint-disable-line no-invalid-this + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.includes.js b/lib/node_modules/@stdlib/array/float64/test/test.includes.js new file mode 100644 index 000000000000..a388d74dad7e --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.includes.js @@ -0,0 +1,162 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has an `includes` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'includes' ), true, 'has property' ); + t.strictEqual( isFunction( arr.includes ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.includes.call( value, 1.0 ); + }; + } +}); + +tape( 'the method returns `false` if operating on an empty typed array', function test( t ) { + var bool; + var arr; + + arr = new Float64Array(); + bool = arr.includes( 1.0 ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `false` if a value is not found', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + bool = arr.includes( 10.0 ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `true` if an array contains a specified value', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + bool = arr.includes( 2.0 ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + bool = arr.includes( 1.0, 20 ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0 ] ); + + bool = arr.includes( 2.0, 0 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( 2.0, 2 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( 1.0, 2 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative)', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0 ] ); + + bool = arr.includes( 2.0, -4 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( 4.0, -2 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index less than zero, the method searches from the first array element', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + bool = arr.includes( 1.0, -10 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( 4.0, -10 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.index_of.js b/lib/node_modules/@stdlib/array/float64/test/test.index_of.js new file mode 100644 index 000000000000..1f6977e57789 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.index_of.js @@ -0,0 +1,162 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has an `indexOf` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'indexOf' ), true, 'has property' ); + t.strictEqual( isFunction( arr.indexOf ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.indexOf.call( value, 1.0 ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty typed array', function test( t ) { + var arr; + var idx; + + arr = new Float64Array(); + idx = arr.indexOf( 1.0 ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if a value is not found', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + idx = arr.indexOf( 10.0 ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the index of the first match', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 5.0 ] ); + idx = arr.indexOf( 2.0 ); + + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + idx = arr.indexOf( 1.0, 20 ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 4.0 ] ); + + idx = arr.indexOf( 2.0, 0 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( 2.0, 2 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.indexOf( 3.0, 3 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative)', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 2.0 ] ); + + idx = arr.indexOf( 2.0, -5 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( 4.0, -2 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index less than zero, the method searches from the first array element', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 2.0 ] ); + + idx = arr.indexOf( 2.0, -10 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( 4.0, -10 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.join.js b/lib/node_modules/@stdlib/array/float64/test/test.join.js new file mode 100644 index 000000000000..454119eb2da3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.join.js @@ -0,0 +1,130 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `join` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'join' ), true, 'has property' ); + t.strictEqual( isFunction( arr.join ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.join.call( value ); + }; + } +}); + +tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { + var str; + var arr; + + arr = new Float64Array(); + str = arr.join(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of the array with elements separated by a comma (default)', function test( t ) { + var expected; + var str; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + expected = '1,2,3'; + + str = arr.join(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation with elements separated by a provided separator', function test( t ) { + var expected; + var str; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + expected = '1@2@3'; + + str = arr.join( '@' ); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation for a single element array', function test( t ) { + var expected; + var str; + var arr; + + arr = new Float64Array( [ 5.0 ] ); + expected = '5'; + + str = arr.join(); + + t.strictEqual( str, expected, 'returns expected value' ); + + str = arr.join( '@' ); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.keys.js b/lib/node_modules/@stdlib/array/float64/test/test.keys.js new file mode 100644 index 000000000000..b5fff9bb0bf6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.keys.js @@ -0,0 +1,149 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `keys` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'keys' ), true, 'has property' ); + t.strictEqual( isFunction( arr.keys ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.keys.call( value ); + }; + } +}); + +tape( 'the method returns an iterator protocol-compliant object', function test( t ) { + var expected; + var arr; + var it; + var i; + var r; + var e; + + arr = new Float64Array( [ 1.0, 2.0 ] ); + expected = [ + { + 'value': 0, + 'done': false + }, + { + 'value': 1, + 'done': false + }, + { + 'value': void 0, + 'done': true + } + ]; + it = arr.keys(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + r = it.next(); + e = expected[ i ]; + if ( e.value === void 0 ) { + t.deepEqual( r, e, 'returns expected value' ); + } else { + t.strictEqual( r.value, e.value, 'returns expected value' ); + t.strictEqual( r.done, e.done, 'returns expected value' ); + } + } + + t.end(); +}); + +tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { + var expected; + var arr; + var it; + var i; + var v; + + arr = new Float64Array( [] ); + expected = [ + { + 'value': void 0, + 'done': true + }, + { + 'value': void 0, + 'done': true + }, + { + 'value': void 0, + 'done': true + } + ]; + it = arr.keys(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + v = it.next(); + t.deepEqual( v, expected[ i ], 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.last_index_of.js b/lib/node_modules/@stdlib/array/float64/test/test.last_index_of.js new file mode 100644 index 000000000000..ff0918ded42f --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.last_index_of.js @@ -0,0 +1,137 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `lastIndexOf` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'lastIndexOf' ), true, 'has property' ); + t.strictEqual( isFunction( arr.lastIndexOf ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.lastIndexOf.call( value, 1.0 ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty typed array', function test( t ) { + var arr; + var idx; + + arr = new Float64Array(); + idx = arr.lastIndexOf( 1.0 ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if a value is not found', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + idx = arr.lastIndexOf( 10.0 ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the index of the last match', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 5.0 ] ); + idx = arr.lastIndexOf( 2.0 ); + + t.strictEqual( idx, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 4.0 ] ); + + idx = arr.lastIndexOf( 2.0, 4 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.lastIndexOf( 2.0, 2 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.lastIndexOf( 3.0, 1 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative)', function test( t ) { + var idx; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 2.0 ] ); + + idx = arr.lastIndexOf( 2.0, -1 ); + t.strictEqual( idx, 4, 'returns expected value' ); + + idx = arr.lastIndexOf( 2.0, -3 ); + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.map.js b/lib/node_modules/@stdlib/array/float64/test/test.map.js new file mode 100644 index 000000000000..824a30701dea --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.map.js @@ -0,0 +1,169 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `map` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'map' ), true, 'has property' ); + t.strictEqual( isFunction( arr.map ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.map.call( value, scale ); + }; + } + + function scale( v ) { + return v * 2.0; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.map( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.map( scale ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.end(); + + function scale( v ) { + return v * 2.0; + } +}); + +tape( 'the method returns a new typed array containing elements which are the result of a callback function', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + actual = arr.map( scale ); + + t.strictEqual( actual instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( actual.length, 3, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + t.strictEqual( actual[ 0 ], 2.0, 'returns expected value' ); + t.strictEqual( actual[ 1 ], 4.0, 'returns expected value' ); + t.strictEqual( actual[ 2 ], 6.0, 'returns expected value' ); + t.end(); + + function scale( v ) { + return v * 2.0; + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var actual; + var arr; + var ctx; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + ctx = { + 'count': 0 + }; + actual = arr.map( scale, ctx ); + + t.strictEqual( actual instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( actual.length, 3, 'returns expected value' ); + t.strictEqual( actual[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( actual[ 1 ], 6.0, 'returns expected value' ); + t.strictEqual( actual[ 2 ], 9.0, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function scale( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v * 3.0; + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.of.js b/lib/node_modules/@stdlib/array/float64/test/test.of.js new file mode 100644 index 000000000000..b54f4b95309d --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.of.js @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `of` method for creating a typed array from a variable number of arguments', function test( t ) { + var arr; + + t.strictEqual( hasProp( Float64Array, 'of' ), true, 'has property' ); + t.strictEqual( isFunction( Float64Array.of ), true, 'has method' ); + + arr = Float64Array.of(); + t.strictEqual( arr instanceof Float64Array, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method creates an empty typed array if called with no arguments', function test( t ) { + var arr; + + arr = Float64Array.of(); + + t.strictEqual( arr instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method creates a typed array from a variable number of arguments', function test( t ) { + var arr; + + arr = Float64Array.of( 1.0, 2.0, 3.0 ); + + t.strictEqual( arr instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( arr.length, 3, 'returns expected value' ); + t.strictEqual( arr[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method creates a typed array from a single argument', function test( t ) { + var arr; + + arr = Float64Array.of( 5.0 ); + + t.strictEqual( arr instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( arr.length, 1, 'returns expected value' ); + t.strictEqual( arr[ 0 ], 5.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.reduce.js b/lib/node_modules/@stdlib/array/float64/test/test.reduce.js new file mode 100644 index 000000000000..76bd9ec066cb --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.reduce.js @@ -0,0 +1,188 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `reduce` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'reduce' ), true, 'has property' ); + t.strictEqual( isFunction( arr.reduce ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.reduce.call( value, add ); + }; + } + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.reduce( value ); + }; + } +}); + +tape( 'the method throws an error if not provided an initial value when operating on an empty typed array', function test( t ) { + var arr; + + arr = new Float64Array( 0 ); + t.throws( foo, TypeError, 'throws an error' ); + t.end(); + + function foo() { + arr.reduce( add ); + } + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the method uses the first element as the initial value when no initial value is provided', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + actual = arr.reduce( add ); + + t.strictEqual( actual, 6.0, 'returns expected value' ); + t.end(); + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the method supports providing an initial value as the second argument', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + actual = arr.reduce( add, 10.0 ); + + t.strictEqual( actual, 16.0, 'returns expected value' ); + t.end(); + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the method returns the accumulated result', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + actual = arr.reduce( add ); + + t.strictEqual( actual, 10.0, 'returns expected value' ); + t.end(); + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the callback receives the accumulator, current value, and index as arguments', function test( t ) { + var indices; + var values; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + indices = []; + values = []; + + arr.reduce( function reducer( acc, v, i ) { + values.push( v ); + indices.push( i ); + return acc + v; + }, 0.0 ); + + t.deepEqual( values, [ 1.0, 2.0, 3.0 ], 'returns expected value' ); + t.deepEqual( indices, [ 0, 1, 2 ], 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.reduce_right.js b/lib/node_modules/@stdlib/array/float64/test/test.reduce_right.js new file mode 100644 index 000000000000..0797d6c6783d --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.reduce_right.js @@ -0,0 +1,184 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `reduceRight` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'reduceRight' ), true, 'has property' ); + t.strictEqual( isFunction( arr.reduceRight ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.reduceRight.call( value, add ); + }; + } + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.reduceRight( value ); + }; + } +}); + +tape( 'the method throws an error if not provided an initial value when operating on an empty typed array', function test( t ) { + var arr; + + arr = new Float64Array( 0 ); + t.throws( foo, TypeError, 'throws an error' ); + t.end(); + + function foo() { + arr.reduceRight( add ); + } + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the method uses the last element as the initial value when no initial value is provided', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + actual = arr.reduceRight( add ); + + t.strictEqual( actual, 6.0, 'returns expected value' ); + t.end(); + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the method supports providing an initial value as the second argument', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + actual = arr.reduceRight( add, 10.0 ); + + t.strictEqual( actual, 16.0, 'returns expected value' ); + t.end(); + + function add( acc, v ) { + return acc + v; + } +}); + +tape( 'the method iterates from right to left', function test( t ) { + var values; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + values = []; + + arr.reduceRight( function reducer( acc, v ) { + values.push( v ); + return acc + v; + }, 0.0 ); + + t.deepEqual( values, [ 3.0, 2.0, 1.0 ], 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the accumulated result', function test( t ) { + var actual; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + actual = arr.reduceRight( add ); + + t.strictEqual( actual, 10.0, 'returns expected value' ); + t.end(); + + function add( acc, v ) { + return acc + v; + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.reverse.js b/lib/node_modules/@stdlib/array/float64/test/test.reverse.js new file mode 100644 index 000000000000..73b24e543035 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.reverse.js @@ -0,0 +1,110 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `reverse` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'reverse' ), true, 'has property' ); + t.strictEqual( isFunction( arr.reverse ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.reverse.call( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.reverse(); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method reverses elements of a typed array in-place', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = arr.reverse(); + + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 1.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new Float64Array( 10 ); + out = arr.reverse(); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.set.js b/lib/node_modules/@stdlib/array/float64/test/test.set.js new file mode 100644 index 000000000000..135816ece75a --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.set.js @@ -0,0 +1,130 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `set` method for setting one or more array elements', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.set.call( value, [ 1.0 ] ); + }; + } +}); + +tape( 'the method sets array elements from an array-like object', function test( t ) { + var arr; + + arr = new Float64Array( 5 ); + arr.set( [ 1.0, 2.0, 3.0 ] ); + + t.strictEqual( arr[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 3.0, 'returns expected value' ); + t.strictEqual( arr[ 3 ], 0.0, 'returns expected value' ); + t.strictEqual( arr[ 4 ], 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method sets array elements from another typed array', function test( t ) { + var src; + var arr; + + arr = new Float64Array( 5 ); + src = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + arr.set( src ); + + t.strictEqual( arr[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 3.0, 'returns expected value' ); + t.strictEqual( arr[ 3 ], 0.0, 'returns expected value' ); + t.strictEqual( arr[ 4 ], 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports an offset argument', function test( t ) { + var arr; + + arr = new Float64Array( 5 ); + arr.set( [ 1.0, 2.0, 3.0 ], 2 ); + + t.strictEqual( arr[ 0 ], 0.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 0.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 1.0, 'returns expected value' ); + t.strictEqual( arr[ 3 ], 2.0, 'returns expected value' ); + t.strictEqual( arr[ 4 ], 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws a RangeError if the provided offset and source length would exceed the array bounds', function test( t ) { + var arr; + + arr = new Float64Array( 5 ); + + t.throws( badValue, RangeError, 'throws a range error' ); + t.end(); + + function badValue() { + arr.set( [ 1.0, 2.0, 3.0 ], 4 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.slice.js b/lib/node_modules/@stdlib/array/float64/test/test.slice.js new file mode 100644 index 000000000000..b62f6072ea1c --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.slice.js @@ -0,0 +1,141 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `slice` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'slice' ), true, 'has property' ); + t.strictEqual( isFunction( arr.slice ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.slice.call( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.slice(); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a copy of the entire array if called with no arguments', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = arr.slice(); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a slice of the array', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + out = arr.slice( 1, 4 ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 4.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports negative indices', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + out = arr.slice( -3, -1 ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( out[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 4.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned slice does not share the same buffer as the original array', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = arr.slice(); + + t.notEqual( out.buffer, arr.buffer, 'does not share buffer' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.some.js b/lib/node_modules/@stdlib/array/float64/test/test.some.js new file mode 100644 index 000000000000..1f18e90dbddd --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.some.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `some` method for testing whether at least one element passes a provided predicate function', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'some' ), true, 'has property' ); + t.strictEqual( isFunction( arr.some ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.some.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.some( value ); + }; + } +}); + +tape( 'the method returns `false` if operating on an empty typed array', function test( t ) { + var bool; + var arr; + + arr = new Float64Array(); + bool = arr.some( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `true` if at least one element passes a test', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ -1.0, -2.0, 3.0 ] ); + bool = arr.some( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method returns `false` if all elements fail a test', function test( t ) { + var bool; + var arr; + + arr = new Float64Array( [ -1.0, -2.0, -3.0 ] ); + bool = arr.some( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( v > 0.0 ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var bool; + var ctx; + var arr; + + ctx = { + 'count': 0 + }; + arr = new Float64Array( [ -1.0, -2.0, 3.0 ] ); + bool = arr.some( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( v > 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.sort.js b/lib/node_modules/@stdlib/array/float64/test/test.sort.js new file mode 100644 index 000000000000..5a84d4bde36e --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.sort.js @@ -0,0 +1,182 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Comparison function. +* +* @private +* @param {number} a - first value for comparison +* @param {number} b - second value for comparison +* @returns {number} comparison result +*/ +function compareFcn( a, b ) { + if ( a < b ) { + return -1; + } + if ( a > b ) { + return 1; + } + return 0; +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `sort` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'sort' ), true, 'has property' ); + t.strictEqual( isFunction( arr.sort ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.sort.call( value, compareFcn ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.sort( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.sort( compareFcn ); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method sorts elements of a typed array in-place', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 3.0, 1.0, 2.0 ] ); + out = arr.sort( compareFcn ); + + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 3.0, 1.0, 2.0 ] ); + out = arr.sort( compareFcn ); + + t.strictEqual( out.length, arr.length, 'returns expected value' ); + t.end(); +}); + +tape( 'the method sorts elements using a provided comparison function in descending order', function test( t ) { + var arr; + + arr = new Float64Array( [ 3.0, 1.0, 2.0 ] ); + arr.sort( descend ); + + t.strictEqual( arr[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( arr[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( arr[ 2 ], 1.0, 'returns expected value' ); + t.end(); + + function descend( a, b ) { + if ( a > b ) { + return -1; + } + if ( a < b ) { + return 1; + } + return 0; + } +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.subarray.js b/lib/node_modules/@stdlib/array/float64/test/test.subarray.js new file mode 100644 index 000000000000..2e4d8548f58f --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.subarray.js @@ -0,0 +1,128 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `subarray` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'subarray' ), true, 'has property' ); + t.strictEqual( isFunction( arr.subarray ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.subarray.call( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.subarray(); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a view of the same underlying buffer', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + out = arr.subarray( 1, 4 ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.buffer, arr.buffer, 'shares the same buffer' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 4.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a subarray sharing the same buffer (no arguments)', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = arr.subarray(); + + t.strictEqual( out.buffer, arr.buffer, 'shares the same buffer' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports negative indices', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + out = arr.subarray( -3, -1 ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.buffer, arr.buffer, 'shares the same buffer' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( out[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 4.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.to_locale_string.js b/lib/node_modules/@stdlib/array/float64/test/test.to_locale_string.js new file mode 100644 index 000000000000..c7fb7cb8dc0f --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.to_locale_string.js @@ -0,0 +1,95 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `toLocaleString` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'toLocaleString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toLocaleString ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.toLocaleString.call( value ); + }; + } +}); + +tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { + var str; + var arr; + + arr = new Float64Array(); + str = arr.toLocaleString(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a locale string representation of a typed array', function test( t ) { + var str; + var arr; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + str = arr.toLocaleString(); + + t.strictEqual( typeof str, 'string', 'returns a string' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.to_reversed.js b/lib/node_modules/@stdlib/array/float64/test/test.to_reversed.js new file mode 100644 index 000000000000..d02b7c18b926 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.to_reversed.js @@ -0,0 +1,128 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `toReversed` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'toReversed' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toReversed ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.toReversed.call( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.toReversed(); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new typed array containing elements in reverse order', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = arr.toReversed(); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 1.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new Float64Array( 10 ); + out = arr.toReversed(); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not mutate the original array', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = arr.toReversed(); + + t.strictEqual( arr[ 0 ], 1.0, 'original is unchanged' ); + t.strictEqual( arr[ 1 ], 2.0, 'original is unchanged' ); + t.strictEqual( arr[ 2 ], 3.0, 'original is unchanged' ); + t.strictEqual( out[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 1.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.to_sorted.js b/lib/node_modules/@stdlib/array/float64/test/test.to_sorted.js new file mode 100644 index 000000000000..ae654e24f655 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.to_sorted.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Comparison function. +* +* @private +* @param {number} a - first value for comparison +* @param {number} b - second value for comparison +* @returns {number} comparison result +*/ +function compareFcn( a, b ) { + if ( a < b ) { + return -1; + } + if ( a > b ) { + return 1; + } + return 0; +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `toSorted` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'toSorted' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toSorted ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.toSorted.call( value, compareFcn ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.toSorted( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty typed array', function test( t ) { + var arr; + var out; + + arr = new Float64Array(); + out = arr.toSorted( compareFcn ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 3.0, 1.0, 2.0 ] ); + out = arr.toSorted( compareFcn ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.strictEqual( out.length, 3, 'returns expected value' ); + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 3.0, 1.0, 2.0 ] ); + out = arr.toSorted( compareFcn ); + + t.strictEqual( out.length, arr.length, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not mutate the original array', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 3.0, 1.0, 2.0 ] ); + out = arr.toSorted( compareFcn ); + + t.strictEqual( arr[ 0 ], 3.0, 'original is unchanged' ); + t.strictEqual( arr[ 1 ], 1.0, 'original is unchanged' ); + t.strictEqual( arr[ 2 ], 2.0, 'original is unchanged' ); + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.to_string.js b/lib/node_modules/@stdlib/array/float64/test/test.to_string.js new file mode 100644 index 000000000000..e0325bc596c7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.to_string.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `toString` method for serializing a typed array', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + t.end(); +}); + +tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { + var str; + var arr; + + arr = new Float64Array(); + str = arr.toString(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a typed array', function test( t ) { + var expected; + var str; + var arr; + + arr = new Float64Array( [ 1, 2, 3, 4 ] ); + expected = '1,2,3,4'; + + str = arr.toString(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.values.js b/lib/node_modules/@stdlib/array/float64/test/test.values.js new file mode 100644 index 000000000000..3a22dd33e6ab --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.values.js @@ -0,0 +1,149 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `values` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'values' ), true, 'has property' ); + t.strictEqual( isFunction( arr.values ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.values.call( value ); + }; + } +}); + +tape( 'the method returns an iterator protocol-compliant object', function test( t ) { + var expected; + var arr; + var it; + var i; + var r; + var e; + + arr = new Float64Array( [ 1.0, 2.0 ] ); + expected = [ + { + 'value': 1.0, + 'done': false + }, + { + 'value': 2.0, + 'done': false + }, + { + 'value': void 0, + 'done': true + } + ]; + it = arr.values(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + r = it.next(); + e = expected[ i ]; + if ( e.value === void 0 ) { + t.deepEqual( r, e, 'returns expected value' ); + } else { + t.strictEqual( r.value, e.value, 'returns expected value' ); + t.strictEqual( r.done, e.done, 'returns expected value' ); + } + } + + t.end(); +}); + +tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { + var expected; + var arr; + var it; + var i; + var v; + + arr = new Float64Array( [] ); + expected = [ + { + 'value': void 0, + 'done': true + }, + { + 'value': void 0, + 'done': true + }, + { + 'value': void 0, + 'done': true + } + ]; + it = arr.values(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + v = it.next(); + t.deepEqual( v, expected[ i ], 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/float64/test/test.with.js b/lib/node_modules/@stdlib/array/float64/test/test.with.js new file mode 100644 index 000000000000..e443bf560bd0 --- /dev/null +++ b/lib/node_modules/@stdlib/array/float64/test/test.with.js @@ -0,0 +1,153 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a typed array instance has a `with` method', function test( t ) { + var arr = new Float64Array( 2 ); + t.strictEqual( hasProp( arr, 'with' ), true, 'has property' ); + t.strictEqual( isFunction( arr.with ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.with.call( value, 0, 1.0 ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { + var values; + var arr; + var i; + + arr = new Float64Array( 10 ); + + values = [ + -11, + -12, + 11, + 12 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.with( value, 1.0 ); + }; + } +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new Float64Array( 10 ); + out = arr.with( 5, 1.0 ); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new typed array with the element at a provided index replaced with a provided value', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = arr.with( 1, 5.0 ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.notEqual( out, arr, 'returns new instance' ); + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 5.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 3 ], 4.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports negative indices', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = arr.with( -1, 5.0 ); + + t.strictEqual( out instanceof Float64Array, true, 'returns expected value' ); + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 5.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not mutate the original array', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = arr.with( 1, 5.0 ); + + t.strictEqual( arr[ 0 ], 1.0, 'original is unchanged' ); + t.strictEqual( arr[ 1 ], 2.0, 'original is unchanged' ); + t.strictEqual( arr[ 2 ], 3.0, 'original is unchanged' ); + t.strictEqual( out[ 1 ], 5.0, 'returns expected value' ); + t.end(); +});