Skip to content

Commit 276f077

Browse files
test: add tests to achieve 100% code coverage
PR-URL: #5638 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 5470254 commit 276f077

File tree

3 files changed

+76
-25
lines changed

3 files changed

+76
-25
lines changed

lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.factory.js

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,39 +56,39 @@ tape( 'if provided `NaN` for any parameter, the created function returns `NaN`',
5656

5757
mgf = factory( 0.0, 1.0, 0.5 );
5858
y = mgf( NaN );
59-
t.equal( isnan( y ), true, 'returns NaN' );
59+
t.equal( isnan( y ), true, 'returns expected value' );
6060

6161
mgf = factory( NaN, 1.0, 0.5 );
6262
y = mgf( 0.0 );
63-
t.equal( isnan( y ), true, 'returns NaN' );
63+
t.equal( isnan( y ), true, 'returns expected value' );
6464

6565
mgf = factory( 0.0, NaN, 0.5 );
6666
y = mgf( 0.0 );
67-
t.equal( isnan( y ), true, 'returns NaN' );
67+
t.equal( isnan( y ), true, 'returns expected value' );
6868

6969
mgf = factory( 0.0, 1.0, NaN );
7070
y = mgf( 0.0 );
71-
t.equal( isnan( y ), true, 'returns NaN' );
71+
t.equal( isnan( y ), true, 'returns expected value' );
7272

7373
mgf = factory( NaN, NaN, NaN );
7474
y = mgf( 0.0 );
75-
t.equal( isnan( y ), true, 'returns NaN' );
75+
t.equal( isnan( y ), true, 'returns expected value' );
7676

7777
mgf = factory( 0.0, NaN, NaN );
7878
y = mgf( 0.0 );
79-
t.equal( isnan( y ), true, 'returns NaN' );
79+
t.equal( isnan( y ), true, 'returns expected value' );
8080

8181
mgf = factory( NaN, 1.0, NaN );
8282
y = mgf( 0.0 );
83-
t.equal( isnan( y ), true, 'returns NaN' );
83+
t.equal( isnan( y ), true, 'returns expected value' );
8484

8585
mgf = factory( NaN, NaN, 0.5 );
8686
y = mgf( 0.0 );
87-
t.equal( isnan( y ), true, 'returns NaN' );
87+
t.equal( isnan( y ), true, 'returns expected value' );
8888

8989
mgf = factory( NaN, NaN, 0.5 );
9090
y = mgf( NaN );
91-
t.equal( isnan( y ), true, 'returns NaN' );
91+
t.equal( isnan( y ), true, 'returns expected value' );
9292

9393
t.end();
9494
});
@@ -100,34 +100,49 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the created function
100100
mgf = factory( 2.0, 1.0, 0.5 );
101101

102102
y = mgf( 2.0 );
103-
t.equal( isnan( y ), true, 'returns NaN' );
103+
t.equal( isnan( y ), true, 'returns expected value' );
104104

105105
y = mgf( 0.0 );
106-
t.equal( isnan( y ), true, 'returns NaN' );
106+
t.equal( isnan( y ), true, 'returns expected value' );
107107

108108
mgf = factory( 0.0, NINF, 0.5 );
109109
y = mgf( 2.0 );
110-
t.equal( isnan( y ), true, 'returns NaN' );
110+
t.equal( isnan( y ), true, 'returns expected value' );
111111

112112
mgf = factory( PINF, NINF, 0.5 );
113113
y = mgf( 2.0 );
114-
t.equal( isnan( y ), true, 'returns NaN' );
114+
t.equal( isnan( y ), true, 'returns expected value' );
115115

116116
mgf = factory( NINF, NINF, 0.5 );
117117
y = mgf( 2.0 );
118-
t.equal( isnan( y ), true, 'returns NaN' );
118+
t.equal( isnan( y ), true, 'returns expected value' );
119119

120120
mgf = factory( -1.0, -2.0, 0.5 );
121121
y = mgf( 2.0 );
122-
t.equal( isnan( y ), true, 'returns NaN' );
122+
t.equal( isnan( y ), true, 'returns expected value' );
123123

124124
mgf = factory( -10.0, 10.0, 12.0 );
125125
y = mgf( 2.0 );
126-
t.equal( isnan( y ), true, 'returns NaN' );
126+
t.equal( isnan( y ), true, 'returns expected value' );
127127

