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 63fb9c05356..a9fcdf1235e 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 @@ -209,6 +209,27 @@ function checkForPlaceholders( actual, expected ) { } } +/** +* Compares array entries with a list of actual values. +* +* @private +* @param {Collection} actual - list of actual values +* @param {Collection} expected - list of expected values +* @returns {(string|null)} result +*/ +function compareEntries( actual, expected ) { + var i; + if ( actual.length !== expected.length ) { + return 'Expected array entries ['+expected+'], but observed ['+actual+']'; + } + for ( i = 0; i < expected.length; i++ ) { + if ( !checkPrimitive( actual[ i ], String( expected[ i ] ) ) ) { + return 'Expected array entries ['+expected+'], but observed ['+actual+']'; + } + } + return null; +} + /** * For a typed array, if the return annotation asserts deep instance equality, check whether it corresponds to the actual value; otherwise, check whether the return annotation signals the correct type. * @@ -221,7 +242,6 @@ function checkTypedArrays( actual, expected ) { var entries; var match; var type; - var i; match = RE_INSTANCE_ANNOTATION.exec( expected ); if ( match ) { @@ -231,12 +251,7 @@ function checkTypedArrays( actual, expected ) { return 'Expected instance type <'+actual.constructor.name+'>, but observed <'+type+'>'; } if ( entries ) { - entries = parse( entries ); - for ( i = 0; i < entries.length; i++ ) { - if ( !checkPrimitive( actual[ i ], String( entries[ i ] ) ) ) { - return 'Expected array entries ['+entries+'], but observed ['+actual+']'; - } - } + return compareEntries( actual, parse( entries ) ); } return null; }