Debian Codegraph @

t/method-signature-simple.t

raw symbols SCIP
1 use lib 't/lib';
2 use Test::More;
3 use TidierTests qw(run_test $indent_tc);
4
5 run_test( <<'RAW', <<'TIDIED', 'Simple method usage', '', );
6 method name1{
7 }
8 sub name2{
9 }
10 RAW
11 method name1 {
12 }
13
14 sub name2 {
15 }
16 TIDIED
17
18 run_test( <<'RAW', <<'TIDIED', 'Simple methods with underscores ', '', );
19 method name_1{
20 }
21 RAW
22 method name_1 {
23 }
24 TIDIED
25
26 run_test( <<'RAW', <<'TIDIED', 'Method with signature', '', );
27 method name1 (class: $that) {
28 }
29 method name2( :$arg1, :$arg2 ){
30 }
31 sub name3 {}
32 RAW
33 method name1 (class: $that) {
34 }
35
36 method name2 ( :$arg1, :$arg2 ) {
37 }
38 sub name3 { }
39 TIDIED
40
41 run_test( <<'RAW', <<'TIDIED', 'Functions', '', );
42 func morning ($name) {
43 say "Hi $name";
44 }
45 RAW
46 func morning ($name) {
47 say "Hi $name";
48 }
49 TIDIED
50
51 run_test( <<'RAW', <<'TIDIED', 'Functions with underscore in name', '', );
52 func morn_ing ($name) {
53 say "Hi $name";
54 }
55 RAW
56 func morn_ing ($name) {
57 say "Hi $name";
58 }
59 TIDIED
60
61 run_test( <<'RAW', <<'TIDIED', 'Functions with multi-line paramaters', '', );
62 func morning ( Str :$name,
63 Int :$age,
64 ) {
65 say "Hi $name";
66 }
67 RAW
68 func morning ( Str :$name,
69 Int :$age,
70 ) {
71 say "Hi $name";
72 }
73 TIDIED
74
75 run_test( <<'RAW', <<"TIDIED", 'With trailing comments', '', );
76 method name1{# Trailing comment
77 }
78 sub name2{ # Trailing comment
79 }
80 RAW
81 method name1 { # Trailing comment
82 }
83
84 sub name2 {$indent_tc# Trailing comment
85 }
86 TIDIED
87
88 run_test( <<'RAW', <<"TIDIED", 'With attribs trailing comments', '', );
89 method name1 :Attrib(Arg) {# comment
90 }
91 sub name2 :Attrib(Arg) { # comment
92 }
93 RAW
94 method name1 :Attrib(Arg) { # comment
95 }
96
97 sub name2 : Attrib(Arg) {$indent_tc# comment
98 }
99 TIDIED
100
101 done_testing;