Skip to content

Commit 234f29c

Browse files
committed
made suggested changes in example.js and main.js
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 6cad99b commit 234f29c

File tree

3 files changed

+48
-97
lines changed

3 files changed

+48
-97
lines changed

lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@
4444
* var y = [];
4545
* var bool = hasSameConstructor( x, y );
4646
* // returns true
47-
*
4847
*/
48+
// function hasSameConstructor( x, y ) {
49+
// if ( !x || !y ) {
50+
// return false;
51+
// }
52+
// return x.constructor === y.constructor;
53+
// }
4954

5055
function hasSameConstructor( x, y ) {
51-
if ( !x || !y ) {
56+
if (x == null || y == null) { // Check for null or undefined only
5257
return false;
5358
}
5459
return x.constructor === y.constructor;

lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js

Lines changed: 37 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -32,101 +32,45 @@ tape( 'main export is a function', function test( t ) {
3232
t.end();
3333
});
3434

35-
tape( 'compare two null values', function test( t ) {
36-
var bool;
37-
38-
bool = hasSameConstructor( null, null );
39-
t.strictEqual( bool, false, 'returns false for null and null' );
40-
41-
t.end();
42-
});
43-
44-
tape( 'compare two Number objects', function test( t ) {
45-
var bool;
46-
47-
bool = hasSameConstructor( new Number(5), new Number(10) );
48-
t.strictEqual( bool, true, 'returns true for matching Number objects' );
49-
50-
t.end();
51-
});
52-
53-
tape( 'compare two Arrays', function test( t ) {
54-
var bool;
55-
56-
bool = hasSameConstructor( [], [] );
57-
t.strictEqual( bool, true, 'returns true for matching Arrays' );
58-
59-
t.end();
60-
});
61-
62-
tape( 'compare Number and Array', function test(t) {
63-
var bool;
64-
65-
bool = hasSameConstructor( new Number(5), [] );
66-
t.strictEqual( bool, false, 'returns false for different constructors' );
67-
68-
t.end();
69-
});
70-
71-
tape( 'compare two null values', function test( t ) {
72-
var bool;
73-
74-
bool = hasSameConstructor( null, null );
75-
t.strictEqual( bool, false, 'returns false for null and null' );
76-
77-
t.end();
78-
});
79-
80-
tape( 'compare two undefined values', function test( t ) {
81-
var bool;
82-
83-
bool = hasSameConstructor( undefined, undefined );
84-
t.strictEqual( bool, false, 'returns false for undefined and undefined' );
85-
86-
t.end();
87-
});
88-
89-
tape( 'compare null and Number object', function test( t ) {
90-
var bool;
91-
92-
bool = hasSameConstructor( null, new Number(5) );
93-
t.strictEqual( bool, false, 'returns false for null and Number object' );
94-
95-
t.end();
96-
});
97-
98-
tape( 'compare undefined and Array', function test( t ) {
99-
var bool;
100-
101-
bool = hasSameConstructor( undefined, [] );
102-
t.strictEqual( bool, false, 'returns false for undefined and Array' );
103-
104-
t.end();
105-
});
106-
107-
tape( 'compare two number primitives', function test( t ) {
108-
var bool;
109-
110-
bool = hasSameConstructor( 5, 5 );
111-
t.strictEqual( bool, true, 'returns true for matching number primitives' );
112-
113-
t.end();
35+
tape( 'the function returns `true` if provided two arguments which have the same constructor', function test ( t ) {
36+
var values;
37+
var bool;
38+
var i;
39+
40+
values =[
41+
[ true, false ],
42+
[ 1.0, 3.1 ],
43+
[ new Number( 1.0 ), 3.1 ],
44+
[ new Number( 0.0 ), new Number( 0.0 ) ],
45+
[ new String( 'abc' ), 'abc' ],
46+
[ JSON, Math ],
47+
[ NaN, NaN ],
48+
[ function() {}, () => {} ]
49+
50+
];
51+
52+
for ( i = 0; i < values.length; i++ ) {
53+
bool = hasSameConstructor( values[ i ][ 0 ], values[ i ][ 1 ] );
54+
t.strictEqual( bool, true, 'returns true' );
55+
}
56+
t.end();
11457
});
11558

116-
tape( 'compare number and string primitives', function test( t ) {
59+
tape( 'the function returns `false` if not provided two arguments having the same constructor', function test( t ) {
60+
var values;
11761
var bool;
118-
119-
bool = hasSameConstructor( 5, 'hello' );
120-
t.strictEqual( bool, false, 'returns false for different primitive types' );
121-
122-
t.end();
123-
});
124-
125-
tape( 'compare number primitive and Number object', function test( t ) {
126-
var bool;
127-
128-
bool = hasSameConstructor( 5, new Number( 5 ) );
129-
t.strictEqual( bool, true, 'returns true for matching number primitive and object' );
130-
62+
var i;
63+
64+
values = [
65+
[ 1.0, '1.0' ],
66+
[ null, null ],
67+
[ [], {} ],
68+
[ null, void 0 ],
69+
];
70+
71+
for ( i = 0; i < values.length; i++ ) {
72+
bool = hasSameConstructor( values[ i ][ 0 ], values[ i ][ 1 ] );
73+
t.strictEqual( bool, false, 'returns false' );
74+
}
13175
t.end();
13276
});

lib/node_modules/@stdlib/assert/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
"bugs": {
3131
"url": "https://github.com/stdlib-js/stdlib/issues"
3232
},
33-
"dependencies": {},
34-
"devDependencies": {},
33+
"dependencies": {
34+
"doctest": "^0.21.0",
35+
"tape": "^5.9.0"
36+
},
3537
"engines": {
3638
"node": ">=0.10.0",
3739
"npm": ">2.7.0"

0 commit comments

Comments
 (0)