Add regression tests for regenerator (#10223)

* Add regression tests for regenerator

* Update tests
This commit is contained in:
Nicolò Ribaudo 2020-03-23 20:49:59 +01:00 committed by GitHub
parent 2f549886e4
commit d23f0ae0ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import { someAction } from 'actions';
function* foo() {
const someAction = bar;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["transform-regenerator", "transform-modules-commonjs"]
}

View File

@ -0,0 +1,19 @@
"use strict";
var _actions = require("actions");
var _marked = /*#__PURE__*/regeneratorRuntime.mark(foo);
function foo() {
var someAction;
return regeneratorRuntime.wrap(function foo$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
someAction = bar;
case 1:
case "end":
return _context.stop();
}
}, _marked);
}

View File

@ -0,0 +1,5 @@
async function foo() {
(async function (number) {
const tmp = number
})
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["transform-regenerator"]
}

View File

@ -0,0 +1,24 @@
function foo() {
return regeneratorRuntime.async(function foo$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
(function _callee(number) {
var tmp;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
tmp = number;
case 1:
case "end":
return _context.stop();
}
}, null, null, null, Promise);
});
case 1:
case "end":
return _context2.stop();
}
}, null, null, null, Promise);
}

View File

@ -0,0 +1,7 @@
<Component>
{() => {
const saveSession = async () => {
const newSessionId = await someAsyncFunc();
};
}}
</Component>;

View File

@ -0,0 +1,4 @@
{
"presets": ["react"],
"plugins": ["transform-regenerator"]
}

View File

@ -0,0 +1,20 @@
/*#__PURE__*/
React.createElement(Component, null, () => {
const saveSession = () => {
var newSessionId;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return regeneratorRuntime.awrap(someAsyncFunc());
case 2:
newSessionId = _context.sent;
case 3:
case "end":
return _context.stop();
}
}, null, null, null, Promise);
};
});