Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
default:
// Unknown type, let it slide...

// TODO: should we compare constructor names here at a minimum? or perhaps walk the prototype tree and compare constructor names to determine whether a value is an instance of?

Check warning on line 293 in lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: should we compare constructor...'
return true;
}
}
Expand Down Expand Up @@ -398,7 +398,7 @@
function checkArray( actual, expected ) {
var entries;
var match;
var a;

Check warning on line 401 in lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

File has too many lines (489). Maximum allowed is 300
var b;
var i;

Expand Down Expand Up @@ -435,6 +435,9 @@
return false;
}
} else if ( isPrimitive( a ) ) {
if ( !isPrimitive( b ) ) {
return false;
}
b = String( b );
if ( !checkPrimitive( a, b ) ) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,55 @@ tape( 'the function compares a function and a corresponding return annotation',
return x;
}
});

tape( 'the function detects a mismatch when an actual array element is a primitive and the expected array element is an array', function test( t ) {
var expected;
var actual;
var msg;

actual = [ 300, 700 ];
expected = '[[ 300, 700 ]]';
msg = 'Displayed return value is `[[ 300, 700 ]]`, but expected `[ 300, 700 ]` instead';
t.strictEqual( compareValues( actual, expected ), msg, 'returns expected message' );

t.end();
});

tape( 'the function detects a mismatch when an actual array element is a primitive and the expected array element is an object', function test( t ) {
var expected;
var actual;
var msg;

actual = [ 1 ];
expected = '[ {} ]';
msg = 'Displayed return value is `[ {} ]`, but expected `[ 1 ]` instead';
t.strictEqual( compareValues( actual, expected ), msg, 'returns expected message' );

t.end();
});

tape( 'the function detects a mismatch when an actual array element is a primitive and the expected array element is a RegExp', function test( t ) {
var expected;
var actual;
var msg;

actual = [ 1 ];
expected = '[ /abc/ ]';
msg = 'Displayed return value is `[ /abc/ ]`, but expected `[ 1 ]` instead';
t.strictEqual( compareValues( actual, expected ), msg, 'returns expected message' );

t.end();
});

tape( 'the function detects a mismatch in a mixed array where a primitive corresponds to an array', function test( t ) {
var expected;
var actual;
var msg;

actual = [ 1, 2 ];
expected = '[ 1, [ 2 ] ]';
msg = 'Displayed return value is `[ 1, [ 2 ] ]`, but expected `[ 1, 2 ]` instead';
t.strictEqual( compareValues( actual, expected ), msg, 'returns expected message' );

t.end();
});