From 04807ef6de143fdb9f19c2dd65e6c41ab79c6ff1 Mon Sep 17 00:00:00 2001 From: Pratik Date: Sat, 6 Apr 2024 23:22:22 +0530 Subject: [PATCH 1/6] feat: add tests to @stdlib/utils/compact-adjacency-matrix added tests to @stdlib/utils/compact-adjacency-matrix Fixes #1330 --- .../test/test.add_edge.js | 119 ++++++++++++ .../test/test.edges.js | 64 +++++++ .../test/test.from_adjacency_list.js | 65 +++++++ .../test/test.from_edges.js | 177 ++++++++++++++++++ .../test/test.has_edge.js | 120 ++++++++++++ .../test/test.indegree.js | 150 +++++++++++++++ .../test/test.inedges.js | 150 +++++++++++++++ .../compact-adjacency-matrix/test/test.js | 18 ++ .../test/test.nedges.js | 63 +++++++ .../test/test.nvertices.js | 54 ++++++ .../test/test.out_degree.js | 149 +++++++++++++++ .../test/test.out_edges.js | 150 +++++++++++++++ .../test/test.remove_edge.js | 119 ++++++++++++ .../test/test.to_adjacency_list.js | 65 +++++++ .../test/test.toposort.js | 65 +++++++ 15 files changed, 1528 insertions(+) create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.edges.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_adjacency_list.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.has_edge.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.indegree.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nedges.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nvertices.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_degree.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_edges.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.to_adjacency_list.js create mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.toposort.js diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js new file mode 100644 index 000000000000..f19cc12b158e --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js @@ -0,0 +1,119 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `addEdge` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'addEdge' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.addEdge ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a value where both arguments are not a non negative number', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + [ '5', 2 ], + [ 'abcde', -1 ], + [ -1, 5 ], + [ NaN, NaN ], + [ true, 2 ], + [ false, '2' ], + [ null, 0 ], + [ void 0, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i][0], values[i][1] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return adj.addEdge( arg1, arg2 ); + }; + } +}); + +tape( 'the method throws an Range error if invoked with value where both arguments exceeds matrix dimensions', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + [ 6, 2 ], + [ 0, 5 ], + [ 7, 8 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i][0], values[i][1] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return adj.addEdge( arg1, arg2 ); + }; + } +}); + +tape( 'the method returns an instance of adjcency matrix upon invoking by a valid input', function test( t ) { + var expected; + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + [ 0, 3], + [ 1, 0], + [ 0, 2] + ]; + for ( i = 0; i < values.length; i++ ) { + expected = adj.addEdge( values[i][0], values[i][1] ); + t.strictEqual( expected instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.edges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.edges.js new file mode 100644 index 000000000000..fa2d61a71422 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.edges.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); +var isArray = require( '@stdlib/assert/is-array' ); +var CompactAdjacencyMatrix = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `edges` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'edges' ), true, 'has property' ); + t.end(); +}); + +tape( 'the method returns a list of array when there exists vertices and edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + t.strictEqual( isArray( adj.edges ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty array in case of vertices but no edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + t.strictEqual( isEmptyArray( adj.edges ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_adjacency_list.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_adjacency_list.js new file mode 100644 index 000000000000..ca39daf414ef --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_adjacency_list.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isArray = require( '@stdlib/assert/is-array' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `toAdjacencyList` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'toAdjacencyList' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.toAdjacencyList ), true, 'has method' ); + t.end(); +}); + +tape( 'the method returns a list of array when there exists vertices and edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + t.strictEqual( isArray( adj.toAdjacencyList() ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty array in case of vertices but no edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + t.strictEqual( isArray( adj.toAdjacencyList() ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js new file mode 100644 index 000000000000..425722703175 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js @@ -0,0 +1,177 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `fromEdges` method', function test( t ) { + var arr; + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'fromEdges' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.fromEdges ), true, 'has method' ); + + arr = CompactAdjacencyMatrix.fromEdges( 2, [] ); + t.strictEqual( arr instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a non negative number', function test( t ) { + var values; + var edges; + var i; + + edges = [ [ 0, 1 ], [ 0, 2 ], [ 1, 2 ], [ 2, 3 ] ]; + + values = [ + '5', + 'abcde', + -1, + NaN, + true, + false, + null, + void 0 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i], edges ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return CompactAdjacencyMatrix.fromEdges.call( arg1, arg2 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not an array like object', function test( t ) { + var values; + var i; + + values = [ + '5', + 'abcde', + -1, + NaN, + true, + false, + null, + void 0 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( 4, values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return CompactAdjacencyMatrix.fromEdges.call( arg1, arg2 ); + }; + } +}); + +tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( 4, values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return CompactAdjacencyMatrix.fromEdges.call( arg1, arg2, clbk ); + }; + } + + function clbk() { + return [ 1.0, 1.0 ]; + } +}); + +tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { + var values; + var i; + + 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( arg1, arg2 ) { + return function badValue() { + return CompactAdjacencyMatrix.fromEdges.call( arg1, arg2, clbk, {} ); + }; + } + + function clbk() { + return [ 1.0, 1.0 ]; + } +}); + +tape( 'the method returns an instance of adjcency matrix upon invoking by a valid input', function test( t ) { + var values; + var i; + + values = [ + [ [ 0, 1 ], [ 2, 3 ] ], + [ [ 1, 3 ], [ 0, 3 ], [ 2, 0 ] ], + [ [ 1, 2 ], [ 0, 1 ] ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( CompactAdjacencyMatrix.fromEdges( 4, values[ i ] ) instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.has_edge.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.has_edge.js new file mode 100644 index 000000000000..5391975118bb --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.has_edge.js @@ -0,0 +1,120 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `hasEdge` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'hasEdge' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.hasEdge ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a value where both arguments are not a non negative number', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + [ '5', 2 ], + [ 'abcde', -1 ], + [ -1, 5 ], + [ NaN, NaN ], + [ true, 2 ], + [ false, '2' ], + [ null, 0 ], + [ void 0, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i][0], values[i][1] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return adj.hasEdge( arg1, arg2 ); + }; + } +}); + +tape( 'the method throws an Range error if invoked with value where both arguments exceeds matrix dimensions', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + [ 6, 2 ], + [ 0, 5 ], + [ 7, 8 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i][0], values[i][1] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return adj.hasEdge( arg1, arg2 ); + }; + } +}); + +tape( 'the method returns a boolean value upon invoking by a valid input', function test( t ) { + var expected; + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.hasEdge( 1, 0 ); + adj.hasEdge( 1, 2 ); + adj.hasEdge( 0, 2 ); + adj.hasEdge( 2, 3 ); + + values = [ + [ 0, 3], + [ 1, 0], + [ 0, 2] + ]; + for ( i = 0; i < values.length; i++ ) { + expected = adj.hasEdge( values[i][0], values[i][1] ); + t.strictEqual( isBoolean( expected ), true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.indegree.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.indegree.js new file mode 100644 index 000000000000..020425eb2461 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.indegree.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `inDegree` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'inDegree' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.inDegree ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a value which is not a non negative number', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + '5', + 'abcde', + -1, + 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 adj.inDegree( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with value which exceeds matrix dimensions', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + 5, + 6, + 8 + ]; + 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 adj.inDegree( value ); + }; + } +}); + +tape( 'the method returns a non negative value upon invoking by a valid input', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + 0, + 1, + 2, + 3 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isNonNegativeInteger( adj.inDegree( values[i] ) ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the method returns 0 in case of vertices but no edges', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + 0, + 1, + 2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( adj.inDegree( values[i] ), 0, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js new file mode 100644 index 000000000000..d466c43a7fed --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); +var isArray = require( '@stdlib/assert/is-array' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `inEdges` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'inEdges' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.inEdges ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a value which is not a non negative number', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + '5', + 'abcde', + -1, + 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 adj.inEdges( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with value which exceeds matrix dimensions', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + 5, + 6, + 8 + ]; + 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 adj.inEdges( value ); + }; + } +}); + +tape( 'the method returns an array upon invoking by a valid input', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + 0, + 1, + 2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isArray( adj.inEdges( values[i] ) ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the method returns an empty array in case of vertices but no edges', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + 0, + 1, + 2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isEmptyArray( adj.inEdges( values[i] ) ), true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.js index 115fd7545421..5ea3baf4b0c4 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.js @@ -48,3 +48,21 @@ tape( 'the constructor does not require the `new` keyword', function test( t ) { t.strictEqual( instanceOf( mat, CompactAdjacencyMatrix ), true, 'returns an instance' ); t.end(); }); + +tape( 'the constructor returns an instance of compact adjacency matrix (length)', function test( t ) { + var arr = new CompactAdjacencyMatrix( 10 ); + t.strictEqual( arr instanceof CompactAdjacencyMatrix, true, 'returns an instance' ); + t.end(); +}); + +tape( 'the constructor returns an instance of compact adjacency matrix (length, no new)', function test( t ) { + var ctor; + var arr; + + ctor = CompactAdjacencyMatrix; + + arr = ctor( 10 ); + t.strictEqual( arr instanceof CompactAdjacencyMatrix, true, 'returns an instance' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nedges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nedges.js new file mode 100644 index 000000000000..4a27c9ebd1fb --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nedges.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var CompactAdjacencyMatrix = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `nedges` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'nedges' ), true, 'has property' ); + t.end(); +}); + +tape( 'the method returns a non negative value denoting number of edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + t.strictEqual( isNonNegativeInteger( adj.nedges ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns 0 in case of vertices but no edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + t.strictEqual( adj.nedges, 0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nvertices.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nvertices.js new file mode 100644 index 000000000000..5928b74af5e1 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nvertices.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `nvertices` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'nvertices' ), true, 'has property' ); + t.end(); +}); + +tape( 'the method returns a non negative value denoting number of vertices', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + t.strictEqual( isNonNegativeInteger( adj.nvertices ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_degree.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_degree.js new file mode 100644 index 000000000000..66f94a5606de --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_degree.js @@ -0,0 +1,149 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `outDegree` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'outDegree' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.outDegree ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a value which is not a non negative number', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + '5', + 'abcde', + -1, + 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 adj.outDegree( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with value which exceeds matrix dimensions', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + 5, + 6, + 8 + ]; + 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 adj.outDegree( value ); + }; + } +}); + +tape( 'the method returns a non negative value upon invoking by a valid input', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + 0, + 1, + 2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isNonNegativeInteger( adj.outDegree( values[i] ) ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the method returns 0 in case of vertices but no edges', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + 0, + 1, + 2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( adj.outDegree( values[i] ), 0, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_edges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_edges.js new file mode 100644 index 000000000000..80cc9eafe563 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_edges.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); +var isArray = require( '@stdlib/assert/is-array' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `outEdges` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'outEdges' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.outEdges ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a value which is not a non negative number', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + '5', + 'abcde', + -1, + 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 adj.outEdges( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with value which exceeds matrix dimensions', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + 5, + 6, + 8 + ]; + 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 adj.outEdges( value ); + }; + } +}); + +tape( 'the method returns an array upon invoking by a valid input', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + 0, + 1, + 2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isArray( adj.outEdges( values[i] ) ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the method returns an empty array in case of vertices but no edges', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + 0, + 1, + 2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isEmptyArray( adj.outEdges( values[i] ) ), true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js new file mode 100644 index 000000000000..d3d7edc0c75b --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js @@ -0,0 +1,119 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `removeEdge` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'removeEdge' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.removeEdge ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a value where both arguments are not a non negative number', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + [ '5', 2 ], + [ 'abcde', -1 ], + [ -1, 5 ], + [ NaN, NaN ], + [ true, 2 ], + [ false, '2' ], + [ null, 0 ], + [ void 0, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i][0], values[i][1] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return adj.removeEdge.call( arg1, arg2 ); + }; + } +}); + +tape( 'the method throws an Range error if invoked with value where both arguments exceeds matrix dimensions', function test( t ) { + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + values = [ + [ 6, 2 ], + [ 0, 5 ], + [ 7, 8 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i][0], values[i][1] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( arg1, arg2 ) { + return function badValue() { + return adj.removeEdge( arg1, arg2 ); + }; + } +}); + +tape( 'the method returns an instance of adjcency matrix upon removing an edge', function test( t ) { + var expected; + var values; + var adj; + var i; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + values = [ + [ 2, 3], + [ 1, 0], + [ 0, 2] + ]; + for ( i = 0; i < values.length; i++ ) { + expected = adj.removeEdge( values[i][0], values[i][1] ); + t.strictEqual( expected instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.to_adjacency_list.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.to_adjacency_list.js new file mode 100644 index 000000000000..ca39daf414ef --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.to_adjacency_list.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isArray = require( '@stdlib/assert/is-array' ); +var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `toAdjacencyList` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'toAdjacencyList' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.toAdjacencyList ), true, 'has method' ); + t.end(); +}); + +tape( 'the method returns a list of array when there exists vertices and edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + t.strictEqual( isArray( adj.toAdjacencyList() ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty array in case of vertices but no edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + t.strictEqual( isArray( adj.toAdjacencyList() ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.toposort.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.toposort.js new file mode 100644 index 000000000000..6a5b1972d329 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.toposort.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isArray = require( '@stdlib/assert/is-array' ); +var CompactAdjacencyMatrix = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `toposort` method', function test( t ) { + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'toposort' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.toposort ), true, 'has method' ); + t.end(); +}); + +tape( 'the method returns an array when there exists vertices and toposort', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + adj.addEdge( 1, 0 ); + adj.addEdge( 1, 2 ); + adj.addEdge( 0, 2 ); + adj.addEdge( 2, 3 ); + + t.strictEqual( isArray( adj.toposort() ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an non-empty array in case of vertices but no edges', function test( t ) { + var adj; + + adj = new CompactAdjacencyMatrix( 4 ); + + t.strictEqual( isArray( adj.toposort() ), true, 'returns expected value' ); + t.end(); +}); From 6427438e5b5a24071cd55d68992dd493ef3c8dc2 Mon Sep 17 00:00:00 2001 From: Pratik Date: Sun, 7 Apr 2024 00:20:12 +0530 Subject: [PATCH 2/6] feat: add tests to @stdlib/utils/compact-adjacency-matrix done some changes related to test messages Fixes #1330 --- .../compact-adjacency-matrix/test/test.from_edges.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js index 425722703175..4f23372c366d 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js @@ -44,7 +44,7 @@ tape( 'attached to the prototype of the main export is a `fromEdges` method', fu t.end(); }); -tape( 'the method throws an error if invoked with a `this` context which is not a non negative number', function test( t ) { +tape( 'the method throws an error if invoked with a value which is not a non negative number', function test( t ) { var values; var edges; var i; @@ -68,12 +68,12 @@ tape( 'the method throws an error if invoked with a `this` context which is not function badValue( arg1, arg2 ) { return function badValue() { - return CompactAdjacencyMatrix.fromEdges.call( arg1, arg2 ); + return CompactAdjacencyMatrix.fromEdges( arg1, arg2 ); }; } }); -tape( 'the method throws an error if invoked with a `this` context which is not an array like object', function test( t ) { +tape( 'the method throws an error if invoked with a value which is not an array like object', function test( t ) { var values; var i; @@ -94,7 +94,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not function badValue( arg1, arg2 ) { return function badValue() { - return CompactAdjacencyMatrix.fromEdges.call( arg1, arg2 ); + return CompactAdjacencyMatrix.fromEdges( arg1, arg2 ); }; } }); @@ -121,7 +121,7 @@ tape( 'the method throws an error if not provided an iterable or array-like obje function badValue( arg1, arg2 ) { return function badValue() { - return CompactAdjacencyMatrix.fromEdges.call( arg1, arg2, clbk ); + return CompactAdjacencyMatrix.fromEdges( arg1, arg2, clbk ); }; } @@ -152,7 +152,7 @@ tape( 'the method throws an error if not provided an iterable or array-like obje function badValue( arg1, arg2 ) { return function badValue() { - return CompactAdjacencyMatrix.fromEdges.call( arg1, arg2, clbk, {} ); + return CompactAdjacencyMatrix.fromEdges( arg1, arg2, clbk, {} ); }; } From 66ec4c1dfa58b8fd75b3b20dab363ce35904482e Mon Sep 17 00:00:00 2001 From: Pratik Date: Sun, 7 Apr 2024 13:55:34 +0530 Subject: [PATCH 3/6] feat: add tests to @stdlib/utils/compact-adjacency-matrix modified test.from_edges.js Fixes #1330 --- .../utils/compact-adjacency-matrix/test/test.from_edges.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js index 4f23372c366d..e545837dbb97 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js @@ -23,7 +23,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // @@ -36,8 +36,9 @@ tape( 'main export is a function', function test( t ) { tape( 'attached to the prototype of the main export is a `fromEdges` method', function test( t ) { var arr; - t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'fromEdges' ), true, 'has property' ); - t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.fromEdges ), true, 'has method' ); + + t.strictEqual( hasOwnProp( CompactAdjacencyMatrix, 'fromEdges' ), true, 'has property' ); + t.strictEqual( isFunction( CompactAdjacencyMatrix.fromEdges ), true, 'has method' ); arr = CompactAdjacencyMatrix.fromEdges( 2, [] ); t.strictEqual( arr instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); From 03a1e5af72539de6f4c1c4b40c7124bc162eba6f Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 13 Oct 2024 16:02:00 -0400 Subject: [PATCH 4/6] test: remove file as duplicate of to_adjacency_list --- .../test/test.from_adjacency_list.js | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_adjacency_list.js diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_adjacency_list.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_adjacency_list.js deleted file mode 100644 index ca39daf414ef..000000000000 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_adjacency_list.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isArray = require( '@stdlib/assert/is-array' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof CompactAdjacencyMatrix, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toAdjacencyList` method', function test( t ) { - t.strictEqual( hasOwnProp( CompactAdjacencyMatrix.prototype, 'toAdjacencyList' ), true, 'has property' ); - t.strictEqual( isFunction( CompactAdjacencyMatrix.prototype.toAdjacencyList ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns a list of array when there exists vertices and edges', function test( t ) { - var adj; - - adj = new CompactAdjacencyMatrix( 4 ); - - adj.addEdge( 1, 0 ); - adj.addEdge( 1, 2 ); - adj.addEdge( 0, 2 ); - adj.addEdge( 2, 3 ); - - t.strictEqual( isArray( adj.toAdjacencyList() ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty array in case of vertices but no edges', function test( t ) { - var adj; - - adj = new CompactAdjacencyMatrix( 4 ); - - t.strictEqual( isArray( adj.toAdjacencyList() ), true, 'returns expected value' ); - t.end(); -}); From 2b21b71c147e6ef938fc638f0c3c45c5e554347b Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 13 Oct 2024 16:02:24 -0400 Subject: [PATCH 5/6] test: fix require paths of package to be relative paths --- .../utils/compact-adjacency-matrix/test/test.add_edge.js | 2 +- .../utils/compact-adjacency-matrix/test/test.has_edge.js | 2 +- .../utils/compact-adjacency-matrix/test/test.indegree.js | 2 +- .../@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js | 2 +- .../utils/compact-adjacency-matrix/test/test.nvertices.js | 2 +- .../utils/compact-adjacency-matrix/test/test.out_degree.js | 2 +- .../utils/compact-adjacency-matrix/test/test.out_edges.js | 2 +- .../utils/compact-adjacency-matrix/test/test.remove_edge.js | 2 +- .../compact-adjacency-matrix/test/test.to_adjacency_list.js | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js index f19cc12b158e..3a311a1282bb 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js @@ -23,7 +23,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.has_edge.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.has_edge.js index 5391975118bb..4c18c240d7c9 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.has_edge.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.has_edge.js @@ -24,7 +24,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); var isBoolean = require( '@stdlib/assert/is-boolean' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.indegree.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.indegree.js index 020425eb2461..8e88307e6a44 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.indegree.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.indegree.js @@ -24,7 +24,7 @@ var tape = require( 'tape' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js index d466c43a7fed..09a01180e909 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.inedges.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); var isArray = require( '@stdlib/assert/is-array' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nvertices.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nvertices.js index 5928b74af5e1..aa8a13783fa2 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nvertices.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.nvertices.js @@ -23,7 +23,7 @@ var tape = require( 'tape' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_degree.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_degree.js index 66f94a5606de..df6a3ae710c1 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_degree.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_degree.js @@ -24,7 +24,7 @@ var tape = require( 'tape' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_edges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_edges.js index 80cc9eafe563..3f10ebb95212 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_edges.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.out_edges.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); var isArray = require( '@stdlib/assert/is-array' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js index d3d7edc0c75b..ce7f0e1c58b7 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js @@ -23,7 +23,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.to_adjacency_list.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.to_adjacency_list.js index ca39daf414ef..13d0de63f61f 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.to_adjacency_list.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.to_adjacency_list.js @@ -24,7 +24,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); var isArray = require( '@stdlib/assert/is-array' ); -var CompactAdjacencyMatrix = require( '@stdlib/utils/compact-adjacency-matrix/lib' ); +var CompactAdjacencyMatrix = require( './../lib' ); // TESTS // From 5835aca24f15a0832d2983abdc418317cfc52e1b Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 13 Oct 2024 16:08:44 -0400 Subject: [PATCH 6/6] chore: use assertion instanceOf package --- .../utils/compact-adjacency-matrix/test/test.add_edge.js | 3 ++- .../utils/compact-adjacency-matrix/test/test.from_edges.js | 5 +++-- .../@stdlib/utils/compact-adjacency-matrix/test/test.js | 4 ++-- .../utils/compact-adjacency-matrix/test/test.remove_edge.js | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js index 3a311a1282bb..943f8551e905 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.add_edge.js @@ -23,6 +23,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); var CompactAdjacencyMatrix = require( './../lib' ); @@ -113,7 +114,7 @@ tape( 'the method returns an instance of adjcency matrix upon invoking by a vali ]; for ( i = 0; i < values.length; i++ ) { expected = adj.addEdge( values[i][0], values[i][1] ); - t.strictEqual( expected instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); + t.strictEqual( instanceOf( expected, CompactAdjacencyMatrix ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js index e545837dbb97..9c92342cf7c0 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.from_edges.js @@ -23,6 +23,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); var CompactAdjacencyMatrix = require( './../lib' ); @@ -41,7 +42,7 @@ tape( 'attached to the prototype of the main export is a `fromEdges` method', fu t.strictEqual( isFunction( CompactAdjacencyMatrix.fromEdges ), true, 'has method' ); arr = CompactAdjacencyMatrix.fromEdges( 2, [] ); - t.strictEqual( arr instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); + t.strictEqual( instanceOf( arr, CompactAdjacencyMatrix ), true, 'returns expected value' ); t.end(); }); @@ -172,7 +173,7 @@ tape( 'the method returns an instance of adjcency matrix upon invoking by a vali [ [ 1, 2 ], [ 0, 1 ] ] ]; for ( i = 0; i < values.length; i++ ) { - t.strictEqual( CompactAdjacencyMatrix.fromEdges( 4, values[ i ] ) instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); + t.strictEqual( instanceOf( CompactAdjacencyMatrix.fromEdges( 4, values[ i ] ), CompactAdjacencyMatrix ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.js index 5ea3baf4b0c4..9db03b65c4b5 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.js @@ -51,7 +51,7 @@ tape( 'the constructor does not require the `new` keyword', function test( t ) { tape( 'the constructor returns an instance of compact adjacency matrix (length)', function test( t ) { var arr = new CompactAdjacencyMatrix( 10 ); - t.strictEqual( arr instanceof CompactAdjacencyMatrix, true, 'returns an instance' ); + t.strictEqual( instanceOf( arr, CompactAdjacencyMatrix ), true, 'returns an instance' ); t.end(); }); @@ -62,7 +62,7 @@ tape( 'the constructor returns an instance of compact adjacency matrix (length, ctor = CompactAdjacencyMatrix; arr = ctor( 10 ); - t.strictEqual( arr instanceof CompactAdjacencyMatrix, true, 'returns an instance' ); + t.strictEqual( instanceOf( arr, CompactAdjacencyMatrix ), true, 'returns an instance' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js index ce7f0e1c58b7..a8dffb4b8c21 100644 --- a/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js +++ b/lib/node_modules/@stdlib/utils/compact-adjacency-matrix/test/test.remove_edge.js @@ -23,6 +23,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); var CompactAdjacencyMatrix = require( './../lib' ); @@ -113,7 +114,7 @@ tape( 'the method returns an instance of adjcency matrix upon removing an edge', ]; for ( i = 0; i < values.length; i++ ) { expected = adj.removeEdge( values[i][0], values[i][1] ); - t.strictEqual( expected instanceof CompactAdjacencyMatrix, true, 'returns expected value' ); + t.strictEqual( instanceOf( expected, CompactAdjacencyMatrix ), true, 'returns expected value' ); } t.end(); });