Skip to content

Commit 34fc73d

Browse files
committed
feat: add tests
--- 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 ---
1 parent fda1211 commit 34fc73d

File tree

1 file changed

+71
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/bradford/mode/test

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var tape = require( 'tape' );
24+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var NINF = require( '@stdlib/constants/float64/ninf' );
27+
var mode = require( './../lib' );
28+
29+
30+
// TESTS //
31+
32+
tape( 'main export is a function', function test( t ) {
33+
t.ok( true, __filename );
34+
t.strictEqual( typeof mode, 'function', 'main export is a function' );
35+
t.end();
36+
});
37+
38+
tape( 'if provided `NaN` for `c`, the function returns `NaN`', function test( t ) {
39+
var v = mode( NaN );
40+
t.equal( isnan( v ), true, 'returns expected value' );
41+
t.end();
42+
});
43+
44+
tape( 'if provided `c <= 0`, the function returns `NaN`', function test( t ) {
45+
var v;
46+
47+
v = mode( 0.0 );
48+
t.equal( isnan( v ), true, 'returns expected value' );
49+
50+
v = mode( -1.0 );
51+
t.equal( isnan( v ), true, 'returns expected value' );
52+
53+
v = mode( NINF );
54+
t.equal( isnan( v ), true, 'returns expected value' );
55+
56+
t.end();
57+
});
58+
59+
tape( 'the function returns `0.0` as the mode of a Bradford distribution', function test( t ) {
60+
var c;
61+
var i;
62+
var y;
63+
64+
c = uniform( 10, 0.1, 10.0 );
65+
66+
for ( i = 0; i < c.length; i++ ) {
67+
y = mode( c[ i ] );
68+
t.equal( y, 0.0, 'returns expected value' );
69+
}
70+
t.end();
71+
});

0 commit comments

Comments
 (0)