This repository was archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathiqr_test.hhs
More file actions
52 lines (40 loc) · 1.4 KB
/
iqr_test.hhs
File metadata and controls
52 lines (40 loc) · 1.4 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* @Author Jianan Lin
* test for iqr function
*/
function iqr_test() {
*import math: iqr
// length = 11, borderline = 5
if (iqr(1, 2, 5, 6, 7, 9, 12, 15, 18, 19, 27) !== 13) {
throw new Error('Unit test failed for iqr for number');
}
// length = 9, borderline = 4
if (iqr(2, 5, 11, 13, 19, 26, 32, 40, 50) !== 28) {
throw new Error('Unit test failed for iqr for number');
}
// length = 10, borderline = 5
if (iqr(3, 5, 7, 8, 9, 11, 15, 16, 20, 21) !== 9) {
throw new Error('Unit test failed for iqr for number');
}
// length = 8, borderline = 4
if (iqr(1, 2, 4, 7, 11, 18, 30, 55) !== 21) {
throw new Error('Unit test failed for iqr for number');
}
// length = 11, borderline = 5
if (iqr([1, 2, 5, 6, 7, 9, 12, 15, 18, 19, 27]) !== 13) {
throw new Error('Unit test failed for iqr for array');
}
// length = 9, borderline = 4
if (iqr([2, 5, 11, 13, 19, 26, 32, 40, 50]) !== 28) {
throw new Error('Unit test failed for iqr for array');
}
// length = 10, borderline = 5
if (iqr([3, 5, 7, 8, 9, 11, 15, 16, 20, 21]) !== 9) {
throw new Error('Unit test failed for iqr for array');
}
// length = 8, borderline = 4
if (iqr([1, 2, 4, 7, 11, 18, 30, 55]) !== 21) {
throw new Error('Unit test failed for iqr for array');
}
//print('iqr test pass');
}