-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
asyncFunctions.js
39 lines (34 loc) · 937 Bytes
/
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
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(100);
if (supportsAsync()) {
require('./es2017/asyncFunctions.js')();
} else {
it('should not test async functions in this environment');
}
if (supportsAsyncGenerators()) {
require('./es2017/asyncGenerators.js')();
} else {
it('should not test async generators in this environment');
}
});