Skip to content

Commit 48eeb62

Browse files
committed
test: fix upper-tail fixture iteration and edge-case assertions in JS tests
1 parent 2f3393c commit 48eeb62

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

  • lib/node_modules/@stdlib/math/base/special/gammaincinv/test

lib/node_modules/@stdlib/math/base/special/gammaincinv/test/test.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var incrspace = require( '@stdlib/array/base/incrspace' );
2525
var isfinite = require( '@stdlib/math/base/assert/is-finite' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var abs = require( '@stdlib/math/base/special/abs' );
28+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
2829
var PINF = require( '@stdlib/constants/float64/pinf' );
2930
var gammaincinv = require( './../lib' );
3031

@@ -116,54 +117,54 @@ tape( 'the function returns `NaN` if provided `p` outside the interval `[0,1]`',
116117
t.end();
117118
});
118119

119-
tape( 'the function returns `0` if provided `p = 1`', function test( t ) {
120+
tape( 'the function returns `+Infinity` if provided `p = 1`', function test( t ) {
120121
var val;
121122
var a;
122123
var i;
123124

124-
a = incrspace( 0, 100, 10 );
125+
a = incrspace( 10, 100, 10 );
125126
for ( i = 0; i < a.length; i++ ) {
126127
val = gammaincinv( 1, a[ i ] );
127-
t.notOk( val === 0, 'returns expected value' );
128+
t.strictEqual( val, PINF, 'returns expected value' );
128129
}
129130
t.end();
130131
});
131132

132-
tape( 'the function returns `+Infinity` if provided `p = 0`', function test( t ) {
133+
tape( 'the function returns `0` if provided `p = 0`', function test( t ) {
133134
var val;
134135
var a;
135136
var i;
136137

137-
a = incrspace( 0, 100, 10 );
138+
a = incrspace( 10, 100, 10 );
138139
for ( i = 0; i < a.length; i++ ) {
139140
val = gammaincinv( 0, a[ i ] );
140-
t.notOk( val === PINF, 'returns expected value' );
141+
t.strictEqual( val, 0.0, 'returns expected value' );
141142
}
142143
t.end();
143144
});
144145

145-
tape( 'the function returns `0` if provided `p = 0` when `upper = true`', function test( t ) {
146+
tape( 'the function returns `+Infinity` if provided `p = 0` when `upper = true`', function test( t ) {
146147
var val;
147148
var a;
148149
var i;
149150

150-
a = incrspace( 0, 100, 10 );
151+
a = incrspace( 10, 100, 10 );
151152
for ( i = 0; i < a.length; i++ ) {
152153
val = gammaincinv( 0, a[ i ], true );
153-
t.notOk( val === 0, 'returns expected value' );
154+
t.strictEqual( val, PINF, 'returns expected value' );
154155
}
155156
t.end();
156157
});
157158

158-
tape( 'the function returns `+Infinity` if provided `p = 1` when `upper = true`', function test( t ) {
159+
tape( 'the function returns `0` if provided `p = 1` when `upper = true`', function test( t ) {
159160
var val;
160161
var a;
161162
var i;
162163

163-
a = incrspace( 0, 100, 10 );
164+
a = incrspace( 10, 100, 10 );
164165
for ( i = 0; i < a.length; i++ ) {
165166
val = gammaincinv( 1, a[ i ], true );
166-
t.notOk( val === PINF, 'returns expected value' );
167+
t.strictEqual( val, 0.0, 'returns expected value' );
167168
}
168169
t.end();
169170
});
@@ -195,18 +196,18 @@ tape( 'the function inverts the upper incomplete gamma function when `upper=true
195196
var b1;
196197
var b2;
197198
var i;
198-
for ( i = 0; i < arg1.length; i++ ) {
199+
for ( i = 0; i < upperArg1.length; i++ ) {
199200
actual = gammaincinv( upperArg1[ i ], upperArg2[ i ], true );
200201

201202
b1 = isfinite( actual );
202203
b2 = isfinite( upperExpected[ i ] );
203204
t.strictEqual( b1, b2, 'returned result is ' + ( (b2) ? 'finite' : 'not finite' ) );
204205

205206
b1 = isnan( actual );
206-
b2 = isnan( expected[ i ] );
207+
b2 = isnan( upperExpected[ i ] );
207208
t.strictEqual( b1, b2, 'returned result is ' + ( (b1) ? '' : 'not' ) + ' NaN' );
208209
if ( !b1 || !b2 ) {
209-
t.ok( abs( actual - upperExpected[ i ] ) < 5e-14, 'returned result is within tolerance. actual: ' + actual + '; expected: ' + upperExpected[ i ] + '.' );
210+
t.strictEqual( isAlmostSameValue( actual, upperExpected[ i ], 40.0 ), true, 'returned result is within tolerance. actual: ' + actual + '; expected: ' + upperExpected[ i ] + '.' );
210211
}
211212
}
212213
t.end();

0 commit comments

Comments
 (0)