Skip to content

Commit

Permalink
feat: updated test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush0325 committed Nov 12, 2024
1 parent 15e5d34 commit 6a21435
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var absf = require( '@stdlib/math/base/special/absf' );
var EPS = require( '@stdlib/constants/float32/eps' );
var FLOAT32_SMALLEST_NORMAL = require( '@stdlib/constants/float32/smallest-normal' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var real = require( '@stdlib/complex/float32/real' );
var imag = require( '@stdlib/complex/float32/imag' );
Expand Down Expand Up @@ -386,6 +387,46 @@ tape( 'the function computes a complex inverse (tiny positive real components)',
t.end();
});

tape( 'the function may produce very large values for very small inputs', function test( t ) {
var huge = 1e37;
var tiny = -1e37;
var v;

v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, FLOAT32_SMALLEST_NORMAL ) );

Check warning on line 395 in lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 83. Maximum allowed is 80
t.ok( real( v ) > huge, 'real component is very large' );
t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' );

v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, FLOAT32_SMALLEST_NORMAL ) );

Check warning on line 399 in lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 84. Maximum allowed is 80
t.ok( real( v ) < tiny, 'real component is very large and negative' );
t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' );

v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, -FLOAT32_SMALLEST_NORMAL ) );

Check warning on line 403 in lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 85. Maximum allowed is 80
t.ok( real( v ) < tiny, 'real component is very large and negative' );
t.ok( imag( v ) > huge, 'imaginary component is very large and positive' );

v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, -FLOAT32_SMALLEST_NORMAL ) );

Check warning on line 407 in lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 84. Maximum allowed is 80
t.ok( real( v ) > huge, 'real component is very large and positive' );
t.ok( imag( v ) > huge, 'imaginary component is very large and positive' );

v = cinvf( new Complex64( 0.0, FLOAT32_SMALLEST_NORMAL ) );
t.strictEqual( real( v ), 0.0, 'real component is 0' );
t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' );

v = cinvf( new Complex64( 0.0, -FLOAT32_SMALLEST_NORMAL ) );
t.strictEqual( real( v ), 0.0, 'real component is 0' );
t.ok( imag( v ) > huge, 'imaginary component is very large and positive' );

v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, 0.0 ) );
t.ok( real( v ) > huge, 'real component is very large and positive' );
t.strictEqual( imag( v ), 0.0, 'imaginary component is 0' );

v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, 0.0 ) );
t.ok( real( v ) < tiny, 'real component is very large and negative' );
t.strictEqual( imag( v ), 0.0, 'imaginary component is 0' );

t.end();
});

tape( 'if a real or imaginary component is `NaN`, all components are `NaN`', function test( t ) {
var v;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var absf = require( '@stdlib/math/base/special/absf' );
var EPS = require( '@stdlib/constants/float32/eps' );
var FLOAT32_SMALLEST_NORMAL = require( '@stdlib/constants/float32/smallest-normal' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var real = require( '@stdlib/complex/float32/real' );
var imag = require( '@stdlib/complex/float32/imag' );
Expand Down Expand Up @@ -395,6 +396,46 @@ tape( 'the function computes a complex inverse (tiny positive real components)',
t.end();
});

tape( 'the function may produce very large values for very small inputs', opts, function test( t ) {
var huge = 1e37;
var tiny = -1e37;
var v;

v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, FLOAT32_SMALLEST_NORMAL ) );

Check warning on line 404 in lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 83. Maximum allowed is 80
t.ok( real( v ) > huge, 'real component is very large' );
t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' );

v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, FLOAT32_SMALLEST_NORMAL ) );

Check warning on line 408 in lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 84. Maximum allowed is 80
t.ok( real( v ) < tiny, 'real component is very large and negative' );
t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' );

v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, -FLOAT32_SMALLEST_NORMAL ) );

Check warning on line 412 in lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 85. Maximum allowed is 80
t.ok( real( v ) < tiny, 'real component is very large and negative' );
t.ok( imag( v ) > huge, 'imaginary component is very large and positive' );

v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, -FLOAT32_SMALLEST_NORMAL ) );

Check warning on line 416 in lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 84. Maximum allowed is 80
t.ok( real( v ) > huge, 'real component is very large and positive' );
t.ok( imag( v ) > huge, 'imaginary component is very large and positive' );

v = cinvf( new Complex64( 0.0, FLOAT32_SMALLEST_NORMAL ) );
t.strictEqual( real( v ), 0.0, 'real component is 0' );
t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' );

v = cinvf( new Complex64( 0.0, -FLOAT32_SMALLEST_NORMAL ) );
t.strictEqual( real( v ), 0.0, 'real component is 0' );
t.ok( imag( v ) > huge, 'imaginary component is very large and positive' );

v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, 0.0 ) );
t.ok( real( v ) > huge, 'real component is very large and positive' );
t.strictEqual( imag( v ), 0.0, 'imaginary component is 0' );

v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, 0.0 ) );
t.ok( real( v ) < tiny, 'real component is very large and negative' );
t.strictEqual( imag( v ), 0.0, 'imaginary component is 0' );

t.end();
});

tape( 'if a real or imaginary component is `NaN`, all components are `NaN`', opts, function test( t ) {
var v;

Expand Down

0 comments on commit 6a21435

Please sign in to comment.