-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumber.test.ts
73 lines (65 loc) · 1.48 KB
/
number.test.ts
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { assertStrictEq, prepareTest } from "../test.mod.ts";
import { extend } from "./extend.ts";
import {
divFloor,
divModFloor,
divRem,
gcd,
isBetween,
isEven,
isMultipleOf,
isNumber,
isOdd,
lcm,
modFloor,
range
} from "./number.ts";
extend({
number: [
divFloor,
divModFloor,
divRem,
gcd,
isBetween,
isEven,
isMultipleOf,
isNumber,
isOdd,
lcm,
modFloor,
range
]
});
async function willExtendNumberPrototype() {
const extensions = [
["Number.prototype.divFloor", "divFloor"],
["Number.prototype.divModFloor", "divModFloor"],
["Number.prototype.divRem", "divRem"],
["Number.prototype.gcd", "gcd"],
["Number.prototype.isBetween", "isBetween"],
["Number.prototype.isEven", "isEven"],
["Number.prototype.isMultipleOf", "isMultipleOf"],
["Number.prototype.isOdd", "isOdd"],
["Number.prototype.lcm", "lcm"],
["Number.prototype.modFloor", "modFloor"]
];
const expectation = extensions.every(([_, methodName]) => {
return methodName in Number.prototype;
});
assertStrictEq(expectation, true);
}
async function willExtendNumberConstructor() {
const extensions = [
["Number.isNumber", "isNumber"],
["Number.range", "range"]
];
const expectation = extensions.every(([_, methodName]) => {
return methodName in Number;
});
assertStrictEq(expectation, true);
}
prepareTest(
[willExtendNumberConstructor, willExtendNumberPrototype],
"jsmodern",
"number"
);