-
Notifications
You must be signed in to change notification settings - Fork 913
/
Copy pathtests-await-top-level.js
68 lines (66 loc) · 1.7 KB
/
tests-await-top-level.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
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
if (typeof exports !== "undefined") {
var test = require("./driver.js").test
var testFail = require("./driver.js").testFail
}
//------------------------------------------------------------------------------
// await-top-level
//------------------------------------------------------------------------------
testFail("await 1", "Unexpected token (1:6)", {ecmaVersion: 8})
test("await 1", {
"type": "Program",
"start": 0,
"end": 7,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 7,
"expression": {
"type": "AwaitExpression",
"start": 0,
"end": 7,
"argument": {
"type": "Literal",
"start": 6,
"end": 7,
"value": 1
}
}
}
]
}, {allowAwaitOutsideFunction: true, ecmaVersion: 8})
testFail("function foo() {return await 1}", "Unexpected token (1:29)", {ecmaVersion: 8})
testFail("function foo() {return await 1}", "Unexpected token (1:29)", {
allowAwaitOutsideFunction: true,
ecmaVersion: 8
})
// ES2022
test("await 1", {
"type": "Program",
"start": 0,
"end": 7,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 7,
"expression": {
"type": "AwaitExpression",
"start": 0,
"end": 7,
"argument": {
"type": "Literal",
"start": 6,
"end": 7,
"value": 1
}
}
}
]
}, {ecmaVersion: 13, sourceType: "module"})
testFail("function foo() {return await 1}", "Unexpected token (1:29)", {ecmaVersion: 13})
testFail("await 1", "Unexpected token (1:6)", {
allowAwaitOutsideFunction: false,
ecmaVersion: 13
})
testFail("await 1", "Unexpected token (1:6)", {ecmaVersion: 12})