Debian Codegraph @

t/moosex-method-signatures.t

raw symbols SCIP
1 use lib 't/lib';
2 use Test::More;
3 use TidierTests;
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', 'Method with signature', '', );
19 method name1 (class: $that) {
20 }
21 method name2( :$arg1, :$arg2 ){
22 }
23 sub name3 {}
24 RAW
25 method name1 (class: $that) {
26 }
27
28 method name2 ( :$arg1, :$arg2 ) {
29 }
30 sub name3 { }
31 TIDIED
32
33 run_test( <<'RAW', <<'TIDIED', 'With paramater typing', '', );
34 method morning (Str $name) {
35 $self->say("Hi ${name}!");
36 }
37 RAW
38 method morning (Str $name) {
39 $self->say("Hi ${name}!");
40 }
41 TIDIED
42
43 run_test( <<'RAW', <<'TIDIED', 'With params with constraints', '', );
44 method hello (:$age where { $_ > 0 }) {
45 }
46 RAW
47 method hello (:$age where { $_ > 0 }) {
48 }
49 TIDIED
50
51 run_test( <<'RAW', <<'TIDIED', 'Multiple line signatures', '', );
52 method name1 (Str $bar,
53 Int $foo where { $_ > 0 }
54 ) {
55 }
56 RAW
57 method name1 (Str $bar,
58 Int $foo where { $_ > 0 }
59 ) {
60 }
61 TIDIED
62
63 run_test( <<'RAW', <<'TIDIED', 'Multiple line signatures w/ comment ', '', );
64 method name1 (Str $bar,
65 Int $foo where { $_ > 0 }
66 ) { # Fun stuff
67 }
68 RAW
69 method name1 (Str $bar,
70 Int $foo where { $_ > 0 }
71 ) { # Fun stuff
72 }
73 TIDIED
74
75 run_test( <<'RAW', <<'TIDIED', 'RT#85076 - handle returns() with signature ', '', );
76 method foo ( File :$file! ) returns(Bool) {
77 }
78 RAW
79 method foo ( File :$file! ) returns(Bool) {
80 }
81 TIDIED
82
83 run_test( <<'RAW', <<'TIDIED', 'RT#85076 - handle returns()', '', );
84 method foo returns (Bool) {
85 }
86 RAW
87 method foo returns (Bool) {
88 }
89 TIDIED
90
91 done_testing;