-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathasyncFunctions.js
42 lines (37 loc) · 1.06 KB
/
asyncFunctions.js
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
var {isAsync} = require('../lib/internal/wrapAsync');
function supportsAsync() {
var supported;
try {
/* eslint no-eval: 0 */
supported = isAsync(eval('(async function () {})'));
} catch (e) {
supported = false;
}
return supported;
}
function supportsAsyncGenerators() {
var supported;
try {
/* eslint no-eval: 0 */
supported = eval('(async function * () { yield await 1 })');
} catch (e) {
supported = false;
}
return supported;
}
describe('async function support', function () {
this.timeout(200);
if (supportsAsync()) {
require('./es2017/asyncFunctions.js').call(this);
describe('awaitable functions', () => {
require('./es2017/awaitableFunctions.js').call(this);
});
} else {
it('should not test async functions in this environment');
}
if (supportsAsyncGenerators()) {
require('./es2017/asyncGenerators.js').call(this);
} else {
it('should not test async generators in this environment');
}
});