Skip to content

Commit 6a802bc

Browse files
test: add tests to achieve 100% code coverage
PR-URL: #5693 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 18596e9 commit 6a802bc

File tree

1 file changed

+28
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/triangular/ctor/test

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var logcdf = require( '@stdlib/stats/base/dists/triangular/logcdf' );
2828
var logpdf = require( '@stdlib/stats/base/dists/triangular/logpdf' );
2929
var cdf = require( '@stdlib/stats/base/dists/triangular/cdf' );
3030
var pdf = require( '@stdlib/stats/base/dists/triangular/pdf' );
31+
var mgf = require( '@stdlib/stats/base/dists/triangular/mgf' );
3132
var kurtosis = require( '@stdlib/stats/base/dists/triangular/kurtosis' );
3233
var skewness = require( '@stdlib/stats/base/dists/triangular/skewness' );
3334
var variance = require( '@stdlib/stats/base/dists/triangular/variance' );
@@ -328,6 +329,19 @@ tape( 'the created distribution throws an error if one attempts to set `b` to a
328329
}
329330
});
330331

332+
tape( 'the created distribution has a property for getting and setting `c`', function test( t ) {
333+
var triangular;
334+
335+
triangular = new Triangular( 2.0, 4.0, 2.5 );
336+
t.strictEqual( hasOwnProp( triangular, 'c' ), true, 'has property' );
337+
t.strictEqual( triangular.c, 2.5, 'returns expected value' );
338+
339+
triangular.c = 3.0;
340+
t.strictEqual( triangular.c, 3.0, 'returns expected value' );
341+
342+
t.end();
343+
});
344+
331345
tape( 'the created distribution throws an error if one attempts to set `c` to a value which is not a number primitive', function test( t ) {
332346
var values;
333347
var i;
@@ -525,6 +539,20 @@ tape( 'the distribution prototype has a method for evaluating the probability de
525539
t.end();
526540
});
527541

542+
tape( 'the distribution prototype has a method for evaluating the moment-generating function (MGF)', function test( t ) {
543+
var triangular;
544+
var y;
545+
546+
t.strictEqual( hasOwnProp( Triangular.prototype, 'mgf' ), true, 'has property' );
547+
t.strictEqual( isFunction( Triangular.prototype.mgf ), true, 'has method' );
548+
549+
triangular = new Triangular();
550+
y = triangular.mgf( 0.2 );
551+
552+
t.strictEqual( y, mgf( 0.2, 0.0, 1.0, 0.5 ), 'returns expected value' );
553+
t.end();
554+
});
555+
528556
tape( 'the distribution prototype has a method for evaluating the quantile function', function test( t ) {
529557
var triangular;
530558
var y;

0 commit comments

Comments
 (0)