From 12e4cc1f6076efd4fef3c694b32dea35edd48932 Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Fri, 19 Dec 2025 02:35:01 +0530 Subject: [PATCH 1/2] fix: doctest linter --- .../@stdlib/_tools/doctest/compare-values/lib/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js b/lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js index dd8f37d264dd..7aef20358034 100644 --- a/lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js @@ -435,6 +435,9 @@ function checkArray( actual, expected ) { return false; } } else if ( isPrimitive( a ) ) { + if ( isArray( b ) ) { + return false; + } b = String( b ); if ( !checkPrimitive( a, b ) ) { return false; From b6658fdb5fea2be47357ad6497d832531d0fb44b Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Fri, 19 Dec 2025 13:52:38 +0530 Subject: [PATCH 2/2] chore: changes --- .../_tools/doctest/compare-values/lib/main.js | 2 +- .../doctest/compare-values/test/test.js | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js b/lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js index 7aef20358034..af66083e87ca 100644 --- a/lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js @@ -435,7 +435,7 @@ function checkArray( actual, expected ) { return false; } } else if ( isPrimitive( a ) ) { - if ( isArray( b ) ) { + if ( !isPrimitive( b ) ) { return false; } b = String( b ); diff --git a/lib/node_modules/@stdlib/_tools/doctest/compare-values/test/test.js b/lib/node_modules/@stdlib/_tools/doctest/compare-values/test/test.js index 5a004ff6869f..032c70c03533 100644 --- a/lib/node_modules/@stdlib/_tools/doctest/compare-values/test/test.js +++ b/lib/node_modules/@stdlib/_tools/doctest/compare-values/test/test.js @@ -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(); +});