Skip to content

Commit 986de43

Browse files
Aadish JainAadish Jain
authored andcommitted
feat(t-mode): fixing test.native.js
1 parent 7c76b9c commit 986de43

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

lib/node_modules/@stdlib/stats/base/dists/t/mode/test/test.native.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,56 @@ var tryRequire = require( '@stdlib/utils/try-require' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727

2828

29+
// FIXTURES //
30+
31+
var data = require( './fixtures/julia/data.json' );
32+
33+
2934
// VARIABLES //
3035

31-
var mode = tryRequire(resolve(__dirname, './../lib/native.js'));
36+
var median = tryRequire(resolve(__dirname, './../lib/native.js'));
3237
var opts = {
33-
'skip': (mode instanceof Error)
38+
'skip': (median instanceof Error)
3439
};
3540

3641

3742
// TESTS //
3843

3944
tape('main export is a function', opts, function test(t) {
4045
t.ok(true, __filename);
41-
t.strictEqual(typeof mode, 'function', 'main export is a function');
46+
t.strictEqual(typeof median, 'function', 'main export is a function');
4247
t.end();
4348
});
4449

4550
tape('if provided `NaN` for the parameter, the function returns `NaN`', opts, function test(t) {
46-
var y = mode(NaN);
51+
var y = median(NaN);
4752
t.equal(isnan(y), true, 'returns NaN');
4853
t.end();
4954
});
5055

5156
tape('if provided a negative value for `v`, the function returns `NaN`', opts, function test(t) {
5257
var y;
5358

54-
y = mode(-1.0);
59+
y = median(-1.0);
5560
t.equal(isnan(y), true, 'returns NaN');
5661

57-
y = mode(-0.5);
62+
y = median(-0.5);
5863
t.equal(isnan(y), true, 'returns NaN');
5964

6065
t.end();
6166
});
6267

63-
tape('the function evaluates the mode for a Student\'s t-distribution', opts, function test(t) {
68+
tape('the function evaluates the median for a Student\'s t-distribution', opts, function test(t) {
69+
var expected;
70+
var v;
6471
var y;
65-
66-
y = mode(3.0);
67-
t.equal(y, 0.0, 'returns 0.0');
68-
69-
y = mode(5.0);
70-
t.equal(y, 0.0, 'returns 0.0');
71-
72-
y = mode(10.0);
73-
t.equal(y, 0.0, 'returns 0.0');
74-
72+
var i;
73+
74+
for (i = 0; i < data.v.length; i++) {
75+
v = data.v[i];
76+
expected = data.expected[i];
77+
y = median(v);
78+
t.equal(y, expected, 'v: ' + v + ', y: ' + y + ', expected: ' + expected);
79+
}
7580
t.end();
7681
});

0 commit comments

Comments
 (0)