From ef8e30419c2db864e62f62bedf1a2069a0fdc21d Mon Sep 17 00:00:00 2001 From: Zoe Carver Date: Wed, 27 Sep 2017 09:00:14 -0700 Subject: [PATCH] Add yield-result (#737) --- .../yield-extra-parentheses/actual.js | 3 + .../yield-extra-parentheses/expected.json | 245 ++++++++++++++++++ test/fixtures/flow/typecasts/yield/actual.js | 3 + .../flow/typecasts/yield/expected.json | 241 +++++++++++++++++ 4 files changed, 492 insertions(+) create mode 100644 test/fixtures/flow/typecasts/yield-extra-parentheses/actual.js create mode 100644 test/fixtures/flow/typecasts/yield-extra-parentheses/expected.json create mode 100644 test/fixtures/flow/typecasts/yield/actual.js create mode 100644 test/fixtures/flow/typecasts/yield/expected.json diff --git a/test/fixtures/flow/typecasts/yield-extra-parentheses/actual.js b/test/fixtures/flow/typecasts/yield-extra-parentheses/actual.js new file mode 100644 index 0000000000..7919e4ac81 --- /dev/null +++ b/test/fixtures/flow/typecasts/yield-extra-parentheses/actual.js @@ -0,0 +1,3 @@ +function* foo(z) { + const x = ((yield 3): any) +} \ No newline at end of file diff --git a/test/fixtures/flow/typecasts/yield-extra-parentheses/expected.json b/test/fixtures/flow/typecasts/yield-extra-parentheses/expected.json new file mode 100644 index 0000000000..75f6b756bf --- /dev/null +++ b/test/fixtures/flow/typecasts/yield-extra-parentheses/expected.json @@ -0,0 +1,245 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "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": [ + { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "z" + }, + "name": "z" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 21, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 27, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "TypeCastExpression", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "expression": { + "type": "YieldExpression", + "start": 33, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "delegate": false, + "argument": { + "type": "NumericLiteral", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "extra": { + "rawValue": 3, + "raw": "3" + }, + "value": 3 + }, + "extra": { + "parenthesized": true, + "parenStart": 32 + } + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 41, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "typeAnnotation": { + "type": "AnyTypeAnnotation", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 31 + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/typecasts/yield/actual.js b/test/fixtures/flow/typecasts/yield/actual.js new file mode 100644 index 0000000000..b30cd18061 --- /dev/null +++ b/test/fixtures/flow/typecasts/yield/actual.js @@ -0,0 +1,3 @@ +function* foo(z) { + const x = (yield 3: any) +} \ No newline at end of file diff --git a/test/fixtures/flow/typecasts/yield/expected.json b/test/fixtures/flow/typecasts/yield/expected.json new file mode 100644 index 0000000000..b6e005a8e2 --- /dev/null +++ b/test/fixtures/flow/typecasts/yield/expected.json @@ -0,0 +1,241 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 47, + "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": [ + { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "z" + }, + "name": "z" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 21, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 27, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "TypeCastExpression", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "expression": { + "type": "YieldExpression", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "delegate": false, + "argument": { + "type": "NumericLiteral", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "extra": { + "rawValue": 3, + "raw": "3" + }, + "value": 3 + } + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 39, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "typeAnnotation": { + "type": "AnyTypeAnnotation", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 31 + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file