Skip to content

Commit b7692ef

Browse files
committed
Add param description and invalid argument test
1 parent 05a76d4 commit b7692ef

File tree

8 files changed

+124
-4
lines changed

8 files changed

+124
-4
lines changed

lib/node_modules/@stdlib/regexp/basename/docs/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ interface ReBasename {
7171
/**
7272
* Returns a regular expression to capture the last part of a path.
7373
*
74+
* @param platform - path platform (`win32` or `posix`)
7475
* @returns regular expression
7576
*
7677
* @example

lib/node_modules/@stdlib/regexp/basename/test/test.main.js

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

35+
tape( 'the function throws an error if the `platform` argument is not a recognized platform', function test( t ) {
36+
var values;
37+
var i;
38+
39+
values = [
40+
123,
41+
'abc',
42+
true,
43+
false,
44+
null,
45+
undefined,
46+
NaN,
47+
[],
48+
{},
49+
function noop() {}
50+
];
51+
52+
for ( i = 0; i < values.length; i++ ) {
53+
t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] );
54+
}
55+
t.end();
56+
57+
function badValue( value ) {
58+
return function factory() {
59+
reBasename( value );
60+
};
61+
}
62+
});
63+
3564
tape( 'the function returns a regular expression that captures the last part of a POSIX path (platform: `posix`)', function test( t ) {
3665
var expected;
3766
var values;

lib/node_modules/@stdlib/regexp/dirname/docs/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ interface ReDirname {
7171
/**
7272
* Returns a regular expression to capture a path dirname.
7373
*
74+
* @param platform - path platform (`win32` or `posix`)
7475
* @returns regular expression
7576
*
7677
* @example

lib/node_modules/@stdlib/regexp/dirname/test/test.main.js

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

35+
tape( 'the function throws an error if the `platform` argument is not a recognized platform', function test( t ) {
36+
var values;
37+
var i;
38+
39+
values = [
40+
123,
41+
'abc',
42+
true,
43+
false,
44+
null,
45+
undefined,
46+
NaN,
47+
[],
48+
{},
49+
function noop() {}
50+
];
51+
52+
for ( i = 0; i < values.length; i++ ) {
53+
t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] );
54+
}
55+
t.end();
56+
57+
function badValue( value ) {
58+
return function factory() {
59+
reDirname( value );
60+
};
61+
}
62+
});
63+
3564
tape( 'the function returns a regular expression that captures POSIX path dirnames (platform: `posix`)', function test( t ) {
3665
var expected;
3766
var values;

lib/node_modules/@stdlib/regexp/extname/docs/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ interface ReExtname {
7171
/**
7272
* Returns a regular expression to capture a filename extension.
7373
*
74+
* @param platform - path platform (`win32` or `posix`)
7475
* @returns regular expression
7576
*
7677
* @example

lib/node_modules/@stdlib/regexp/extname/test/test.main.js

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

35+
tape( 'the function throws an error if the `platform` argument is not a recognized platform', function test( t ) {
36+
var values;
37+
var i;
38+
39+
values = [
40+
123,
41+
'abc',
42+
true,
43+
false,
44+
null,
45+
undefined,
46+
NaN,
47+
[],
48+
{},
49+
function noop() {}
50+
];
51+
52+
for ( i = 0; i < values.length; i++ ) {
53+
t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] );
54+
}
55+
t.end();
56+
57+
function badValue( value ) {
58+
return function factory() {
59+
reExtname( value );
60+
};
61+
}
62+
});
63+
3564
tape( 'the function returns a regular expression that captures POSIX filename extensions (platform: `posix`)', function test( t ) {
3665
var expected;
3766
var values;

lib/node_modules/@stdlib/regexp/filename/docs/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ interface ReFilename {
7171
/**
7272
* Returns a regular expression to split a filename.
7373
*
74+
* @param platform - path platform (`win32` or `posix`)
7475
* @returns regular expression
7576
*
7677
* @example

lib/node_modules/@stdlib/regexp/filename/test/test.main.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,54 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var reExtname = require( './../lib/main.js' );
24+
var reFilename = require( './../lib/main.js' );
2525

2626

2727
// TESTS //
2828

2929
tape( 'main export is a function', function test( t ) {
3030
t.ok( true, __filename );
31-
t.strictEqual( reExtname instanceof Function, true, 'main export is a function' );
31+
t.strictEqual( reFilename instanceof Function, true, 'main export is a function' );
3232
t.end();
3333
});
3434

35+
tape( 'the function throws an error if the `platform` argument is not a recognized platform', function test( t ) {
36+
var values;
37+
var i;
38+
39+
values = [
40+
123,
41+
'abc',
42+
true,
43+
false,
44+
null,
45+
undefined,
46+
NaN,
47+
[],
48+
{},
49+
function noop() {}
50+
];
51+
52+
for ( i = 0; i < values.length; i++ ) {
53+
t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] );
54+
}
55+
t.end();
56+
57+
function badValue( value ) {
58+
return function factory() {
59+
reFilename( value );
60+
};
61+
}
62+
});
63+
3564
tape( 'the function returns a regular expression that splits POSIX filenames (platform: `posix`)', function test( t ) {
3665
var expected;
3766
var values;
3867
var parts;
3968
var RE;
4069
var i;
4170

42-
RE = reExtname( 'posix' );
71+
RE = reFilename( 'posix' );
4372

4473
values = [
4574
'index.js',
@@ -65,7 +94,7 @@ tape( 'the function returns a regular expression that splits Windows filenames (
6594
var RE;
6695
var i;
6796

68-
RE = reExtname( 'win32' );
97+
RE = reFilename( 'win32' );
6998

7099
values = [
71100
'index.js',

0 commit comments

Comments
 (0)