128128
mgf = factory( -10.0, 10.0, -12.0 );
129129
y = mgf( 2.0 );
130-
t.equal( isnan( y ), true, 'returns NaN' );
130+
t.equal( isnan( y ), true, 'returns expected value' );
131+
132+
t.end();
133+
});
134+
135+
tape( 'if provided valid `a`, `b`, and `c`, the function returns a function which returns `1` when provided `0` for `t`', function test( t ) {
136+
var mgf;
137+
var y;
138+
139+
mgf = factory( 0.0, 1.0, 0.5 );
140+
y = mgf( 0.0 );
141+
t.equal( y, 1.0, 'returns expected value' );
142+
143+
mgf = factory( -1.0, 1.0, 0.0 );
144+
y = mgf( 0.0 );
145+
t.equal( y, 1.0, 'returns expected value' );
131146

132147
t.end();
133148
});

lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.mgf.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,48 @@ tape( 'main export is a function', function test( t ) {
4444

4545
tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) {
4646
var y = mgf( NaN, 0.0, 1.0, 0.5 );
47-
t.equal( isnan( y ), true, 'returns NaN' );
47+
t.equal( isnan( y ), true, 'returns expected value' );
4848
y = mgf( 0.0, NaN, 1.0, 0.5 );
49-
t.equal( isnan( y ), true, 'returns NaN' );
49+
t.equal( isnan( y ), true, 'returns expected value' );
5050
y = mgf( 0.0, 1.0, NaN, 0.5 );
51-
t.equal( isnan( y ), true, 'returns NaN' );
51+
t.equal( isnan( y ), true, 'returns expected value' );
5252
y = mgf( 0.0, 0.0, 1.0, NaN );
53-
t.equal( isnan( y ), true, 'returns NaN' );
53+
t.equal( isnan( y ), true, 'returns expected value' );
5454
t.end();
5555
});
5656

5757
tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns `NaN`', function test( t ) {
5858
var y;
5959

6060
y = mgf( 2.0, -1.0, -1.1, -1.0 );
61-
t.equal( isnan( y ), true, 'returns NaN' );
61+
t.equal( isnan( y ), true, 'returns expected value' );
6262

6363
y = mgf( 0.0, 3.0, 2.0, 2.5 );
64-
t.equal( isnan( y ), true, 'returns NaN' );
64+
t.equal( isnan( y ), true, 'returns expected value' );
6565

6666
y = mgf( 0.0, 0.0, 1.0, -1.0 );
67-
t.equal( isnan( y ), true, 'returns NaN' );
67+
t.equal( isnan( y ), true, 'returns expected value' );
6868

6969
y = mgf( 0.0, 0.0, 1.0, 2.0 );
70-
t.equal( isnan( y ), true, 'returns NaN' );
70+
t.equal( isnan( y ), true, 'returns expected value' );
71+
72+
t.end();
73+
});
74+
75+
tape( 'if provided `0` for `t` and valid `a`, `b` and `c`, the function returns `1`', function test( t ) {
76+
var y;
77+
78+
y = mgf( 0.0, -1.0, -1.0, -1.0 );
79+
t.equal( y, 1.0, 'returns expected value' );
80+
81+
y = mgf( 0.0, 0.0, 1.0, 0.5 );
82+
t.equal( y, 1.0, 'returns expected value' );
83+
84+
y = mgf( 0.0, 0.0, 1.0, 1.0 );
85+
t.equal( y, 1.0, 'returns expected value' );
86+
87+
y = mgf( 0.0, 1.0, 1.0, 1.0 );
88+
t.equal( y, 1.0, 'returns expected value' );
7189

7290
t.end();
7391
});

lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.native.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns
8181
t.end();
8282
});
8383

84+
tape( 'if provided `0` for `t` and valid `a`, `b` and `c`, the function returns `1`', function test( t ) {
85+
var y;
86+
87+
y = mgf( 0.0, -1.0, -1.0, -1.0 );
88+
t.equal( y, 1.0, 'returns expected value' );
89+
90+
y = mgf( 0.0, 0.0, 1.0, 0.5 );
91+
t.equal( y, 1.0, 'returns expected value' );
92+
93+
y = mgf( 0.0, 0.0, 1.0, 1.0 );
94+
t.equal( y, 1.0, 'returns expected value' );
95+
96+
y = mgf( 0.0, 1.0, 1.0, 1.0 );
97+
t.equal( y, 1.0, 'returns expected value' );
98+
99+
t.end();
100+
});
101+
84102
tape( 'the function evaluates the MGF for `x` given a small range `b - a`', opts, function test( t ) {
85103
var expected;
86104
var delta;

0 commit comments

Comments
 (0)