2018-05-03 19:25:52 +00:00
|
|
|
"use strict";
|
|
|
|
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
|
|
|
|
|
|
|
|
const cases = [];
|
|
|
|
cases.push({
|
|
|
|
title: "Async anonymous function closure (js)",
|
2021-08-10 18:31:59 +00:00
|
|
|
// eslint-disable-next-line
|
2018-05-03 19:25:52 +00:00
|
|
|
func: async function (a) { await a; },
|
|
|
|
expectText: `exports.handler = __f0;
|
|
|
|
|
2019-05-21 02:19:22 +00:00
|
|
|
function __f0(__0) {
|
2018-05-03 19:25:52 +00:00
|
|
|
return (function() {
|
2023-05-09 18:50:28 +00:00
|
|
|
with({ this: undefined, arguments: undefined }) {
|
2018-05-03 19:25:52 +00:00
|
|
|
|
|
|
|
return async function (a) { await a; };
|
|
|
|
|
|
|
|
}
|
|
|
|
}).apply(undefined, undefined).apply(this, arguments);
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
cases.push({
|
|
|
|
title: "Async anonymous function closure - extra space (js)",
|
2021-08-10 18:31:59 +00:00
|
|
|
// eslint-disable-next-line
|
2018-05-03 19:25:52 +00:00
|
|
|
func: async function (a) { await a; },
|
|
|
|
expectText: `exports.handler = __f0;
|
|
|
|
|
2019-05-21 02:19:22 +00:00
|
|
|
function __f0(__0) {
|
2018-05-03 19:25:52 +00:00
|
|
|
return (function() {
|
2023-05-09 18:50:28 +00:00
|
|
|
with({ this: undefined, arguments: undefined }) {
|
2018-05-03 19:25:52 +00:00
|
|
|
|
|
|
|
return async function (a) { await a; };
|
|
|
|
|
|
|
|
}
|
|
|
|
}).apply(undefined, undefined).apply(this, arguments);
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
cases.push({
|
|
|
|
title: "Async named function closure (js)",
|
2021-08-10 18:31:59 +00:00
|
|
|
// eslint-disable-next-line
|
2018-05-03 19:25:52 +00:00
|
|
|
func: async function foo(a) { await a; },
|
|
|
|
expectText: `exports.handler = __foo;
|
|
|
|
|
2019-05-21 02:19:22 +00:00
|
|
|
function __foo(__0) {
|
2018-05-03 19:25:52 +00:00
|
|
|
return (function() {
|
2023-05-09 18:50:28 +00:00
|
|
|
with({ foo: __foo, this: undefined, arguments: undefined }) {
|
2018-05-03 19:25:52 +00:00
|
|
|
|
|
|
|
return async function /*foo*/(a) { await a; };
|
|
|
|
|
|
|
|
}
|
|
|
|
}).apply(undefined, undefined).apply(this, arguments);
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
cases.push({
|
|
|
|
title: "Async arrow function closure (js)",
|
2021-08-10 18:31:59 +00:00
|
|
|
// eslint-disable-next-line
|
2018-05-03 19:25:52 +00:00
|
|
|
func: async (a) => { await a; },
|
|
|
|
expectText: `exports.handler = __f0;
|
|
|
|
|
2019-05-21 02:19:22 +00:00
|
|
|
function __f0(__0) {
|
2018-05-03 19:25:52 +00:00
|
|
|
return (function() {
|
2023-05-09 18:50:28 +00:00
|
|
|
with({ this: undefined, arguments: undefined }) {
|
2018-05-03 19:25:52 +00:00
|
|
|
|
|
|
|
return async (a) => { await a; };
|
|
|
|
|
|
|
|
}
|
|
|
|
}).apply(undefined, undefined).apply(this, arguments);
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2018-05-24 18:54:31 +00:00
|
|
|
cases.push({
|
|
|
|
title: "Function captures V8 intrinsic (js)",
|
|
|
|
func: () => { %AbortJS(0) },
|
2019-03-22 22:33:37 +00:00
|
|
|
error: `Error serializing function 'func': jsClosureCases_8.js(0,0)
|
2018-05-24 18:54:31 +00:00
|
|
|
|
2019-03-22 22:33:37 +00:00
|
|
|
function 'func': jsClosureCases_8.js(0,0): which could not be serialized because
|
2018-05-24 18:54:31 +00:00
|
|
|
the function could not be parsed: (...)
|
|
|
|
|
|
|
|
Function code:
|
|
|
|
() => { %AbortJS(0) }`
|
|
|
|
});
|
|
|
|
|
2018-05-03 19:25:52 +00:00
|
|
|
|
|
|
|
module.exports.cases = cases;
|
|
|
|
|