| 1 | package TidierTestsscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/; |
| 2 | |
| 3 | use strictscip-perl cpan Perl-Tidy-Sweetened 1.20 strict/; |
| 4 | use warningsscip-perl cpan Perl-Tidy-Sweetened 1.20 warnings/; |
| 5 | use Perl::Tidy::Sweetenedscip-perl cpan Perl-Tidy-Sweetened 1.20 Perl/Tidy/Sweetened/; |
| 6 | use Test::Mostscip-perl cpan Perl-Tidy-Sweetened 1.20 Test/Most/; |
| 7 | |
| 8 | use Exporterscip-perl cpan Perl-Tidy-Sweetened 1.20 Exporter/; |
| 9 | @TidierTests::ISAscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/`@ISA`. = qw(Exporter); |
| 10 | @TidierTests::EXPORTscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/`@EXPORT`. = qw(run_test); |
| 11 | @TidierTests::EXPORT_OKscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/`@EXPORT_OK`. = qw($indent_tc $indent_csc); |
| 12 | |
| 13 | sub run_testscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/run_test(). { |
| 14 | my ( $raw, $expected, $msg, $todo, @args ) = @_scip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/`@_`.; |
| 15 | |
| 16 | my $errorbuffer = ''; |
| 17 | my @tidied; |
| 18 | ## warn "# -nsyn -ce -npro -l=60 " . join( ' ', @args ), "\n"; |
| 19 | Perl::Tidy::Sweetened::perltidyscip-perl cpan Perl-Tidy-Sweetened 1.20 Perl/Tidy/Sweetened/perltidy().( |
| 20 | source => \$raw, |
| 21 | destination => \@tidied, |
| 22 | perltidyrc => undef, |
| 23 | errorfile => \$errorbuffer, |
| 24 | argv => '-nsyn -ce -npro -l=60 ' . joinscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/join().( ' ', @args ), |
| 25 | ); |
| 26 | my $tidied = joinscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/join(). '', @tidied; |
| 27 | |
| 28 | if ($todo) { |
| 29 | |
| 30 | TODO: { |
| 31 | # Works with Test::More prior to 1.301001_? |
| 32 | local $TidierTests::TODOscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/$TODO. = 'Not implmented'; |
| 33 | |
| 34 | # Works with Test::More after 1.301001_021 |
| 35 | local $TODOscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/$TODO. = 'Not implmented'; |
| 36 | |
| 37 | return check_testscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/check_test().( $tidied, $expected, $errorbuffer, $msg ); |
| 38 | } |
| 39 | |
| 40 | } else { |
| 41 | return check_testscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/check_test().( $tidied, $expected, $errorbuffer, $msg ); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | sub check_testscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/check_test(). { |
| 46 | my ( $tidied, $expected, $errors, $msg ) = @_scip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/`@_`.; |
| 47 | |
| 48 | my $ok_log = isscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/is().( $errors, '', "$msg: no errors" ); |
| 49 | my $ok_tidy = eq_or_diffscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/eq_or_diff().( $tidied, $expected, "$msg: matches" ); |
| 50 | |
| 51 | return $ok_log && $ok_tidy; |
| 52 | } |
| 53 | |
| 54 | # Handle changes in spacing between versions |
| 55 | requirescip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/require(). Perl::Tidy; |
| 56 | ## Perl::Tidy changed spacing for trailing comments in v v20200907 |
| 57 | our $indent_tcscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/$indent_tc. = ' ' x ( ( $Perl::Tidy::VERSIONscip-perl cpan Perl-Tidy-Sweetened 1.20 Perl/Tidy/$VERSION. < 20200907 ) ? 8 : 4 ); |
| 58 | ## Perl::Tidy changed spacing for closing side comments in v20200110 |
| 59 | our $indent_cscscip-perl cpan Perl-Tidy-Sweetened 1.20 TidierTests/$indent_csc. = ' ' x ( ( $Perl::Tidy::VERSIONscip-perl cpan Perl-Tidy-Sweetened 1.20 Perl/Tidy/$VERSION. < 20200110 ) ? 4 : 1 ); |
| 60 | |
| 61 | 1; |