diff --git a/lib/node_modules/@stdlib/string/substring-after-last/lib/main.js b/lib/node_modules/@stdlib/string/substring-after-last/lib/main.js index 89d1d6855dd9..787a3409cd4d 100644 --- a/lib/node_modules/@stdlib/string/substring-after-last/lib/main.js +++ b/lib/node_modules/@stdlib/string/substring-after-last/lib/main.js @@ -72,7 +72,7 @@ function substringAfterLast( str, search, fromIndex ) { } if ( arguments.length > 2 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', fromIndex ) ); } idx = str.lastIndexOf( search, fromIndex ); } else { diff --git a/lib/node_modules/@stdlib/string/substring-after-last/test/test.js b/lib/node_modules/@stdlib/string/substring-after-last/test/test.js index a14b06581f8d..33bb699be523 100644 --- a/lib/node_modules/@stdlib/string/substring-after-last/test/test.js +++ b/lib/node_modules/@stdlib/string/substring-after-last/test/test.js @@ -88,6 +88,35 @@ tape( 'the function throws an error if not provided a string as its second argum } }); +tape( 'the function throws an error if not provided an integer as its third argument', function test( t ) { + var values; + var i; + + values = [ + 1.5, + -1.5, + NaN, + '5', + true, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), /Third argument must be an integer/, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + substringAfterLast( 'beep', 'b', value ); + }; + } +}); + tape( 'the function returns the substring after the last occurrence of a provided search string', function test( t ) { var expected; var actual; @@ -155,6 +184,10 @@ tape( 'the function returns the substring after the last occurrence of a provide expected = ''; t.strictEqual( actual, expected, 'returns expected value' ); + actual = substringAfterLast( 'beep', 'b', -1 ); + expected = 'eep'; + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); });