18
18
suggest_spec /1 ,
19
19
extract_function /1 ,
20
20
extract_function_case /1 ,
21
- extract_function_tuple /1
21
+ extract_function_tuple /1 ,
22
+ extract_function_list_comp /1
22
23
]).
23
24
24
25
% %==============================================================================
@@ -57,7 +58,8 @@ init_per_testcase(TestCase, Config0) when
57
58
TestCase =:= ct_run_test ;
58
59
TestCase =:= extract_function ;
59
60
TestCase =:= extract_function_case ;
60
- TestCase =:= extract_function_tuple
61
+ TestCase =:= extract_function_tuple ;
62
+ TestCase =:= extract_function_list_comp
61
63
->
62
64
Config = els_test_utils :init_per_testcase (TestCase , Config0 ),
63
65
setup_mocks (),
@@ -82,7 +84,8 @@ end_per_testcase(TestCase, Config) when
82
84
TestCase =:= ct_run_test ;
83
85
TestCase =:= extract_function ;
84
86
TestCase =:= extract_function_case ;
85
- TestCase =:= extract_function_tuple
87
+ TestCase =:= extract_function_tuple ;
88
+ TestCase =:= extract_function_list_comp
86
89
->
87
90
teardown_mocks (),
88
91
els_test_utils :end_per_testcase (TestCase , Config );
@@ -285,8 +288,8 @@ extract_function(Config) ->
285
288
" A + B + C.\n\n "
286
289
>>,
287
290
range := #{
288
- 'end' := #{character := 0 , line := 14 },
289
- start := #{character := 0 , line := 14 }
291
+ 'end' := #{character := 0 , line := 15 },
292
+ start := #{character := 0 , line := 15 }
290
293
}
291
294
}
292
295
] = Changes .
@@ -315,12 +318,40 @@ extract_function_case(Config) ->
315
318
>>,
316
319
range :=
317
320
#{
318
- 'end' := #{character := 0 , line := 14 },
319
- start := #{character := 0 , line := 14 }
321
+ 'end' := #{character := 0 , line := 15 },
322
+ start := #{character := 0 , line := 15 }
320
323
}
321
324
}
322
325
] = Changes .
323
326
327
+ -spec extract_function_list_comp (config ()) -> ok .
328
+ extract_function_list_comp (Config ) ->
329
+ Uri = ? config (extract_function_uri , Config ),
330
+ execute_command_refactor_extract (Uri , {13 , 4 }, {13 , 32 }),
331
+ [#{edit := #{changes := #{Uri := Changes }}}] = get_edits_from_meck_history (),
332
+ [
333
+ #{
334
+ range :=
335
+ #{
336
+ start := #{line := 13 , character := 4 },
337
+ 'end' := #{line := 13 , character := 32 }
338
+ },
339
+ newText := <<" new_function(A, B, C)" >>
340
+ },
341
+ #{
342
+ range :=
343
+ #{
344
+ start := #{line := 15 , character := 0 },
345
+ 'end' := #{line := 15 , character := 0 }
346
+ },
347
+ newText :=
348
+ <<
349
+ " new_function(A, B, C) ->\n "
350
+ " [X || X <- [A, B, C], X > 1].\n\n "
351
+ >>
352
+ }
353
+ ] = Changes .
354
+
324
355
-spec extract_function_tuple (config ()) -> ok .
325
356
extract_function_tuple (Config ) ->
326
357
Uri = ? config (extract_function_uri , Config ),
@@ -343,8 +374,8 @@ extract_function_tuple(Config) ->
343
374
>>,
344
375
range :=
345
376
#{
346
- 'end' := #{character := 0 , line := 14 },
347
- start := #{character := 0 , line := 14 }
377
+ 'end' := #{character := 0 , line := 15 },
378
+ start := #{character := 0 , line := 15 }
348
379
}
349
380
}
350
381
] = Changes .
0 commit comments