MCPcopy
hub / github.com/evanw/esbuild / TestLowerFunctionArgumentScope

Function TestLowerFunctionArgumentScope

internal/js_parser/js_parser_lower_test.go:10–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestLowerFunctionArgumentScope(t *testing.T) {
11 templates := []string{
12 "(x = %s) => {\n};\n",
13 "(function(x = %s) {\n});\n",
14 "function foo(x = %s) {\n}\n",
15
16 "({ [%s]: x }) => {\n};\n",
17 "(function({ [%s]: x }) {\n});\n",
18 "function foo({ [%s]: x }) {\n}\n",
19
20 "({ x = %s }) => {\n};\n",
21 "(function({ x = %s }) {\n});\n",
22 "function foo({ x = %s }) {\n}\n",
23 }
24
25 for _, template := range templates {
26 test := func(before string, after string) {
27 expectPrintedTarget(t, 2015, fmt.Sprintf(template, before), fmt.Sprintf(template, after))
28 }
29
30 test("a() ?? b", "((_a) => (_a = a()) != null ? _a : b)()")
31 test("a()?.b", "((_a) => (_a = a()) == null ? void 0 : _a.b)()")
32 test("a?.b?.()", "((_a) => (_a = a == null ? void 0 : a.b) == null ? void 0 : _a.call(a))()")
33 test("a.b.c?.()", "((_a) => ((_b) => (_b = (_a = a.b).c) == null ? void 0 : _b.call(_a))())()")
34 test("class { static a }", "((_a) => (_a = class {\n}, __publicField(_a, \"a\"), _a))()")
35 }
36}
37
38func TestLowerArrowFunction(t *testing.T) {
39 expectPrintedTarget(t, 5, "function foo(a) { arr.forEach(e => this.foo(e)) }",

Callers

nothing calls this directly

Calls 2

expectPrintedTargetFunction · 0.70
testFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…