Skip to content

Commit c9faa13

Browse files
committed
Add tests for negative values
1 parent 79f4f06 commit c9faa13

File tree

10 files changed

+120
-4
lines changed

10 files changed

+120
-4
lines changed

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/huge_negative.json

+1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/huge_positive.json

+1-1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/large_negative.json

+1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/large_positive.json

+1-1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/larger_negative.json

+1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/larger_positive.json

+1-1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/medium_negative.json

+1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/medium_positive.json

+1-1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acoth/test/fixtures/julia/runner.jl

100644100755
+16
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,19 @@ gen( x, "larger_positive.json" );
7474
# Huge positive values:
7575
x = linspace( 1.0e300, 1.0e308, 1003 );
7676
gen( x, "huge_positive.json" );
77+
78+
# Negative medium values:
79+
x = linspace( -1.1, -3.0, 503 );
80+
gen( x, "medium_negative.json" );
81+
82+
# Large negative values:
83+
x = linspace( -3.0, -28.0, 503 );
84+
gen( x, "large_negative.json" );
85+
86+
# Larger negative values:
87+
x = linspace( -28.0, -100.0, 503 );
88+
gen( x, "larger_negative.json" );
89+
90+
# Huge negative values:
91+
x = linspace( -1.0e300, -1.0e308, 1003 );
92+
gen( x, "huge_negative.json" );

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

+96
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ var largerPositive = require( './fixtures/julia/larger_positive.json' );
3434
var largePositive = require( './fixtures/julia/large_positive.json' );
3535
var mediumPositive = require( './fixtures/julia/medium_positive.json' );
3636
var hugePositive = require( './fixtures/julia/huge_positive.json' );
37+
var largerNegative = require( './fixtures/julia/larger_negative.json' );
38+
var largeNegative = require( './fixtures/julia/large_negative.json' );
39+
var mediumNegative = require( './fixtures/julia/medium_negative.json' );
40+
var hugeNegative = require( './fixtures/julia/huge_negative.json' );
3741

3842

3943
// TESTS //
@@ -67,6 +71,29 @@ tape( 'the function computes the inverse hyperbolic cotangent for medium positiv
6771
t.end();
6872
});
6973

74+
tape( 'the function computes the inverse hyperbolic cotangent for medium negative values', function test( t ) {
75+
var expected;
76+
var delta;
77+
var tol;
78+
var x;
79+
var y;
80+
var i;
81+
82+
x = mediumNegative.x;
83+
expected = mediumNegative.expected;
84+
for ( i = 0; i < x.length; i++ ) {
85+
y = acoth( x[ i ] );
86+
if ( y === expected[ i ] ) {
87+
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i]+'.' );
88+
} else {
89+
delta = abs( y - expected[i] );
90+
tol = 1.0 * EPS * abs( expected[i] );
91+
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
92+
}
93+
}
94+
t.end();
95+
});
96+
7097
tape( 'the function computes the inverse hyperbolic cotangent for large positive values', function test( t ) {
7198
var expected;
7299
var delta;
@@ -90,6 +117,29 @@ tape( 'the function computes the inverse hyperbolic cotangent for large positive
90117
t.end();
91118
});
92119

120+
tape( 'the function computes the inverse hyperbolic cotangent for large negative values', function test( t ) {
121+
var expected;
122+
var delta;
123+
var tol;
124+
var x;
125+
var y;
126+
var i;
127+
128+
x = largeNegative.x;
129+
expected = largeNegative.expected;
130+
for ( i = 0; i < x.length; i++ ) {
131+
y = acoth( x[ i ] );
132+
if ( y === expected[ i ] ) {
133+
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i]+'.' );
134+
} else {
135+
delta = abs( y - expected[i] );
136+
tol = 1.0 * EPS * abs( expected[i] );
137+
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
138+
}
139+
}
140+
t.end();
141+
});
142+
93143
tape( 'the function computes the inverse hyperbolic cotangent for larger positive values', function test( t ) {
94144
var expected;
95145
var delta;
@@ -113,6 +163,29 @@ tape( 'the function computes the inverse hyperbolic cotangent for larger positiv
113163
t.end();
114164
});
115165

166+
tape( 'the function computes the inverse hyperbolic cotangent for larger negative values', function test( t ) {
167+
var expected;
168+
var delta;
169+
var tol;
170+
var x;
171+
var y;
172+
var i;
173+
174+
x = largerNegative.x;
175+
expected = largerNegative.expected;
176+
for ( i = 0; i < x.length; i++ ) {
177+
y = acoth( x[ i ] );
178+
if ( y === expected[ i ] ) {
179+
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i]+'.' );
180+
} else {
181+
delta = abs( y - expected[i] );
182+
tol = 1.0 * EPS * abs( expected[i] );
183+
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
184+
}
185+
}
186+
t.end();
187+
});
188+
116189
tape( 'the function computes the inverse hyperbolic cotangent for huge positive values', function test( t ) {
117190
var expected;
118191
var delta;
@@ -136,6 +209,29 @@ tape( 'the function computes the inverse hyperbolic cotangent for huge positive
136209
t.end();
137210
});
138211

212+
tape( 'the function computes the inverse hyperbolic cotangent for huge negative values', function test( t ) {
213+
var expected;
214+
var delta;
215+
var tol;
216+
var x;
217+
var y;
218+
var i;
219+
220+
x = hugeNegative.x;
221+
expected = hugeNegative.expected;
222+
for ( i = 0; i < x.length; i++ ) {
223+
y = acoth( x[ i ] );
224+
if ( y === expected[ i ] ) {
225+
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i]+'.' );
226+
} else {
227+
delta = abs( y - expected[i] );
228+
tol = 1.0 * EPS * abs( expected[i] );
229+
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
230+
}
231+
}
232+
t.end();
233+
});
234+
139235
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
140236
var v = acoth( NaN );
141237
t.equal( isnan( v ), true, 'returns NaN' );

0 commit comments

Comments
 (0)