Add is.generator() and is.generatorFunction() (#4)
This commit is contained in:
parent
000f66bbdc
commit
dbe5cc8d82
3 changed files with 26 additions and 1 deletions
16
test.js
16
test.js
|
|
@ -58,6 +58,9 @@ const types = new Map([
|
|||
PromiseSubclassFixture.resolve()
|
||||
]],
|
||||
['promise', {then() {}, catch() {}}],
|
||||
['generator', (function * () {
|
||||
yield 42;
|
||||
})()],
|
||||
['map', new Map()],
|
||||
['set', new Set()],
|
||||
['weakMap', new WeakMap()],
|
||||
|
|
@ -86,7 +89,7 @@ const types = new Map([
|
|||
['integer', 6]
|
||||
]);
|
||||
|
||||
// This ensure a certain method matches only the types
|
||||
// This ensures a certain method matches only the types
|
||||
// it's supposed to and none of the other methods' types
|
||||
const testType = (t, type, exclude) => {
|
||||
for (const [key, value] of types) {
|
||||
|
|
@ -170,6 +173,17 @@ if (isNode8orHigher) {
|
|||
});
|
||||
}
|
||||
|
||||
test('is.generator', t => {
|
||||
testType(t, 'generator', ['function']);
|
||||
});
|
||||
|
||||
test('is.generatorFunction', t => {
|
||||
const gen = function * () {
|
||||
yield 42;
|
||||
};
|
||||
t.true(m.generatorFunction(gen));
|
||||
});
|
||||
|
||||
test('is.map', t => {
|
||||
testType(t, 'map');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue