Skip to content

test: add tests to achieve 100% code coverage #5693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var logcdf = require( '@stdlib/stats/base/dists/triangular/logcdf' );
var logpdf = require( '@stdlib/stats/base/dists/triangular/logpdf' );
var cdf = require( '@stdlib/stats/base/dists/triangular/cdf' );
var pdf = require( '@stdlib/stats/base/dists/triangular/pdf' );
var mgf = require( '@stdlib/stats/base/dists/triangular/mgf' );
var kurtosis = require( '@stdlib/stats/base/dists/triangular/kurtosis' );
var skewness = require( '@stdlib/stats/base/dists/triangular/skewness' );
var variance = require( '@stdlib/stats/base/dists/triangular/variance' );
Expand Down Expand Up @@ -328,6 +329,19 @@ tape( 'the created distribution throws an error if one attempts to set `b` to a
}
});

tape( 'the created distribution has a property for getting and setting `c`', function test( t ) {
var triangular;

triangular = new Triangular( 2.0, 4.0, 2.5 );
t.strictEqual( hasOwnProp( triangular, 'c' ), true, 'has property' );
t.strictEqual( triangular.c, 2.5, 'returns expected value' );

triangular.c = 3.0;
t.strictEqual( triangular.c, 3.0, 'returns expected value' );

t.end();
});

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 ) {
var values;
var i;
Expand Down Expand Up @@ -525,6 +539,20 @@ tape( 'the distribution prototype has a method for evaluating the probability de
t.end();
});

tape( 'the distribution prototype has a method for evaluating the moment-generating function (MGF)', function test( t ) {
var triangular;
var y;

t.strictEqual( hasOwnProp( Triangular.prototype, 'mgf' ), true, 'has property' );
t.strictEqual( isFunction( Triangular.prototype.mgf ), true, 'has method' );

triangular = new Triangular();
y = triangular.mgf( 0.2 );

t.strictEqual( y, mgf( 0.2, 0.0, 1.0, 0.5 ), 'returns expected value' );
t.end();
});

tape( 'the distribution prototype has a method for evaluating the quantile function', function test( t ) {
var triangular;
var y;
Expand Down