forked from angus-c/just
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (29 loc) · 735 Bytes
/
Copy pathindex.js
File metadata and controls
32 lines (29 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var test = require('../util/test')(__filename);
var mean = require('../../packages/array-mean');
test('array of numbers returns mean', function(t) {
t.plan(3);
t.equal(mean([1, 2, 3, 2, 4, 1]).toFixed(4), '2.1667');
t.equal(mean([4.5, -1.1, 98.6]), 34);
t.equal(mean([4]), 4);
t.end();
});
test('list of numeric arguments returns mean', function(t) {
t.plan(3);
t.equal(mean(1, 2, 5, 2, 4, 1), 2.5);
t.equal(mean(100, 100, 100.1, 100), 100.025);
t.equal(mean(-4), -4);
t.end();
});
test('non-numeric values throw', function(t) {
t.plan(3);
t.throws(function() {
mean([1, '2', 3, 4]);
});
t.throws(function() {
mean({a: 2});
});
t.throws(function() {
mean(undefined);
});
t.end();
});