(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func 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 | |
| 38 | func TestLowerArrowFunction(t *testing.T) { |
| 39 | expectPrintedTarget(t, 5, "function foo(a) { arr.forEach(e => this.foo(e)) }", |
nothing calls this directly
no test coverage detected
searching dependent graphs…