| 1 | use lib 't/lib'; |
| 2 | use Test::More; |
| 3 | use TidierTests; |
| 4 | |
| 5 | run_test( <<'RAW', <<'TIDIED', 'Simple empty class', '', ); |
| 6 | class Point{ |
| 7 | } |
| 8 | sub name3{} |
| 9 | RAW |
| 10 | class Point { |
| 11 | } |
| 12 | sub name3 { } |
| 13 | TIDIED |
| 14 | |
| 15 | run_test( <<'RAW', <<'TIDIED', 'Class with inheritance', '', ); |
| 16 | class Point3D extends Point{ |
| 17 | } |
| 18 | RAW |
| 19 | class Point3D extends Point { |
| 20 | } |
| 21 | TIDIED |
| 22 | |
| 23 | run_test( <<'RAW', <<'TIDIED', 'Class with attribute', '', ); |
| 24 | class Point { |
| 25 | has $!x; |
| 26 | } |
| 27 | |
| 28 | sub name3 {} |
| 29 | RAW |
| 30 | class Point { |
| 31 | has $!x; |
| 32 | } |
| 33 | |
| 34 | sub name3 { } |
| 35 | TIDIED |
| 36 | |
| 37 | run_test( <<'RAW', <<'TIDIED', 'Class with attribute and trait', '', ); |
| 38 | class Point { |
| 39 | has $!x is ro; |
| 40 | } |
| 41 | RAW |
| 42 | class Point { |
| 43 | has $!x is ro; |
| 44 | } |
| 45 | TIDIED |
| 46 | |
| 47 | run_test( <<'RAW', <<'TIDIED', 'Class with attribute with default value', '', ); |
| 48 | class Point { |
| 49 | has $!x is ro = 1 ; |
| 50 | } |
| 51 | RAW |
| 52 | class Point { |
| 53 | has $!x is ro = 1; |
| 54 | } |
| 55 | TIDIED |
| 56 | |
| 57 | run_test( <<'RAW', <<'TIDIED', 'Class with method', '', ); |
| 58 | class Point { |
| 59 | has $!x; |
| 60 | |
| 61 | method set_x($x) { |
| 62 | $!x = $x; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | sub name3 {} |
| 67 | RAW |
| 68 | class Point { |
| 69 | has $!x; |
| 70 | |
| 71 | method set_x ($x) { |
| 72 | $!x = $x; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | sub name3 { } |
| 77 | TIDIED |
| 78 | |
| 79 | run_test( <<'RAW', <<'TIDIED', 'Multipart class', '', ); |
| 80 | class A::Point { |
| 81 | has $!x is ro = 1 ; |
| 82 | } |
| 83 | RAW |
| 84 | class A::Point { |
| 85 | has $!x is ro = 1; |
| 86 | } |
| 87 | TIDIED |
| 88 | |
| 89 | done_testing; |