| 1 | use lib 't/lib'; |
| 2 | use Test::More; |
| 3 | use TidierTests; |
| 4 | |
| 5 | run_test( <<'RAW', <<'TIDIED', 'RT#83511 - () { rewriten as { ()', '', ); |
| 6 | method name1 () { |
| 7 | } |
| 8 | method name2(){ |
| 9 | } |
| 10 | RAW |
| 11 | method name1 () { |
| 12 | } |
| 13 | |
| 14 | method name2 () { |
| 15 | } |
| 16 | TIDIED |
| 17 | |
| 18 | run_test( <<'RAW', <<'TIDIED', 'RT#83511 - same for func', '', ); |
| 19 | func name1 () { |
| 20 | } |
| 21 | func name2(){ |
| 22 | } |
| 23 | RAW |
| 24 | func name1 () { |
| 25 | } |
| 26 | |
| 27 | func name2 () { |
| 28 | } |
| 29 | TIDIED |
| 30 | |
| 31 | run_test( <<'RAW', <<'TIDIED', 'RT#84868 - prototype with ()', '', ); |
| 32 | func nm (Any $a where qr{(foo)}) { |
| 33 | } |
| 34 | func name2(){ |
| 35 | } |
| 36 | RAW |
| 37 | func nm (Any $a where qr{(foo)}) { |
| 38 | } |
| 39 | |
| 40 | func name2 () { |
| 41 | } |
| 42 | TIDIED |
| 43 | |
| 44 | run_test( <<'RAW', <<'TIDIED', 'RT#84868 - prototype with multiple ()', '', ); |
| 45 | func nm (Any $a where qr{(f)(o)}) { |
| 46 | } |
| 47 | func name2(){ |
| 48 | } |
| 49 | RAW |
| 50 | func nm (Any $a where qr{(f)(o)}) { |
| 51 | } |
| 52 | |
| 53 | func name2 () { |
| 54 | } |
| 55 | TIDIED |
| 56 | |
| 57 | run_test( <<'RAW', <<'TIDIED', 'RT#84868 - Multiple line signatures', '', ); |
| 58 | method nm (Str $bar, |
| 59 | Int $foo where { $_>(0) } |
| 60 | ) { |
| 61 | } |
| 62 | RAW |
| 63 | method nm (Str $bar, |
| 64 | Int $foo where { $_>(0) } |
| 65 | ) { |
| 66 | } |
| 67 | TIDIED |
| 68 | |
| 69 | run_test( <<'RAW', <<'TIDIED', 'RT#84868 - Multiple line signatures w/ comment', '', ); |
| 70 | method nm (Str $bar, |
| 71 | Int $foo where { $_ > (0) } |
| 72 | ) { # Fun stuff |
| 73 | } |
| 74 | RAW |
| 75 | method nm (Str $bar, |
| 76 | Int $foo where { $_ > (0) } |
| 77 | ) { # Fun stuff |
| 78 | } |
| 79 | TIDIED |
| 80 | |
| 81 | run_test( <<'RAW', <<'TIDIED', 'RT#85076 - handle returns() with signature ', '', ); |
| 82 | method foo ( File :$file! ) returns(Bool) { |
| 83 | } |
| 84 | RAW |
| 85 | method foo ( File :$file! ) returns(Bool) { |
| 86 | } |
| 87 | TIDIED |
| 88 | |
| 89 | run_test( <<'RAW', <<'TIDIED', 'RT#85076 - handle returns()', '', ); |
| 90 | method foo returns(Bool) { |
| 91 | } |
| 92 | RAW |
| 93 | method foo returns(Bool) { |
| 94 | } |
| 95 | TIDIED |
| 96 | |
| 97 | run_test( <<'RAW', <<'TIDIED', 'RT#94633 - class WORD::WORD {}', '', ); |
| 98 | class WORD::WORD { |
| 99 | } |
| 100 | |
| 101 | class WORD { |
| 102 | } |
| 103 | |
| 104 | sub mysub:ATTRIBUTE { |
| 105 | } |
| 106 | RAW |
| 107 | class WORD::WORD { |
| 108 | } |
| 109 | |
| 110 | class WORD { |
| 111 | } |
| 112 | |
| 113 | sub mysub : ATTRIBUTE { |
| 114 | } |
| 115 | TIDIED |
| 116 | |
| 117 | run_test( <<'RAW', <<'TIDIED', 'RT#106398 - Long single line subs', '', ); |
| 118 | sub test ($param) {$param->test->that->breaks->perltidysweetened} |
| 119 | RAW |
| 120 | sub test ($param) { $param->test->that->breaks->perltidysweetened } |
| 121 | TIDIED |
| 122 | |
| 123 | run_test( <<'RAW', <<'TIDIED', 'RT#106398 - Long single line subs w/o params', '', ); |
| 124 | sub test {$param->this->is->a->test->that->breaks->perltidysweetened} |
| 125 | RAW |
| 126 | sub test { |
| 127 | $param->this->is->a->test->that->breaks |
| 128 | ->perltidysweetened; |
| 129 | } |
| 130 | TIDIED |
| 131 | |
| 132 | run_test( <<'RAW', <<'TIDIED', 'RT#106464 - MooseX::Role::Parameterized', '', ); |
| 133 | method _path => sub {$path}; |
| 134 | RAW |
| 135 | method _path => sub { $path }; |
| 136 | TIDIED |
| 137 | |
| 138 | done_testing; |