From 267f91b970283ac4949f990a5c51a889c9998973 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 1 Mar 2025 10:59:37 -0800 Subject: [PATCH] test: add tests to achieve 100% code coverage --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../dists/triangular/mgf/test/test.factory.js | 49 ++++++++++++------- .../dists/triangular/mgf/test/test.mgf.js | 34 ++++++++++--- .../dists/triangular/mgf/test/test.native.js | 18 +++++++ 3 files changed, 76 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.factory.js index 061758e25031..e09ee2891521 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.factory.js @@ -56,39 +56,39 @@ tape( 'if provided `NaN` for any parameter, the created function returns `NaN`', mgf = factory( 0.0, 1.0, 0.5 ); y = mgf( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( NaN, 1.0, 0.5 ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( 0.0, NaN, 0.5 ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( 0.0, 1.0, NaN ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( NaN, NaN, NaN ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( 0.0, NaN, NaN ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( NaN, 1.0, NaN ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( NaN, NaN, 0.5 ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( NaN, NaN, 0.5 ); y = mgf( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -100,34 +100,49 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the created function mgf = factory( 2.0, 1.0, 0.5 ); y = mgf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( 0.0, NINF, 0.5 ); y = mgf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( PINF, NINF, 0.5 ); y = mgf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( NINF, NINF, 0.5 ); y = mgf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( -1.0, -2.0, 0.5 ); y = mgf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( -10.0, 10.0, 12.0 ); y = mgf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( -10.0, 10.0, -12.0 ); y = mgf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided valid `a`, `b`, and `c`, the function returns a function which returns `1` when provided `0` for `t`', function test( t ) { + var mgf; + var y; + + mgf = factory( 0.0, 1.0, 0.5 ); + y = mgf( 0.0 ); + t.equal( y, 1.0, 'returns expected value' ); + + mgf = factory( -1.0, 1.0, 0.0 ); + y = mgf( 0.0 ); + t.equal( y, 1.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.mgf.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.mgf.js index 747f4ac64bc6..cb18e08e3d04 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.mgf.js +++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.mgf.js @@ -44,13 +44,13 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) { var y = mgf( NaN, 0.0, 1.0, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, NaN, 1.0, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, 1.0, NaN, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, 0.0, 1.0, NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -58,16 +58,34 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns var y; y = mgf( 2.0, -1.0, -1.1, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, 3.0, 2.0, 2.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, 0.0, 1.0, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, 0.0, 1.0, 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided `0` for `t` and valid `a`, `b` and `c`, the function returns `1`', function test( t ) { + var y; + + y = mgf( 0.0, -1.0, -1.0, -1.0 ); + t.equal( y, 1.0, 'returns expected value' ); + + y = mgf( 0.0, 0.0, 1.0, 0.5 ); + t.equal( y, 1.0, 'returns expected value' ); + + y = mgf( 0.0, 0.0, 1.0, 1.0 ); + t.equal( y, 1.0, 'returns expected value' ); + + y = mgf( 0.0, 1.0, 1.0, 1.0 ); + t.equal( y, 1.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.native.js index 08e9ba884fdd..47e6e6ebcbc7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.native.js @@ -81,6 +81,24 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns t.end(); }); +tape( 'if provided `0` for `t` and valid `a`, `b` and `c`, the function returns `1`', function test( t ) { + var y; + + y = mgf( 0.0, -1.0, -1.0, -1.0 ); + t.equal( y, 1.0, 'returns expected value' ); + + y = mgf( 0.0, 0.0, 1.0, 0.5 ); + t.equal( y, 1.0, 'returns expected value' ); + + y = mgf( 0.0, 0.0, 1.0, 1.0 ); + t.equal( y, 1.0, 'returns expected value' ); + + y = mgf( 0.0, 1.0, 1.0, 1.0 ); + t.equal( y, 1.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function evaluates the MGF for `x` given a small range `b - a`', opts, function test( t ) { var expected; var delta;