File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed
test/com/google/javascript/jscomp Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,71 @@ function foo(){ return 4 }
257
257
"4" );
258
258
}
259
259
260
+ @ Test
261
+ public void testInlineFunctions1_arrowFn () {
262
+ test (
263
+ """
264
+ const foo = () => 4;
265
+ foo();
266
+ """ ,
267
+ "4" );
268
+ }
269
+
270
+ @ Test
271
+ public void testInlineFunctions1_arrowFn_block () {
272
+ test (
273
+ """
274
+ const foo = () => { return 4; };
275
+ foo();
276
+ """ ,
277
+ "4" );
278
+ }
279
+
280
+ @ Test
281
+ public void testInlineFunctions1_inArrowFn () {
282
+ test (
283
+ """
284
+ const foo = () => 4;
285
+ (() => foo())();
286
+ """ ,
287
+ "4" );
288
+ }
289
+
290
+ @ Test
291
+ public void testInlineFunctions1_inArrowFn_block () {
292
+ test (
293
+ """
294
+ const foo = () => 4;
295
+ (() => {
296
+ let a = foo();
297
+ [].forEach(() => a += 1);
298
+ return a;
299
+ })();
300
+ """ ,
301
+ // Why is the IIFE not inlined here?
302
+ // This happens whether or not the function references
303
+ // a local.
304
+ """
305
+ (() => {
306
+ let a = 4;
307
+ [].forEach(() => {
308
+ return a = a + 1;
309
+ });
310
+ return a;
311
+ })();
312
+ """ );
313
+ }
314
+
315
+ @ Test
316
+ public void testInlineFunctions1_arrowFnArg () {
317
+ test (
318
+ """
319
+ const bar = (f) => f();
320
+ bar(() => 4);
321
+ """ ,
322
+ "4" );
323
+ }
324
+
260
325
@ Test
261
326
public void testInlineFunctions2 () {
262
327
// inline simple constants
You can’t perform that action at this time.
0 commit comments