Refactor to reduce code repetition

closes #5
This commit is contained in:
Giora Guttsait 2017-09-25 23:09:23 +03:00
parent 26ca195302
commit 4850b97143
2 changed files with 53 additions and 62 deletions

24
test.js
View file

@ -10,7 +10,11 @@ const ErrorSubclassFixture = class extends Error {};
const types = new Map([
['undefined', undefined],
['null', null],
['string', '🦄'],
['string', [
'🦄',
'hello world',
''
]],
['number', [
6,
1.4,
@ -247,9 +251,7 @@ test('is.primitive', t => {
Symbol('🦄')
];
for (const el of primitives) {
t.true(m.primitive(el));
}
primitives.forEach(el => t.true(m.primitive(el)));
});
test('is.integer', t => {
@ -320,13 +322,15 @@ test('is.inRange', t => {
t.true(m.inRange(x, 10));
t.true(m.inRange(0, 0));
t.true(m.inRange(-2, -3));
t.false(m.inRange(x, 2));
t.false(m.inRange(-3, -2));
t.throws(() => {
t.true(m.inRange(0));
});
t.throws(() =>
t.true(m.inRange(0))
);
t.throws(() => {
t.true(m.inRange(0, [5]));
});
t.throws(() =>
t.true(m.inRange(0, [5]))
);
});