Merge pull request #613 from jridgewell/function-sent-statement
Fix function.sent parsing
This commit is contained in:
commit
cc643668c8
@ -802,13 +802,12 @@ export default class ExpressionParser extends LValParser {
|
||||
const meta = this.parseIdentifier(true);
|
||||
if (
|
||||
this.state.inGenerator &&
|
||||
this.eat(tt.dot) &&
|
||||
this.hasPlugin("functionSent")
|
||||
this.hasPlugin("functionSent") &&
|
||||
this.eat(tt.dot)
|
||||
) {
|
||||
return this.parseMetaProperty(node, meta, "sent");
|
||||
} else {
|
||||
return this.parseFunction(node, false);
|
||||
}
|
||||
return this.parseFunction(node, false);
|
||||
}
|
||||
|
||||
parseMetaProperty(
|
||||
|
||||
@ -94,6 +94,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
case tt._for:
|
||||
return this.parseForStatement(node);
|
||||
case tt._function:
|
||||
if (this.lookahead().type === tt.dot) break;
|
||||
if (!declaration) this.unexpected();
|
||||
return this.parseFunctionStatement(node);
|
||||
|
||||
|
||||
3
test/fixtures/experimental/function-sent/disabled-function-keyword-declaration/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/disabled-function-keyword-declaration/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
function.sent() {}
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/disabled-function-keyword-declaration/options.json
vendored
Normal file
3
test/fixtures/experimental/function-sent/disabled-function-keyword-declaration/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ( (2:10)"
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/disabled-function-keyword-expression/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/disabled-function-keyword-expression/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
(function.sent() {});
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/disabled-function-keyword-expression/options.json
vendored
Normal file
3
test/fixtures/experimental/function-sent/disabled-function-keyword-expression/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ( (2:11)"
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/disabled-inside-generator/options.json
vendored
Normal file
3
test/fixtures/experimental/function-sent/disabled-inside-generator/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ( (2:17)"
|
||||
}
|
||||
4
test/fixtures/experimental/function-sent/enabled-asi-funciton-declaration/actual.js
vendored
Normal file
4
test/fixtures/experimental/function-sent/enabled-asi-funciton-declaration/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
function* foo() {
|
||||
function.sent()
|
||||
{}
|
||||
}
|
||||
185
test/fixtures/experimental/function-sent/enabled-asi-funciton-declaration/expected.json
vendored
Normal file
185
test/fixtures/experimental/function-sent/enabled-asi-funciton-declaration/expected.json
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": true,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 16,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 20,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start": 20,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "MetaProperty",
|
||||
"start": 20,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"type": "Identifier",
|
||||
"start": 20,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "function"
|
||||
},
|
||||
"name": "function"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 29,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "sent"
|
||||
},
|
||||
"name": "sent"
|
||||
}
|
||||
},
|
||||
"arguments": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BlockStatement",
|
||||
"start": 38,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-call-statement/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-call-statement/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
function.sent();
|
||||
}
|
||||
168
test/fixtures/experimental/function-sent/enabled-call-statement/expected.json
vendored
Normal file
168
test/fixtures/experimental/function-sent/enabled-call-statement/expected.json
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": true,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 16,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 20,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start": 20,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "MetaProperty",
|
||||
"start": 20,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"type": "Identifier",
|
||||
"start": 20,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "function"
|
||||
},
|
||||
"name": "function"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 29,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "sent"
|
||||
},
|
||||
"name": "sent"
|
||||
}
|
||||
},
|
||||
"arguments": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-call-statement/options.json
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-call-statement/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["functionSent"]
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-call/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-call/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
(function.sent());
|
||||
}
|
||||
172
test/fixtures/experimental/function-sent/enabled-call/expected.json
vendored
Normal file
172
test/fixtures/experimental/function-sent/enabled-call/expected.json
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": true,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 16,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 20,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start": 21,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "MetaProperty",
|
||||
"start": 21,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"type": "Identifier",
|
||||
"start": 21,
|
||||
"end": 29,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "function"
|
||||
},
|
||||
"name": "function"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 30,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"identifierName": "sent"
|
||||
},
|
||||
"name": "sent"
|
||||
}
|
||||
},
|
||||
"arguments": [],
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 20
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-call/options.json
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-call/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["functionSent"]
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-function-keyword-declaration/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-function-keyword-declaration/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
function.sent() {}
|
||||
}
|
||||
4
test/fixtures/experimental/function-sent/enabled-function-keyword-declaration/options.json
vendored
Normal file
4
test/fixtures/experimental/function-sent/enabled-function-keyword-declaration/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["functionSent"],
|
||||
"throws": "Unexpected token, expected ; (2:18)"
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-function-keyword-expression/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-function-keyword-expression/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
(function.sent() {});
|
||||
}
|
||||
4
test/fixtures/experimental/function-sent/enabled-function-keyword-expression/options.json
vendored
Normal file
4
test/fixtures/experimental/function-sent/enabled-function-keyword-expression/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["functionSent"],
|
||||
"throws": "Unexpected token, expected , (2:19)"
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-if-statement/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-if-statement/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
if (true) function.sent;
|
||||
}
|
||||
184
test/fixtures/experimental/function-sent/enabled-if-statement/expected.json
vendored
Normal file
184
test/fixtures/experimental/function-sent/enabled-if-statement/expected.json
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": true,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 16,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "IfStatement",
|
||||
"start": 20,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 26
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"type": "BooleanLiteral",
|
||||
"start": 24,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"value": true
|
||||
},
|
||||
"consequent": {
|
||||
"type": "ExpressionStatement",
|
||||
"start": 30,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 26
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "MetaProperty",
|
||||
"start": 30,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"type": "Identifier",
|
||||
"start": 30,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"identifierName": "function"
|
||||
},
|
||||
"name": "function"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 39,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
},
|
||||
"identifierName": "sent"
|
||||
},
|
||||
"name": "sent"
|
||||
}
|
||||
}
|
||||
},
|
||||
"alternate": null
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-if-statement/options.json
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-if-statement/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["functionSent"]
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-inside-function/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-inside-function/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function foo() {
|
||||
return function.sent;
|
||||
}
|
||||
4
test/fixtures/experimental/function-sent/enabled-inside-function/options.json
vendored
Normal file
4
test/fixtures/experimental/function-sent/enabled-inside-function/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["functionSent"],
|
||||
"throws": "Unexpected token, expected ( (2:17)"
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-inside-generator/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-inside-generator/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
return function.sent;
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-inside-generator/options.json
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-inside-generator/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["functionSent"]
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-statement/actual.js
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-statement/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* foo() {
|
||||
function.sent;
|
||||
}
|
||||
152
test/fixtures/experimental/function-sent/enabled-statement/expected.json
vendored
Normal file
152
test/fixtures/experimental/function-sent/enabled-statement/expected.json
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": true,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 16,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 20,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "MetaProperty",
|
||||
"start": 20,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"type": "Identifier",
|
||||
"start": 20,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "function"
|
||||
},
|
||||
"name": "function"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 29,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "sent"
|
||||
},
|
||||
"name": "sent"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/experimental/function-sent/enabled-statement/options.json
vendored
Normal file
3
test/fixtures/experimental/function-sent/enabled-statement/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["functionSent"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user